aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs/hpfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hpfs/hpfs.h')
-rw-r--r--fs/hpfs/hpfs.h289
1 files changed, 140 insertions, 149 deletions
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
index 8b0650aae328..cce025aff1b1 100644
--- a/fs/hpfs/hpfs.h
+++ b/fs/hpfs/hpfs.h
@@ -51,11 +51,11 @@ struct hpfs_boot_block
51 u8 n_rootdir_entries[2]; 51 u8 n_rootdir_entries[2];
52 u8 n_sectors_s[2]; 52 u8 n_sectors_s[2];
53 u8 media_byte; 53 u8 media_byte;
54 u16 sectors_per_fat; 54 __le16 sectors_per_fat;
55 u16 sectors_per_track; 55 __le16 sectors_per_track;
56 u16 heads_per_cyl; 56 __le16 heads_per_cyl;
57 u32 n_hidden_sectors; 57 __le32 n_hidden_sectors;
58 u32 n_sectors_l; /* size of partition */ 58 __le32 n_sectors_l; /* size of partition */
59 u8 drive_number; 59 u8 drive_number;
60 u8 mbz; 60 u8 mbz;
61 u8 sig_28h; /* 28h */ 61 u8 sig_28h; /* 28h */
@@ -63,7 +63,7 @@ struct hpfs_boot_block
63 u8 vol_label[11]; 63 u8 vol_label[11];
64 u8 sig_hpfs[8]; /* "HPFS " */ 64 u8 sig_hpfs[8]; /* "HPFS " */
65 u8 pad[448]; 65 u8 pad[448];
66 u16 magic; /* aa55 */ 66 __le16 magic; /* aa55 */
67}; 67};
68 68
69 69
@@ -75,28 +75,28 @@ struct hpfs_boot_block
75 75
76struct hpfs_super_block 76struct hpfs_super_block
77{ 77{
78 u32 magic; /* f995 e849 */ 78 __le32 magic; /* f995 e849 */
79 u32 magic1; /* fa53 e9c5, more magic? */ 79 __le32 magic1; /* fa53 e9c5, more magic? */
80 u8 version; /* version of a filesystem usually 2 */ 80 u8 version; /* version of a filesystem usually 2 */
81 u8 funcversion; /* functional version - oldest version 81 u8 funcversion; /* functional version - oldest version
82 of filesystem that can understand 82 of filesystem that can understand
83 this disk */ 83 this disk */
84 u16 zero; /* 0 */ 84 __le16 zero; /* 0 */
85 fnode_secno root; /* fnode of root directory */ 85 __le32 root; /* fnode of root directory */
86 secno n_sectors; /* size of filesystem */ 86 __le32 n_sectors; /* size of filesystem */
87 u32 n_badblocks; /* number of bad blocks */ 87 __le32 n_badblocks; /* number of bad blocks */
88 secno bitmaps; /* pointers to free space bit maps */ 88 __le32 bitmaps; /* pointers to free space bit maps */
89 u32 zero1; /* 0 */ 89 __le32 zero1; /* 0 */
90 secno badblocks; /* bad block list */ 90 __le32 badblocks; /* bad block list */
91 u32 zero3; /* 0 */ 91 __le32 zero3; /* 0 */
92 time32_t last_chkdsk; /* date last checked, 0 if never */ 92 __le32 last_chkdsk; /* date last checked, 0 if never */
93 time32_t last_optimize; /* date last optimized, 0 if never */ 93 __le32 last_optimize; /* date last optimized, 0 if never */
94 secno n_dir_band; /* number of sectors in dir band */ 94 __le32 n_dir_band; /* number of sectors in dir band */
95 secno dir_band_start; /* first sector in dir band */ 95 __le32 dir_band_start; /* first sector in dir band */
96 secno dir_band_end; /* last sector in dir band */ 96 __le32 dir_band_end; /* last sector in dir band */
97 secno dir_band_bitmap; /* free space map, 1 dnode per bit */ 97 __le32 dir_band_bitmap; /* free space map, 1 dnode per bit */
98 u8 volume_name[32]; /* not used */ 98 u8 volume_name[32]; /* not used */
99 secno user_id_table; /* 8 preallocated sectors - user id */ 99 __le32 user_id_table; /* 8 preallocated sectors - user id */
100 u32 zero6[103]; /* 0 */ 100 u32 zero6[103]; /* 0 */
101}; 101};
102 102
@@ -109,8 +109,8 @@ struct hpfs_super_block
109 109
110struct hpfs_spare_block 110struct hpfs_spare_block
111{ 111{
112 u32 magic; /* f991 1849 */ 112 __le32 magic; /* f991 1849 */
113 u32 magic1; /* fa52 29c5, more magic? */ 113 __le32 magic1; /* fa52 29c5, more magic? */
114 114
115#ifdef __LITTLE_ENDIAN 115#ifdef __LITTLE_ENDIAN
116 u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */ 116 u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */
@@ -153,21 +153,21 @@ struct hpfs_spare_block
153 u8 mm_contlgulty; 153 u8 mm_contlgulty;
154 u8 unused; 154 u8 unused;
155 155
156 secno hotfix_map; /* info about remapped bad sectors */ 156 __le32 hotfix_map; /* info about remapped bad sectors */
157 u32 n_spares_used; /* number of hotfixes */ 157 __le32 n_spares_used; /* number of hotfixes */
158 u32 n_spares; /* number of spares in hotfix map */ 158 __le32 n_spares; /* number of spares in hotfix map */
159 u32 n_dnode_spares_free; /* spare dnodes unused */ 159 __le32 n_dnode_spares_free; /* spare dnodes unused */
160 u32 n_dnode_spares; /* length of spare_dnodes[] list, 160 __le32 n_dnode_spares; /* length of spare_dnodes[] list,
161 follows in this block*/ 161 follows in this block*/
162 secno code_page_dir; /* code page directory block */ 162 __le32 code_page_dir; /* code page directory block */
163 u32 n_code_pages; /* number of code pages */ 163 __le32 n_code_pages; /* number of code pages */
164 u32 super_crc; /* on HPFS386 and LAN Server this is 164 __le32 super_crc; /* on HPFS386 and LAN Server this is
165 checksum of superblock, on normal 165 checksum of superblock, on normal
166 OS/2 unused */ 166 OS/2 unused */
167 u32 spare_crc; /* on HPFS386 checksum of spareblock */ 167 __le32 spare_crc; /* on HPFS386 checksum of spareblock */
168 u32 zero1[15]; /* unused */ 168 __le32 zero1[15]; /* unused */
169 dnode_secno spare_dnodes[100]; /* emergency free dnode list */ 169 __le32 spare_dnodes[100]; /* emergency free dnode list */
170 u32 zero2[1]; /* room for more? */ 170 __le32 zero2[1]; /* room for more? */
171}; 171};
172 172
173/* The bad block list is 4 sectors long. The first word must be zero, 173/* The bad block list is 4 sectors long. The first word must be zero,
@@ -202,18 +202,18 @@ struct hpfs_spare_block
202 202
203struct code_page_directory 203struct code_page_directory
204{ 204{
205 u32 magic; /* 4945 21f7 */ 205 __le32 magic; /* 4945 21f7 */
206 u32 n_code_pages; /* number of pointers following */ 206 __le32 n_code_pages; /* number of pointers following */
207 u32 zero1[2]; 207 __le32 zero1[2];
208 struct { 208 struct {
209 u16 ix; /* index */ 209 __le16 ix; /* index */
210 u16 code_page_number; /* code page number */ 210 __le16 code_page_number; /* code page number */
211 u32 bounds; /* matches corresponding word 211 __le32 bounds; /* matches corresponding word
212 in data block */ 212 in data block */
213 secno code_page_data; /* sector number of a code_page_data 213 __le32 code_page_data; /* sector number of a code_page_data
214 containing c.p. array */ 214 containing c.p. array */
215 u16 index; /* index in c.p. array in that sector*/ 215 __le16 index; /* index in c.p. array in that sector*/
216 u16 unknown; /* some unknown value; usually 0; 216 __le16 unknown; /* some unknown value; usually 0;
217 2 in Japanese version */ 217 2 in Japanese version */
218 } array[31]; /* unknown length */ 218 } array[31]; /* unknown length */
219}; 219};
@@ -224,19 +224,19 @@ struct code_page_directory
224 224
225struct code_page_data 225struct code_page_data
226{ 226{
227 u32 magic; /* 8945 21f7 */ 227 __le32 magic; /* 8945 21f7 */
228 u32 n_used; /* # elements used in c_p_data[] */ 228 __le32 n_used; /* # elements used in c_p_data[] */
229 u32 bounds[3]; /* looks a bit like 229 __le32 bounds[3]; /* looks a bit like
230 (beg1,end1), (beg2,end2) 230 (beg1,end1), (beg2,end2)
231 one byte each */ 231 one byte each */
232 u16 offs[3]; /* offsets from start of sector 232 __le16 offs[3]; /* offsets from start of sector
233 to start of c_p_data[ix] */ 233 to start of c_p_data[ix] */
234 struct { 234 struct {
235 u16 ix; /* index */ 235 __le16 ix; /* index */
236 u16 code_page_number; /* code page number */ 236 __le16 code_page_number; /* code page number */
237 u16 unknown; /* the same as in cp directory */ 237 __le16 unknown; /* the same as in cp directory */
238 u8 map[128]; /* upcase table for chars 80..ff */ 238 u8 map[128]; /* upcase table for chars 80..ff */
239 u16 zero2; 239 __le16 zero2;
240 } code_page[3]; 240 } code_page[3];
241 u8 incognita[78]; 241 u8 incognita[78];
242}; 242};
@@ -278,8 +278,8 @@ struct code_page_data
278#define DNODE_MAGIC 0x77e40aae 278#define DNODE_MAGIC 0x77e40aae
279 279
280struct dnode { 280struct dnode {
281 u32 magic; /* 77e4 0aae */ 281 __le32 magic; /* 77e4 0aae */
282 u32 first_free; /* offset from start of dnode to 282 __le32 first_free; /* offset from start of dnode to
283 first free dir entry */ 283 first free dir entry */
284#ifdef __LITTLE_ENDIAN 284#ifdef __LITTLE_ENDIAN
285 u8 root_dnode: 1; /* Is it root dnode? */ 285 u8 root_dnode: 1; /* Is it root dnode? */
@@ -293,14 +293,14 @@ struct dnode {
293 u8 root_dnode: 1; /* Is it root dnode? */ 293 u8 root_dnode: 1; /* Is it root dnode? */
294#endif 294#endif
295 u8 increment_me2[3]; 295 u8 increment_me2[3];
296 secno up; /* (root dnode) directory's fnode 296 __le32 up; /* (root dnode) directory's fnode
297 (nonroot) parent dnode */ 297 (nonroot) parent dnode */
298 dnode_secno self; /* pointer to this dnode */ 298 __le32 self; /* pointer to this dnode */
299 u8 dirent[2028]; /* one or more dirents */ 299 u8 dirent[2028]; /* one or more dirents */
300}; 300};
301 301
302struct hpfs_dirent { 302struct hpfs_dirent {
303 u16 length; /* offset to next dirent */ 303 __le16 length; /* offset to next dirent */
304 304
305#ifdef __LITTLE_ENDIAN 305#ifdef __LITTLE_ENDIAN
306 u8 first: 1; /* set on phony ^A^A (".") entry */ 306 u8 first: 1; /* set on phony ^A^A (".") entry */
@@ -346,12 +346,12 @@ struct hpfs_dirent {
346 u8 read_only: 1; /* dos attrib */ 346 u8 read_only: 1; /* dos attrib */
347#endif 347#endif
348 348
349 fnode_secno fnode; /* fnode giving allocation info */ 349 __le32 fnode; /* fnode giving allocation info */
350 time32_t write_date; /* mtime */ 350 __le32 write_date; /* mtime */
351 u32 file_size; /* file length, bytes */ 351 __le32 file_size; /* file length, bytes */
352 time32_t read_date; /* atime */ 352 __le32 read_date; /* atime */
353 time32_t creation_date; /* ctime */ 353 __le32 creation_date; /* ctime */
354 u32 ea_size; /* total EA length, bytes */ 354 __le32 ea_size; /* total EA length, bytes */
355 u8 no_of_acls; /* number of ACL's (low 3 bits) */ 355 u8 no_of_acls; /* number of ACL's (low 3 bits) */
356 u8 ix; /* code page index (of filename), see 356 u8 ix; /* code page index (of filename), see
357 struct code_page_data */ 357 struct code_page_data */
@@ -375,50 +375,36 @@ struct hpfs_dirent {
375 375
376struct bplus_leaf_node 376struct bplus_leaf_node
377{ 377{
378 u32 file_secno; /* first file sector in extent */ 378 __le32 file_secno; /* first file sector in extent */
379 u32 length; /* length, sectors */ 379 __le32 length; /* length, sectors */
380 secno disk_secno; /* first corresponding disk sector */ 380 __le32 disk_secno; /* first corresponding disk sector */
381}; 381};
382 382
383struct bplus_internal_node 383struct bplus_internal_node
384{ 384{
385 u32 file_secno; /* subtree maps sectors < this */ 385 __le32 file_secno; /* subtree maps sectors < this */
386 anode_secno down; /* pointer to subtree */ 386 __le32 down; /* pointer to subtree */
387}; 387};
388 388
389enum {
390 BP_hbff = 1,
391 BP_fnode_parent = 0x20,
392 BP_binary_search = 0x40,
393 BP_internal = 0x80
394};
389struct bplus_header 395struct bplus_header
390{ 396{
391#ifdef __LITTLE_ENDIAN 397 u8 flags; /* bit 0 - high bit of first free entry offset
392 u8 hbff: 1; /* high bit of first free entry offset */ 398 bit 5 - we're pointed to by an fnode,
393 u8 flag1234: 4;
394 u8 fnode_parent: 1; /* ? we're pointed to by an fnode,
395 the data btree or some ea or the
396 main ea bootage pointer ea_secno */
397 /* also can get set in fnodes, which
398 may be a chkdsk glitch or may mean
399 this bit is irrelevant in fnodes,
400 or this interpretation is all wet */
401 u8 binary_search: 1; /* suggest binary search (unused) */
402 u8 internal: 1; /* 1 -> (internal) tree of anodes
403 0 -> (leaf) list of extents */
404#else
405 u8 internal: 1; /* 1 -> (internal) tree of anodes
406 0 -> (leaf) list of extents */
407 u8 binary_search: 1; /* suggest binary search (unused) */
408 u8 fnode_parent: 1; /* ? we're pointed to by an fnode,
409 the data btree or some ea or the 399 the data btree or some ea or the
410 main ea bootage pointer ea_secno */ 400 main ea bootage pointer ea_secno
411 /* also can get set in fnodes, which 401 bit 6 - suggest binary search (unused)
412 may be a chkdsk glitch or may mean 402 bit 7 - 1 -> (internal) tree of anodes
413 this bit is irrelevant in fnodes, 403 0 -> (leaf) list of extents */
414 or this interpretation is all wet */
415 u8 flag1234: 4;
416 u8 hbff: 1; /* high bit of first free entry offset */
417#endif
418 u8 fill[3]; 404 u8 fill[3];
419 u8 n_free_nodes; /* free nodes in following array */ 405 u8 n_free_nodes; /* free nodes in following array */
420 u8 n_used_nodes; /* used nodes in following array */ 406 u8 n_used_nodes; /* used nodes in following array */
421 u16 first_free; /* offset from start of header to 407 __le16 first_free; /* offset from start of header to
422 first free node in array */ 408 first free node in array */
423 union { 409 union {
424 struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving 410 struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving
@@ -428,6 +414,16 @@ struct bplus_header
428 } u; 414 } u;
429}; 415};
430 416
417static inline bool bp_internal(struct bplus_header *bp)
418{
419 return bp->flags & BP_internal;
420}
421
422static inline bool bp_fnode_parent(struct bplus_header *bp)
423{
424 return bp->flags & BP_fnode_parent;
425}
426
431/* fnode: root of allocation b+ tree, and EA's */ 427/* fnode: root of allocation b+ tree, and EA's */
432 428
433/* Every file and every directory has one fnode, pointed to by the directory 429/* Every file and every directory has one fnode, pointed to by the directory
@@ -436,62 +432,56 @@ struct bplus_header
436 432
437#define FNODE_MAGIC 0xf7e40aae 433#define FNODE_MAGIC 0xf7e40aae
438 434
435enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)};
439struct fnode 436struct fnode
440{ 437{
441 u32 magic; /* f7e4 0aae */ 438 __le32 magic; /* f7e4 0aae */
442 u32 zero1[2]; /* read history */ 439 __le32 zero1[2]; /* read history */
443 u8 len, name[15]; /* true length, truncated name */ 440 u8 len, name[15]; /* true length, truncated name */
444 fnode_secno up; /* pointer to file's directory fnode */ 441 __le32 up; /* pointer to file's directory fnode */
445 secno acl_size_l; 442 __le32 acl_size_l;
446 secno acl_secno; 443 __le32 acl_secno;
447 u16 acl_size_s; 444 __le16 acl_size_s;
448 u8 acl_anode; 445 u8 acl_anode;
449 u8 zero2; /* history bit count */ 446 u8 zero2; /* history bit count */
450 u32 ea_size_l; /* length of disk-resident ea's */ 447 __le32 ea_size_l; /* length of disk-resident ea's */
451 secno ea_secno; /* first sector of disk-resident ea's*/ 448 __le32 ea_secno; /* first sector of disk-resident ea's*/
452 u16 ea_size_s; /* length of fnode-resident ea's */ 449 __le16 ea_size_s; /* length of fnode-resident ea's */
453
454#ifdef __LITTLE_ENDIAN
455 u8 flag0: 1;
456 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
457 u8 flag234567: 6;
458#else
459 u8 flag234567: 6;
460 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
461 u8 flag0: 1;
462#endif
463 450
464#ifdef __LITTLE_ENDIAN 451 __le16 flags; /* bit 1 set -> ea_secno is an anode */
465 u8 dirflag: 1; /* 1 -> directory. first & only extent 452 /* bit 8 set -> directory. first & only extent
466 points to dnode. */
467 u8 flag9012345: 7;
468#else
469 u8 flag9012345: 7;
470 u8 dirflag: 1; /* 1 -> directory. first & only extent
471 points to dnode. */ 453 points to dnode. */
472#endif
473
474 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ 454 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */
475 union { 455 union {
476 struct bplus_leaf_node external[8]; 456 struct bplus_leaf_node external[8];
477 struct bplus_internal_node internal[12]; 457 struct bplus_internal_node internal[12];
478 } u; 458 } u;
479 459
480 u32 file_size; /* file length, bytes */ 460 __le32 file_size; /* file length, bytes */
481 u32 n_needea; /* number of EA's with NEEDEA set */ 461 __le32 n_needea; /* number of EA's with NEEDEA set */
482 u8 user_id[16]; /* unused */ 462 u8 user_id[16]; /* unused */
483 u16 ea_offs; /* offset from start of fnode 463 __le16 ea_offs; /* offset from start of fnode
484 to first fnode-resident ea */ 464 to first fnode-resident ea */
485 u8 dasd_limit_treshhold; 465 u8 dasd_limit_treshhold;
486 u8 dasd_limit_delta; 466 u8 dasd_limit_delta;
487 u32 dasd_limit; 467 __le32 dasd_limit;
488 u32 dasd_usage; 468 __le32 dasd_usage;
489 u8 ea[316]; /* zero or more EA's, packed together 469 u8 ea[316]; /* zero or more EA's, packed together
490 with no alignment padding. 470 with no alignment padding.
491 (Do not use this name, get here 471 (Do not use this name, get here
492 via fnode + ea_offs. I think.) */ 472 via fnode + ea_offs. I think.) */
493}; 473};
494 474
475static inline bool fnode_in_anode(struct fnode *p)
476{
477 return (p->flags & FNODE_anode) != 0;
478}
479
480static inline bool fnode_is_dir(struct fnode *p)
481{
482 return (p->flags & FNODE_dir) != 0;
483}
484
495 485
496/* anode: 99.44% pure allocation tree */ 486/* anode: 99.44% pure allocation tree */
497 487
@@ -499,9 +489,9 @@ struct fnode
499 489
500struct anode 490struct anode
501{ 491{
502 u32 magic; /* 37e4 0aae */ 492 __le32 magic; /* 37e4 0aae */
503 anode_secno self; /* pointer to this anode */ 493 __le32 self; /* pointer to this anode */
504 secno up; /* parent anode or fnode */ 494 __le32 up; /* parent anode or fnode */
505 495
506 struct bplus_header btree; /* b+tree, 40 extents or 60 subtrees */ 496 struct bplus_header btree; /* b+tree, 40 extents or 60 subtrees */
507 union { 497 union {
@@ -509,7 +499,7 @@ struct anode
509 struct bplus_internal_node internal[60]; 499 struct bplus_internal_node internal[60];
510 } u; 500 } u;
511 501
512 u32 fill[3]; /* unused */ 502 __le32 fill[3]; /* unused */
513}; 503};
514 504
515 505
@@ -528,32 +518,23 @@ struct anode
528 run, or in multiple runs. Flags in the fnode tell whether the EA list 518 run, or in multiple runs. Flags in the fnode tell whether the EA list
529 is immediate, in a single run, or in multiple runs. */ 519 is immediate, in a single run, or in multiple runs. */
530 520
521enum {EA_indirect = 1, EA_anode = 2, EA_needea = 128 };
531struct extended_attribute 522struct extended_attribute
532{ 523{
533#ifdef __LITTLE_ENDIAN 524 u8 flags; /* bit 0 set -> value gives sector number
534 u8 indirect: 1; /* 1 -> value gives sector number
535 where real value starts */ 525 where real value starts */
536 u8 anode: 1; /* 1 -> sector is an anode 526 /* bit 1 set -> sector is an anode
537 that points to fragmented value */ 527 that points to fragmented value */
538 u8 flag23456: 5; 528 /* bit 7 set -> required ea */
539 u8 needea: 1; /* required ea */
540#else
541 u8 needea: 1; /* required ea */
542 u8 flag23456: 5;
543 u8 anode: 1; /* 1 -> sector is an anode
544 that points to fragmented value */
545 u8 indirect: 1; /* 1 -> value gives sector number
546 where real value starts */
547#endif
548 u8 namelen; /* length of name, bytes */ 529 u8 namelen; /* length of name, bytes */
549 u8 valuelen_lo; /* length of value, bytes */ 530 u8 valuelen_lo; /* length of value, bytes */
550 u8 valuelen_hi; /* length of value, bytes */ 531 u8 valuelen_hi; /* length of value, bytes */
551 u8 name[0]; 532 u8 name[];
552 /* 533 /*
553 u8 name[namelen]; ascii attrib name 534 u8 name[namelen]; ascii attrib name
554 u8 nul; terminating '\0', not counted 535 u8 nul; terminating '\0', not counted
555 u8 value[valuelen]; value, arbitrary 536 u8 value[valuelen]; value, arbitrary
556 if this.indirect, valuelen is 8 and the value is 537 if this.flags & 1, valuelen is 8 and the value is
557 u32 length; real length of value, bytes 538 u32 length; real length of value, bytes
558 secno secno; sector address where it starts 539 secno secno; sector address where it starts
559 if this.anode, the above sector number is the root of an anode tree 540 if this.anode, the above sector number is the root of an anode tree
@@ -561,6 +542,16 @@ struct extended_attribute
561 */ 542 */
562}; 543};
563 544
545static inline bool ea_indirect(struct extended_attribute *ea)
546{
547 return ea->flags & EA_indirect;
548}
549
550static inline bool ea_in_anode(struct extended_attribute *ea)
551{
552 return ea->flags & EA_anode;
553}
554
564/* 555/*
565 Local Variables: 556 Local Variables:
566 comment-column: 40 557 comment-column: 40