Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/fs/hpfs/hpfs.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  HPFS structures by Chris Smith, 1993
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  a little bit modified by Mikulas Patocka, 1998-1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /* The paper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)      Duncan, Roy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)      Design goals and implementation of the new High Performance File System
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)      Microsoft Systems Journal  Sept 1989  v4 n5 p1(13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)    describes what HPFS looked like when it was new, and it is the source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)    of most of the information given here.  The rest is conjecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)    For definitive information on the Duncan paper, see it, not this file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)    For definitive information on HPFS, ask somebody else -- this is guesswork.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)    There are certain to be many mistakes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #error unknown endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /* Notation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) typedef u32 secno;			/* sector number, partition relative */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) typedef secno dnode_secno;		/* sector number of a dnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) typedef secno fnode_secno;		/* sector number of an fnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) typedef secno anode_secno;		/* sector number of an anode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) typedef u32 time32_t;		/* 32-bit time_t type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /* sector 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /* The boot block is very like a FAT boot block, except that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)    29h signature byte is 28h instead, and the ID string is "HPFS". */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define BB_MAGIC 0xaa55
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) struct hpfs_boot_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)   u8 jmp[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)   u8 oem_id[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)   u8 bytes_per_sector[2];	/* 512 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)   u8 sectors_per_cluster;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)   u8 n_reserved_sectors[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)   u8 n_fats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)   u8 n_rootdir_entries[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)   u8 n_sectors_s[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)   u8 media_byte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)   __le16 sectors_per_fat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)   __le16 sectors_per_track;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)   __le16 heads_per_cyl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)   __le32 n_hidden_sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)   __le32 n_sectors_l;		/* size of partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)   u8 drive_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)   u8 mbz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)   u8 sig_28h;			/* 28h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)   u8 vol_serno[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)   u8 vol_label[11];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)   u8 sig_hpfs[8];		/* "HPFS    " */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)   u8 pad[448];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)   __le16 magic;			/* aa55 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /* sector 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /* The super block has the pointer to the root directory. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define SB_MAGIC 0xf995e849
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) struct hpfs_super_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)   __le32 magic;				/* f995 e849 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)   __le32 magic1;			/* fa53 e9c5, more magic? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)   u8 version;				/* version of a filesystem  usually 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)   u8 funcversion;			/* functional version - oldest version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)   					   of filesystem that can understand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 					   this disk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)   __le16 zero;				/* 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)   __le32 root;				/* fnode of root directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)   __le32 n_sectors;			/* size of filesystem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)   __le32 n_badblocks;			/* number of bad blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)   __le32 bitmaps;			/* pointers to free space bit maps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)   __le32 zero1;				/* 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)   __le32 badblocks;			/* bad block list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)   __le32 zero3;				/* 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)   __le32 last_chkdsk;			/* date last checked, 0 if never */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)   __le32 last_optimize;			/* date last optimized, 0 if never */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)   __le32 n_dir_band;			/* number of sectors in dir band */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)   __le32 dir_band_start;			/* first sector in dir band */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)   __le32 dir_band_end;			/* last sector in dir band */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)   __le32 dir_band_bitmap;		/* free space map, 1 dnode per bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)   u8 volume_name[32];			/* not used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)   __le32 user_id_table;			/* 8 preallocated sectors - user id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)   u32 zero6[103];			/* 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* sector 17 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* The spare block has pointers to spare sectors.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define SP_MAGIC 0xf9911849
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct hpfs_spare_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)   __le32 magic;				/* f991 1849 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)   __le32 magic1;				/* fa52 29c5, more magic? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)   u8 dirty: 1;				/* 0 clean, 1 "improperly stopped" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)   u8 sparedir_used: 1;			/* spare dirblks used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)   u8 hotfixes_used: 1;			/* hotfixes used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)   u8 bad_sector: 1;			/* bad sector, corrupted disk (???) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)   u8 bad_bitmap: 1;			/* bad bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)   u8 fast: 1;				/* partition was fast formatted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)   u8 old_wrote: 1;			/* old version wrote to partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)   u8 old_wrote_1: 1;			/* old version wrote to partition (?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)   u8 old_wrote_1: 1;			/* old version wrote to partition (?) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)   u8 old_wrote: 1;			/* old version wrote to partition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)   u8 fast: 1;				/* partition was fast formatted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)   u8 bad_bitmap: 1;			/* bad bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)   u8 bad_sector: 1;			/* bad sector, corrupted disk (???) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)   u8 hotfixes_used: 1;			/* hotfixes used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)   u8 sparedir_used: 1;			/* spare dirblks used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)   u8 dirty: 1;				/* 0 clean, 1 "improperly stopped" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)   u8 install_dasd_limits: 1;		/* HPFS386 flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)   u8 resynch_dasd_limits: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)   u8 dasd_limits_operational: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)   u8 multimedia_active: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)   u8 dce_acls_active: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)   u8 dasd_limits_dirty: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)   u8 flag67: 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)   u8 flag67: 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)   u8 dasd_limits_dirty: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)   u8 dce_acls_active: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)   u8 multimedia_active: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)   u8 dasd_limits_operational: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)   u8 resynch_dasd_limits: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)   u8 install_dasd_limits: 1;		/* HPFS386 flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)   u8 mm_contlgulty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)   u8 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)   __le32 hotfix_map;			/* info about remapped bad sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)   __le32 n_spares_used;			/* number of hotfixes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)   __le32 n_spares;			/* number of spares in hotfix map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)   __le32 n_dnode_spares_free;		/* spare dnodes unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)   __le32 n_dnode_spares;		/* length of spare_dnodes[] list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 					   follows in this block*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)   __le32 code_page_dir;			/* code page directory block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)   __le32 n_code_pages;			/* number of code pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)   __le32 super_crc;			/* on HPFS386 and LAN Server this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)   					   checksum of superblock, on normal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 					   OS/2 unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)   __le32 spare_crc;			/* on HPFS386 checksum of spareblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)   __le32 zero1[15];			/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)   __le32 spare_dnodes[100];		/* emergency free dnode list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)   __le32 zero2[1];			/* room for more? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* The bad block list is 4 sectors long.  The first word must be zero,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)    the remaining words give n_badblocks bad block numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)    I bet you can see it coming... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #define BAD_MAGIC 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)        
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* The hotfix map is 4 sectors long.  It looks like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)        secno from[n_spares];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)        secno to[n_spares];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)    The to[] list is initialized to point to n_spares preallocated empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)    sectors.  The from[] list contains the sector numbers of bad blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)    which have been remapped to corresponding sectors in the to[] list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)    n_spares_used gives the length of the from[] list. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Sectors 18 and 19 are preallocated and unused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)    Maybe they're spares for 16 and 17, but simple substitution fails. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* The code page info pointed to by the spare block consists of an index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)    block and blocks containing uppercasing tables.  I don't know what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)    these are for (CHKDSK, maybe?) -- OS/2 does not seem to use them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)    itself.  Linux doesn't use them either. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /* block pointed to by spareblock->code_page_dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define CP_DIR_MAGIC 0x494521f7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct code_page_directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)   __le32 magic;				/* 4945 21f7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)   __le32 n_code_pages;			/* number of pointers following */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)   __le32 zero1[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)   struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)     __le16 ix;				/* index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)     __le16 code_page_number;		/* code page number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)     __le32 bounds;			/* matches corresponding word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 					   in data block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)     __le32 code_page_data;		/* sector number of a code_page_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					   containing c.p. array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)     __le16 index;			/* index in c.p. array in that sector*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)     __le16 unknown;			/* some unknown value; usually 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)     					   2 in Japanese version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)   } array[31];				/* unknown length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* blocks pointed to by code_page_directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #define CP_DATA_MAGIC 0x894521f7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct code_page_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)   __le32 magic;				/* 8945 21f7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)   __le32 n_used;			/* # elements used in c_p_data[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)   __le32 bounds[3];			/* looks a bit like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 					     (beg1,end1), (beg2,end2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					   one byte each */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)   __le16 offs[3];			/* offsets from start of sector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 					   to start of c_p_data[ix] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)   struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)     __le16 ix;				/* index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)     __le16 code_page_number;		/* code page number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)     __le16 unknown;			/* the same as in cp directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)     u8 map[128];			/* upcase table for chars 80..ff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)     __le16 zero2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)   } code_page[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)   u8 incognita[78];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /* Free space bitmaps are 4 sectors long, which is 16384 bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)    16384 sectors is 8 meg, and each 8 meg band has a 4-sector bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)    Bit order in the maps is little-endian.  0 means taken, 1 means free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)    Bit map sectors are marked allocated in the bit maps, and so are sectors 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)    off the end of the partition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)    Band 0 is sectors 0-3fff, its map is in sectors 18-1b.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)    Band 1 is 4000-7fff, its map is in 7ffc-7fff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)    Band 2 is 8000-ffff, its map is in 8000-8003.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)    The remaining bands have maps in their first (even) or last (odd) 4 sectors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)      -- if the last, partial, band is odd its map is in its last 4 sectors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)    The bitmap locations are given in a table pointed to by the super block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)    No doubt they aren't constrained to be at 18, 7ffc, 8000, ...; that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)    just where they usually are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)    The "directory band" is a bunch of sectors preallocated for dnodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)    It has a 4-sector free space bitmap of its own.  Each bit in the map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)    corresponds to one 4-sector dnode, bit 0 of the map corresponding to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)    the first 4 sectors of the directory band.  The entire band is marked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)    allocated in the main bitmap.   The super block gives the locations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)    of the directory band and its bitmap.  ("band" doesn't mean it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)    8 meg long; it isn't.)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* dnode: directory.  4 sectors long */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /* A directory is a tree of dnodes.  The fnode for a directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)    contains one pointer, to the root dnode of the tree.  The fnode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)    never moves, the dnodes do the B-tree thing, splitting and merging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)    as files are added and removed.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #define DNODE_MAGIC   0x77e40aae
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct dnode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)   __le32 magic;				/* 77e4 0aae */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)   __le32 first_free;			/* offset from start of dnode to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 					   first free dir entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)   u8 root_dnode: 1;			/* Is it root dnode? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)   u8 increment_me: 7;			/* some kind of activity counter? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 					/* Neither HPFS.IFS nor CHKDSK cares
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 					   if you change this word */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)   u8 increment_me: 7;			/* some kind of activity counter? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 					/* Neither HPFS.IFS nor CHKDSK cares
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 					   if you change this word */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)   u8 root_dnode: 1;			/* Is it root dnode? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)   u8 increment_me2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)   __le32 up;				/* (root dnode) directory's fnode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 					   (nonroot) parent dnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)   __le32 self;			/* pointer to this dnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)   u8 dirent[2028];			/* one or more dirents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) struct hpfs_dirent {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)   __le16 length;			/* offset to next dirent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)   u8 first: 1;				/* set on phony ^A^A (".") entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)   u8 has_acl: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)   u8 down: 1;				/* down pointer present (after name) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)   u8 last: 1;				/* set on phony \377 entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)   u8 has_ea: 1;				/* entry has EA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)   u8 has_xtd_perm: 1;			/* has extended perm list (???) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)   u8 has_explicit_acl: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)   u8 has_needea: 1;			/* ?? some EA has NEEDEA set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 					   I have no idea why this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 					   interesting in a dir entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)   u8 has_needea: 1;			/* ?? some EA has NEEDEA set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 					   I have no idea why this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 					   interesting in a dir entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)   u8 has_explicit_acl: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)   u8 has_xtd_perm: 1;			/* has extended perm list (???) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)   u8 has_ea: 1;				/* entry has EA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)   u8 last: 1;				/* set on phony \377 entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)   u8 down: 1;				/* down pointer present (after name) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)   u8 has_acl: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)   u8 first: 1;				/* set on phony ^A^A (".") entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)   u8 read_only: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)   u8 hidden: 1;				/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)   u8 system: 1;				/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)   u8 flag11: 1;				/* would be volume label dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)   u8 directory: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)   u8 archive: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)   u8 not_8x3: 1;			/* name is not 8.3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)   u8 flag15: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)   u8 flag15: 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)   u8 not_8x3: 1;			/* name is not 8.3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)   u8 archive: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)   u8 directory: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)   u8 flag11: 1;				/* would be volume label dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)   u8 system: 1;				/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)   u8 hidden: 1;				/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)   u8 read_only: 1;			/* dos attrib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)   __le32 fnode;				/* fnode giving allocation info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)   __le32 write_date;			/* mtime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)   __le32 file_size;			/* file length, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)   __le32 read_date;			/* atime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)   __le32 creation_date;			/* ctime */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)   __le32 ea_size;			/* total EA length, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)   u8 no_of_acls;			/* number of ACL's (low 3 bits) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)   u8 ix;				/* code page index (of filename), see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 					   struct code_page_data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)   u8 namelen, name[1];			/* file name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)   /* dnode_secno down;	  btree down pointer, if present,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)      			  follows name on next word boundary, or maybe it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			  precedes next dirent, which is on a word boundary. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /* B+ tree: allocation info in fnodes and anodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* dnodes point to fnodes which are responsible for listing the sectors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)    assigned to the file.  This is done with trees of (length,address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)    pairs.  (Actually triples, of (length, file-address, disk-address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)    which can represent holes.  Find out if HPFS does that.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)    At any rate, fnodes contain a small tree; if subtrees are needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)    they occupy essentially a full block in anodes.  A leaf-level tree node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)    has 3-word entries giving sector runs, a non-leaf node has 2-word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)    entries giving subtree pointers.  A flag in the header says which. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct bplus_leaf_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)   __le32 file_secno;			/* first file sector in extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)   __le32 length;			/* length, sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)   __le32 disk_secno;			/* first corresponding disk sector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) struct bplus_internal_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)   __le32 file_secno;			/* subtree maps sectors < this  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)   __le32 down;				/* pointer to subtree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	BP_hbff = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	BP_fnode_parent = 0x20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	BP_binary_search = 0x40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	BP_internal = 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) struct bplus_header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)   u8 flags;				/* bit 0 - high bit of first free entry offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 					   bit 5 - we're pointed to by an fnode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 					   the data btree or some ea or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 					   main ea bootage pointer ea_secno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 					   bit 6 - suggest binary search (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 					   bit 7 - 1 -> (internal) tree of anodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 						   0 -> (leaf) list of extents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)   u8 fill[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)   u8 n_free_nodes;			/* free nodes in following array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)   u8 n_used_nodes;			/* used nodes in following array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)   __le16 first_free;			/* offset from start of header to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 					   first free node in array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)   union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)     struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 					       subtree pointers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)     struct bplus_leaf_node external[0];	    /* (external) 3-word entries giving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 					       sector runs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)   } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static inline bool bp_internal(struct bplus_header *bp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	return bp->flags & BP_internal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) static inline bool bp_fnode_parent(struct bplus_header *bp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	return bp->flags & BP_fnode_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) /* fnode: root of allocation b+ tree, and EA's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) /* Every file and every directory has one fnode, pointed to by the directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)    entry and pointing to the file's sectors or directory's root dnode.  EA's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)    are also stored here, and there are said to be ACL's somewhere here too. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) #define FNODE_MAGIC 0xf7e40aae
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) struct fnode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)   __le32 magic;				/* f7e4 0aae */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)   __le32 zero1[2];			/* read history */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)   u8 len, name[15];			/* true length, truncated name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)   __le32 up;				/* pointer to file's directory fnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)   __le32 acl_size_l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)   __le32 acl_secno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)   __le16 acl_size_s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)   u8 acl_anode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)   u8 zero2;				/* history bit count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)   __le32 ea_size_l;			/* length of disk-resident ea's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)   __le32 ea_secno;			/* first sector of disk-resident ea's*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)   __le16 ea_size_s;			/* length of fnode-resident ea's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)   __le16 flags;				/* bit 1 set -> ea_secno is an anode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 					/* bit 8 set -> directory.  first & only extent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 					   points to dnode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)   struct bplus_header btree;		/* b+ tree, 8 extents or 12 subtrees */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)   union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)     struct bplus_leaf_node external[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)     struct bplus_internal_node internal[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)   } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)   __le32 file_size;			/* file length, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)   __le32 n_needea;			/* number of EA's with NEEDEA set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)   u8 user_id[16];			/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)   __le16 ea_offs;			/* offset from start of fnode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 					   to first fnode-resident ea */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)   u8 dasd_limit_treshhold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)   u8 dasd_limit_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)   __le32 dasd_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)   __le32 dasd_usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)   u8 ea[316];				/* zero or more EA's, packed together
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 					   with no alignment padding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 					   (Do not use this name, get here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 					   via fnode + ea_offs. I think.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) static inline bool fnode_in_anode(struct fnode *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	return (p->flags & FNODE_anode) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) static inline bool fnode_is_dir(struct fnode *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	return (p->flags & FNODE_dir) != 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) /* anode: 99.44% pure allocation tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) #define ANODE_MAGIC 0x37e40aae
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct anode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)   __le32 magic;				/* 37e4 0aae */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)   __le32 self;				/* pointer to this anode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)   __le32 up;				/* parent anode or fnode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)   struct bplus_header btree;		/* b+tree, 40 extents or 60 subtrees */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)   union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)     struct bplus_leaf_node external[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)     struct bplus_internal_node internal[60];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)   } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)   __le32 fill[3];			/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) /* extended attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)    A file's EA info is stored as a list of (name,value) pairs.  It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)    usually in the fnode, but (if it's large) it is moved to a single
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)    sector run outside the fnode, or to multiple runs with an anode tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)    that points to them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)    The value of a single EA is stored along with the name, or (if large)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)    it is moved to a single sector run, or multiple runs pointed to by an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)    anode tree, pointed to by the value field of the (name,value) pair.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)    Flags in the EA tell whether the value is immediate, in a single sector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)    run, or in multiple runs.  Flags in the fnode tell whether the EA list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)    is immediate, in a single run, or in multiple runs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) enum {EA_indirect = 1, EA_anode = 2, EA_needea = 128 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) struct extended_attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)   u8 flags;				/* bit 0 set -> value gives sector number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 					   where real value starts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 					/* bit 1 set -> sector is an anode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 					   that points to fragmented value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 					/* bit 7 set -> required ea */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)   u8 namelen;				/* length of name, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)   u8 valuelen_lo;			/* length of value, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)   u8 valuelen_hi;			/* length of value, bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)   u8 name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)   /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)     u8 name[namelen];			ascii attrib name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)     u8 nul;				terminating '\0', not counted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)     u8 value[valuelen];			value, arbitrary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)       if this.flags & 1, valuelen is 8 and the value is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)         u32 length;			real length of value, bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)         secno secno;			sector address where it starts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)       if this.anode, the above sector number is the root of an anode tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)         which points to the value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) static inline bool ea_indirect(struct extended_attribute *ea)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	return ea->flags & EA_indirect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) static inline bool ea_in_anode(struct extended_attribute *ea)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	return ea->flags & EA_anode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)    Local Variables:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)    comment-column: 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)    End:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) */