ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

msdos_fs.h
Go to the documentation of this file.
00001 #ifndef _LINUX_MSDOS_FS_H
00002 #define _LINUX_MSDOS_FS_H
00003 
00004 /*
00005  * The MS-DOS filesystem constants/structures
00006  */
00007 #ifdef _M_IX86
00008 #include "byteorder.h"
00009 #endif
00010 
00011 #define SECTOR_SIZE 512     /* sector size (bytes) */
00012 #define SECTOR_BITS 9       /* log2(SECTOR_SIZE) */
00013 #define MSDOS_DPB   (MSDOS_DPS) /* dir entries per block */
00014 #define MSDOS_DPB_BITS  4       /* log2(MSDOS_DPB) */
00015 #define MSDOS_DPS   (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
00016 #define MSDOS_DPS_BITS  4       /* log2(MSDOS_DPS) */
00017 #if 0
00018 #define CF_LE_W(v)  le16_to_cpu(v)
00019 #define CF_LE_L(v)  le32_to_cpu(v)
00020 #define CT_LE_W(v)  cpu_to_le16(v)
00021 #define CT_LE_L(v)  cpu_to_le32(v)
00022 #endif
00023 
00024 #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
00025 
00026 #define MSDOS_ROOT_INO  1   /* == MINIX_ROOT_INO */
00027 #define MSDOS_DIR_BITS  5   /* log2(sizeof(struct msdos_dir_entry)) */
00028 
00029 /* directory limit */
00030 #define FAT_MAX_DIR_ENTRIES (65536)
00031 #define FAT_MAX_DIR_SIZE    (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
00032 
00033 #define ATTR_NONE   0   /* no attribute bits */
00034 #define ATTR_RO     1   /* read-only */
00035 #define ATTR_HIDDEN 2   /* hidden */
00036 #define ATTR_SYS    4   /* system */
00037 #define ATTR_VOLUME 8   /* volume label */
00038 #define ATTR_DIR    16  /* directory */
00039 #define ATTR_ARCH   32  /* archived */
00040 
00041 /* attribute bits that are copied "as is" */
00042 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
00043 /* bits that are used by the Windows 95/Windows NT extended FAT */
00044 #define ATTR_EXT    (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
00045 
00046 #define CASE_LOWER_BASE 8   /* base is lower case */
00047 #define CASE_LOWER_EXT  16  /* extension is lower case */
00048 
00049 #define DELETED_FLAG    0xe5    /* marks file as deleted when in name[0] */
00050 #define IS_FREE(n)  (!*(n) || *(n) == DELETED_FLAG)
00051 
00052 /* valid file mode bits */
00053 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
00054 /* Convert attribute bits and a mask to the UNIX mode. */
00055 #define MSDOS_MKMODE(a, m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
00056 
00057 #define MSDOS_NAME  11  /* maximum name length */
00058 #define MSDOS_LONGNAME  256 /* maximum name length */
00059 #define MSDOS_SLOTS 21  /* max # of slots for short and long names */
00060 #define MSDOS_DOT   ".          "   /* ".", padded to MSDOS_NAME chars */
00061 #define MSDOS_DOTDOT    "..         "   /* "..", padded to MSDOS_NAME chars */
00062 
00063 /* media of boot sector */
00064 #define FAT_VALID_MEDIA(x)  ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
00065 #define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
00066     MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
00067 
00068 /* start of data cluster's entry (number of reserved clusters) */
00069 #define FAT_START_ENT   2
00070 
00071 /* maximum number of clusters */
00072 #define MAX_FAT12   0xFF4
00073 #define MAX_FAT16   0xFFF4
00074 #define MAX_FAT32   0x0FFFFFF6
00075 #define MAX_FAT(s)  (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
00076     MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
00077 
00078 /* bad cluster mark */
00079 #define BAD_FAT12   0xFF7
00080 #define BAD_FAT16   0xFFF7
00081 #define BAD_FAT32   0x0FFFFFF7
00082 
00083 /* standard EOF */
00084 #define EOF_FAT12   0xFFF
00085 #define EOF_FAT16   0xFFFF
00086 #define EOF_FAT32   0x0FFFFFFF
00087 
00088 #define FAT_ENT_FREE    (0)
00089 #define FAT_ENT_BAD (BAD_FAT32)
00090 #define FAT_ENT_EOF (EOF_FAT32)
00091 
00092 #define FAT_FSINFO_SIG1 0x41615252
00093 #define FAT_FSINFO_SIG2 0x61417272
00094 #define IS_FSINFO(x)    (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
00095              && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
00096 
00097 /*
00098  * ioctl commands
00099  */
00100 #define VFAT_IOCTL_READDIR_BOTH     _IOR('r', 1, struct dirent [2])
00101 #define VFAT_IOCTL_READDIR_SHORT    _IOR('r', 2, struct dirent [2])
00102 /* <linux/videotext.h> has used 0x72 ('r') in collision, so skip a few */
00103 #define FAT_IOCTL_GET_ATTRIBUTES    _IOR('r', 0x10, __u32)
00104 #define FAT_IOCTL_SET_ATTRIBUTES    _IOW('r', 0x11, __u32)
00105 
00106 /*
00107  * vfat shortname flags
00108  */
00109 #define VFAT_SFN_DISPLAY_LOWER  0x0001 /* convert to lowercase for display */
00110 #define VFAT_SFN_DISPLAY_WIN95  0x0002 /* emulate win95 rule for display */
00111 #define VFAT_SFN_DISPLAY_WINNT  0x0004 /* emulate winnt rule for display */
00112 #define VFAT_SFN_CREATE_WIN95   0x0100 /* emulate win95 rule for create */
00113 #define VFAT_SFN_CREATE_WINNT   0x0200 /* emulate winnt rule for create */
00114 
00115 struct fat_boot_sector {
00116     __u8    ignored[3]; /* Boot strap short or near jump */
00117     __u8    system_id[8];   /* Name - can be used to special case
00118                    partition manager volumes */
00119     __u8    sector_size[2]; /* bytes per logical sector */
00120     __u8    sec_per_clus;   /* sectors/cluster */
00121     __le16  reserved;   /* reserved sectors */
00122     __u8    fats;       /* number of FATs */
00123     __u8    dir_entries[2]; /* root directory entries */
00124     __u8    sectors[2]; /* number of sectors */
00125     __u8    media;      /* media code */
00126     __le16  fat_length; /* sectors/FAT */
00127     __le16  secs_track; /* sectors per track */
00128     __le16  heads;      /* number of heads */
00129     __le32  hidden;     /* hidden sectors (unused) */
00130     __le32  total_sect; /* number of sectors (if sectors == 0) */
00131 
00132     /* The following fields are only used by FAT32 */
00133     __le32  fat32_length;   /* sectors/FAT */
00134     __le16  flags;      /* bit 8: fat mirroring, low 4: active fat */
00135     __u8    version[2]; /* major, minor filesystem version */
00136     __le32  root_cluster;   /* first cluster in root directory */
00137     __le16  info_sector;    /* filesystem info sector */
00138     __le16  backup_boot;    /* backup boot sector */
00139     __le16  reserved2[6];   /* Unused */
00140 };
00141 
00142 struct fat_boot_fsinfo {
00143     __le32   signature1;    /* 0x41615252L */
00144     __le32   reserved1[120];    /* Nothing as far as I can tell */
00145     __le32   signature2;    /* 0x61417272L */
00146     __le32   free_clusters; /* Free cluster count.  -1 if unknown */
00147     __le32   next_cluster;  /* Most recently allocated cluster */
00148     __le32   reserved2[4];
00149 };
00150 
00151 struct msdos_dir_entry {
00152     __u8    name[8],ext[3]; /* name and extension */
00153     __u8    attr;       /* attribute bits */
00154     __u8    lcase;      /* Case for base and extension */
00155     __u8    ctime_cs;   /* Creation time, centiseconds (0-199) */
00156     __le16  ctime;      /* Creation time */
00157     __le16  cdate;      /* Creation date */
00158     __le16  adate;      /* Last access date */
00159     __le16  starthi;    /* High 16 bits of cluster in FAT32 */
00160     __le16  time,date,start;/* time, date and first cluster */
00161     __le32  size;       /* file size (in bytes) */
00162 };
00163 
00164 /* Up to 13 characters of the name */
00165 struct msdos_dir_slot {
00166     __u8    id;     /* sequence number for slot */
00167     __u8    name0_4[10];    /* first 5 characters in name */
00168     __u8    attr;       /* attribute byte */
00169     __u8    reserved;   /* always 0 */
00170     __u8    alias_checksum; /* checksum for 8.3 alias */
00171     __u8    name5_10[12];   /* 6 more characters in name */
00172     __le16   start;     /* starting cluster number, 0 in long slots */
00173     __u8    name11_12[4];   /* last 2 characters in name */
00174 };
00175 
00176 struct fat_slot_info {
00177     loff_t i_pos;       /* on-disk position of directory entry */
00178     loff_t slot_off;    /* offset for slot or de start */
00179     int nr_slots;       /* number of slots + 1(de) in filename */
00180     struct msdos_dir_entry *de;
00181     struct buffer_head *bh;
00182 };
00183 
00184 #endif

Generated on Sat May 26 2012 04:35:04 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.