"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "dosfstools-2.11/dosfsck/dosfsck.h" of archive dosfstools-2.11.src.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /* dosfsck.h - Common data structures and global variables */
2
3 /* Written 1993 by Werner Almesberger */
4
5 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
6 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
7
8
9 #ifndef _DOSFSCK_H
10 #define _DOSFSCK_H
11
12 #include <sys/types.h>
13 #define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
14 #define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
15 #define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
16
17 #include <linux/version.h>
18 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
19 # define __KERNEL__
20 # include <asm/types.h>
21 # include <asm/byteorder.h>
22 # undef __KERNEL__
23 #endif
24
25 #include <linux/msdos_fs.h>
26
27 #undef CF_LE_W
28 #undef CF_LE_L
29 #undef CT_LE_W
30 #undef CT_LE_L
31
32 #if __BYTE_ORDER == __BIG_ENDIAN
33 #include <byteswap.h>
34 #define CF_LE_W(v) bswap_16(v)
35 #define CF_LE_L(v) bswap_32(v)
36 #define CT_LE_W(v) CF_LE_W(v)
37 #define CT_LE_L(v) CF_LE_L(v)
38 #else
39 #define CF_LE_W(v) (v)
40 #define CF_LE_L(v) (v)
41 #define CT_LE_W(v) (v)
42 #define CT_LE_L(v) (v)
43 #endif /* __BIG_ENDIAN */
44
45 #define VFAT_LN_ATTR (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
46
47 /* ++roman: Use own definition of boot sector structure -- the kernel headers'
48 * name for it is msdos_boot_sector in 2.0 and fat_boot_sector in 2.1 ... */
49 struct boot_sector {
50 __u8 ignored[3]; /* Boot strap short or near jump */
51 __u8 system_id[8]; /* Name - can be used to special case
52 partition manager volumes */
53 __u8 sector_size[2]; /* bytes per logical sector */
54 __u8 cluster_size; /* sectors/cluster */
55 __u16 reserved; /* reserved sectors */
56 __u8 fats; /* number of FATs */
57 __u8 dir_entries[2]; /* root directory entries */
58 __u8 sectors[2]; /* number of sectors */
59 __u8 media; /* media code (unused) */
60 __u16 fat_length; /* sectors/FAT */
61 __u16 secs_track; /* sectors per track */
62 __u16 heads; /* number of heads */
63 __u32 hidden; /* hidden sectors (unused) */
64 __u32 total_sect; /* number of sectors (if sectors == 0) */
65
66 /* The following fields are only used by FAT32 */
67 __u32 fat32_length; /* sectors/FAT */
68 __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
69 __u8 version[2]; /* major, minor filesystem version */
70 __u32 root_cluster; /* first cluster in root directory */
71 __u16 info_sector; /* filesystem info sector */
72 __u16 backup_boot; /* backup boot sector */
73 __u16 reserved2[6]; /* Unused */
74
75 /* fill up to 512 bytes */
76 __u8 junk[448];
77 } __attribute__ ((packed));
78
79 struct info_sector {
80 __u32 magic; /* Magic for info sector ('RRaA') */
81 __u8 junk[0x1dc];
82 __u32 reserved1; /* Nothing as far as I can tell */
83 __u32 signature; /* 0x61417272 ('rrAa') */
84 __u32 free_clusters; /* Free cluster count. -1 if unknown */
85 __u32 next_cluster; /* Most recently allocated cluster. */
86 __u32 reserved2[3];
87 __u16 reserved3;
88 __u16 boot_sign;
89 };
90
91 typedef struct {
92 __u8 name[8],ext[3]; /* name and extension */
93 __u8 attr; /* attribute bits */
94 __u8 lcase; /* Case for base and extension */
95 __u8 ctime_ms; /* Creation time, milliseconds */
96 __u16 ctime; /* Creation time */
97 __u16 cdate; /* Creation date */
98 __u16 adate; /* Last access date */
99 __u16 starthi; /* High 16 bits of cluster in FAT32 */
100 __u16 time,date,start;/* time, date and first cluster */
101 __u32 size; /* file size (in bytes) */
102 } DIR_ENT;
103
104 typedef struct _dos_file {
105 DIR_ENT dir_ent;
106 char *lfn;
107 loff_t offset;
108 struct _dos_file *parent; /* parent directory */
109 struct _dos_file *next; /* next entry */
110 struct _dos_file *first; /* first entry (directory only) */
111 } DOS_FILE;
112
113 typedef struct {
114 unsigned long value;
115 unsigned long reserved;
116 DOS_FILE *owner;
117 int prev; /* number of previous clusters */
118 } FAT_ENTRY;
119
120 typedef struct {
121 int nfats;
122 loff_t fat_start;
123 unsigned int fat_size; /* unit is bytes */
124 unsigned int fat_bits; /* size of a FAT entry */
125 unsigned int eff_fat_bits; /* # of used bits in a FAT entry */
126 unsigned long root_cluster; /* 0 for old-style root dir */
127 loff_t root_start;
128 unsigned int root_entries;
129 loff_t data_start;
130 unsigned int cluster_size;
131 unsigned long clusters;
132 loff_t fsinfo_start; /* 0 if not present */
133 long free_clusters;
134 loff_t backupboot_start; /* 0 if not present */
135 FAT_ENTRY *fat;
136 } DOS_FS;
137
138 #ifndef offsetof
139 #define offsetof(t,e) ((int)&(((t *)0)->e))
140 #endif
141
142 extern int interactive,list,verbose,test,write_immed;
143 extern int atari_format;
144 extern unsigned n_files;
145 extern void *mem_queue;
146
147 /* value to use as end-of-file marker */
148 #define FAT_EOF(fs) ((atari_format ? 0xfff : 0xff8) | FAT_EXTD(fs))
149 #define FAT_IS_EOF(fs,v) ((unsigned long)(v) >= (0xff8|FAT_EXTD(fs)))
150 /* value to mark bad clusters */
151 #define FAT_BAD(fs) (0xff7 | FAT_EXTD(fs))
152 /* range of values used for bad clusters */
153 #define FAT_MIN_BAD(fs) ((atari_format ? 0xff0 : 0xff7) | FAT_EXTD(fs))
154 #define FAT_MAX_BAD(fs) ((atari_format ? 0xff7 : 0xff7) | FAT_EXTD(fs))
155 #define FAT_IS_BAD(fs,v) ((v) >= FAT_MIN_BAD(fs) && (v) <= FAT_MAX_BAD(fs))
156
157 /* return -16 as a number with fs->fat_bits bits */
158 #define FAT_EXTD(fs) (((1 << fs->eff_fat_bits)-1) & ~0xf)
159
160 #endif
161
162 /* Local Variables: */
163 /* tab-width: 8 */
164 /* End: */