NetBSD/sys/msdosfs/direntry.h
cgd 54eb3b1f88 brought in fixed/renamed/matching MS-DOS FS code, from Jeff Polk
<polk@bsdi.com>.  His notes are as follows:
------------------------------------------------------------------------------

 July 22, 1993

 - Changed name of entire package from PCFS to MSDOSFS

 - Fixed bugs:
      root directory size in clusters instead of bytes
      growing directory didn't update in-core size
      link, symlink, mknod didn't free locked parent (deadlock)
      lookup returned real error on create and rename instead of EJUSTRETURN
      rename changed `.' entry in child instead of name entry in parent
      rename removed `.' entry in child instead of removing entry in
              parent when moving a directory from one dir to another
      createde() left new node locked when write of parent failed (deadlock)
      removede() decremented refcount even on error (rmdir's which failed
              due to write errors left in-core cache entries inconsistent)
      changed validation for filesystem to not check for the boot signature
              since some disks (e.g., mtools) aren't bootable
      directories are always show current time as modify time
              (needed for NFS export since DOS never updates dir mod times --
               ctime is true create time).

 - Added support for cookies changes to the readdir() vnode
      interface (#ifdef __bsdi__)

 - Punted on the whole problem of inode generation numbers.  This means
   that there's a chance of using a stale file handle to access a new
   file, but it doesn't appear to be the common case, and I don't see
   how to generate reasonable generation numbers without changing something
   on the disk (which is the way the SVR4 filesystem survival kit guys
   did it).  I don't think it would be very safe to change the on-disk
   format.

        Jeff Polk (polk@BSDI.COM)

------------------------------------------------------------------------------
1993-08-13 11:35:13 +00:00

90 lines
2.6 KiB
C

/*
* Written by Paul Popelka (paulp@uts.amdahl.com)
*
* You can do anything you want with this software, just don't say you wrote
* it, and don't remove this notice.
*
* This software is provided "as is".
*
* The author supplies this software to be publicly redistributed on the
* understanding that the author is not responsible for the correct
* functioning of this software in any circumstances and is not liable for
* any damages caused by this software.
*
* October 1992
*
* $Id: direntry.h,v 1.1 1993/08/13 11:35:32 cgd Exp $
*/
/*
* Structure of a dos directory entry.
*/
struct direntry {
u_char deName[8]; /* filename, blank filled */
#define SLOT_EMPTY 0x00 /* slot has never been used */
#define SLOT_E5 0x05 /* the real value is 0xe5 */
#define SLOT_DELETED 0xe5 /* file in this slot deleted */
u_char deExtension[3]; /* extension, blank filled */
u_char deAttributes; /* file attributes */
#define ATTR_NORMAL 0x00 /* normal file */
#define ATTR_READONLY 0x01 /* file is readonly */
#define ATTR_HIDDEN 0x02 /* file is hidden */
#define ATTR_SYSTEM 0x04 /* file is a system file */
#define ATTR_VOLUME 0x08 /* entry is a volume label */
#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
#define ATTR_ARCHIVE 0x20 /* file is new or modified */
char deReserved[10]; /* reserved */
u_short deTime; /* create/last update time */
u_short deDate; /* create/last update date */
u_short deStartCluster; /* starting cluster of file */
u_long deFileSize; /* size of file in bytes */
};
/*
* This is the format of the contents of the deTime field in the direntry
* structure.
*/
struct DOStime {
u_short
dt_2seconds:5, /* seconds divided by 2 */
dt_minutes:6, /* minutes */
dt_hours:5; /* hours */
};
/*
* This is the format of the contents of the deDate field in the direntry
* structure.
*/
struct DOSdate {
u_short
dd_day:5, /* day of month */
dd_month:4, /* month */
dd_year:7; /* years since 1980 */
};
union dostime {
struct DOStime dts;
u_short dti;
};
union dosdate {
struct DOSdate dds;
u_short ddi;
};
/*
* The following defines are used to rename fields in the ufs_specific
* structure in the nameidata structure in namei.h
*/
#define ni_msdosfs ni_ufs
#define msdosfs_count ufs_count
#define msdosfs_offset ufs_offset
#define msdosfs_cluster ufs_ino
#if defined(KERNEL)
void unix2dostime __P((struct timeval * tvp, union dosdate * ddp, union dostime * dtp));
void dos2unixtime __P((union dosdate * ddp, union dostime * dtp, struct timeval * tvp));
int dos2unixfn __P((u_char dn[11], u_char * un));
void unix2dosfn __P((u_char * un, u_char dn[11], int unlen));
#endif /* defined(KERNEL) */