diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 13:34:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 13:34:35 -0400 |
commit | 1193755ac6328ad240ba987e6ec41d5e8baf0680 (patch) | |
tree | 40bf847d7e3ebaa57b107151d14e6cd1d280cc6d /fs/hpfs | |
parent | 4edebed86690eb8db9af3ab85baf4a34e73266cc (diff) | |
parent | 0ef97dcfce4179a2eba046b855ee2f91d6f1b414 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs changes from Al Viro.
"A lot of misc stuff. The obvious groups:
* Miklos' atomic_open series; kills the damn abuse of
->d_revalidate() by NFS, which was the major stumbling block for
all work in that area.
* ripping security_file_mmap() and dealing with deadlocks in the
area; sanitizing the neighborhood of vm_mmap()/vm_munmap() in
general.
* ->encode_fh() switched to saner API; insane fake dentry in
mm/cleancache.c gone.
* assorted annotations in fs (endianness, __user)
* parts of Artem's ->s_dirty work (jff2 and reiserfs parts)
* ->update_time() work from Josef.
* other bits and pieces all over the place.
Normally it would've been in two or three pull requests, but
signal.git stuff had eaten a lot of time during this cycle ;-/"
Fix up trivial conflicts in Documentation/filesystems/vfs.txt (the
'truncate_range' inode method was removed by the VM changes, the VFS
update adds an 'update_time()' method), and in fs/btrfs/ulist.[ch] (due
to sparse fix added twice, with other changes nearby).
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (95 commits)
nfs: don't open in ->d_revalidate
vfs: retry last component if opening stale dentry
vfs: nameidata_to_filp(): don't throw away file on error
vfs: nameidata_to_filp(): inline __dentry_open()
vfs: do_dentry_open(): don't put filp
vfs: split __dentry_open()
vfs: do_last() common post lookup
vfs: do_last(): add audit_inode before open
vfs: do_last(): only return EISDIR for O_CREAT
vfs: do_last(): check LOOKUP_DIRECTORY
vfs: do_last(): make ENOENT exit RCU safe
vfs: make follow_link check RCU safe
vfs: do_last(): use inode variable
vfs: do_last(): inline walk_component()
vfs: do_last(): make exit RCU safe
vfs: split do_lookup()
Btrfs: move over to use ->update_time
fs: introduce inode operation ->update_time
reiserfs: get rid of resierfs_sync_super
reiserfs: mark the superblock as dirty a bit later
...
Diffstat (limited to 'fs/hpfs')
-rw-r--r-- | fs/hpfs/alloc.c | 14 | ||||
-rw-r--r-- | fs/hpfs/anode.c | 43 | ||||
-rw-r--r-- | fs/hpfs/dir.c | 2 | ||||
-rw-r--r-- | fs/hpfs/dnode.c | 10 | ||||
-rw-r--r-- | fs/hpfs/ea.c | 60 | ||||
-rw-r--r-- | fs/hpfs/hpfs.h | 289 | ||||
-rw-r--r-- | fs/hpfs/hpfs_fn.h | 16 | ||||
-rw-r--r-- | fs/hpfs/inode.c | 2 | ||||
-rw-r--r-- | fs/hpfs/map.c | 20 | ||||
-rw-r--r-- | fs/hpfs/namei.c | 2 | ||||
-rw-r--r-- | fs/hpfs/super.c | 4 |
11 files changed, 229 insertions, 233 deletions
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 7a5eb2c718c8..cdb84a838068 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -16,9 +16,9 @@ | |||
16 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) | 16 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) |
17 | { | 17 | { |
18 | struct quad_buffer_head qbh; | 18 | struct quad_buffer_head qbh; |
19 | u32 *bmp; | 19 | __le32 *bmp; |
20 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; | 20 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; |
21 | if ((cpu_to_le32(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { | 21 | if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { |
22 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); | 22 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); |
23 | goto fail1; | 23 | goto fail1; |
24 | } | 24 | } |
@@ -62,7 +62,7 @@ int hpfs_chk_sectors(struct super_block *s, secno start, int len, char *msg) | |||
62 | static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigned forward) | 62 | static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigned forward) |
63 | { | 63 | { |
64 | struct quad_buffer_head qbh; | 64 | struct quad_buffer_head qbh; |
65 | unsigned *bmp; | 65 | __le32 *bmp; |
66 | unsigned bs = near & ~0x3fff; | 66 | unsigned bs = near & ~0x3fff; |
67 | unsigned nr = (near & 0x3fff) & ~(n - 1); | 67 | unsigned nr = (near & 0x3fff) & ~(n - 1); |
68 | /*unsigned mnr;*/ | 68 | /*unsigned mnr;*/ |
@@ -236,7 +236,7 @@ static secno alloc_in_dirband(struct super_block *s, secno near) | |||
236 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) | 236 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) |
237 | { | 237 | { |
238 | struct quad_buffer_head qbh; | 238 | struct quad_buffer_head qbh; |
239 | u32 *bmp; | 239 | __le32 *bmp; |
240 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; | 240 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; |
241 | if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) { | 241 | if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) { |
242 | bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f))); | 242 | bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f))); |
@@ -254,7 +254,7 @@ int hpfs_alloc_if_possible(struct super_block *s, secno sec) | |||
254 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | 254 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) |
255 | { | 255 | { |
256 | struct quad_buffer_head qbh; | 256 | struct quad_buffer_head qbh; |
257 | u32 *bmp; | 257 | __le32 *bmp; |
258 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 258 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
259 | /*printk("2 - ");*/ | 259 | /*printk("2 - ");*/ |
260 | if (!n) return; | 260 | if (!n) return; |
@@ -299,7 +299,7 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) | |||
299 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; | 299 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; |
300 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; | 300 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; |
301 | int i, j; | 301 | int i, j; |
302 | u32 *bmp; | 302 | __le32 *bmp; |
303 | struct quad_buffer_head qbh; | 303 | struct quad_buffer_head qbh; |
304 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 304 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
305 | for (j = 0; j < 512; j++) { | 305 | for (j = 0; j < 512; j++) { |
@@ -351,7 +351,7 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno) | |||
351 | hpfs_free_sectors(s, dno, 4); | 351 | hpfs_free_sectors(s, dno, 4); |
352 | } else { | 352 | } else { |
353 | struct quad_buffer_head qbh; | 353 | struct quad_buffer_head qbh; |
354 | u32 *bmp; | 354 | __le32 *bmp; |
355 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; | 355 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; |
356 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 356 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
357 | return; | 357 | return; |
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index 08b503e8ed29..4bae4a4a60b1 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c | |||
@@ -20,7 +20,7 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode, | |||
20 | int c1, c2 = 0; | 20 | int c1, c2 = 0; |
21 | go_down: | 21 | go_down: |
22 | if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; | 22 | if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; |
23 | if (btree->internal) { | 23 | if (bp_internal(btree)) { |
24 | for (i = 0; i < btree->n_used_nodes; i++) | 24 | for (i = 0; i < btree->n_used_nodes; i++) |
25 | if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) { | 25 | if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) { |
26 | a = le32_to_cpu(btree->u.internal[i].down); | 26 | a = le32_to_cpu(btree->u.internal[i].down); |
@@ -82,7 +82,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
82 | brelse(bh); | 82 | brelse(bh); |
83 | return -1; | 83 | return -1; |
84 | } | 84 | } |
85 | if (btree->internal) { | 85 | if (bp_internal(btree)) { |
86 | a = le32_to_cpu(btree->u.internal[n].down); | 86 | a = le32_to_cpu(btree->u.internal[n].down); |
87 | btree->u.internal[n].file_secno = cpu_to_le32(-1); | 87 | btree->u.internal[n].file_secno = cpu_to_le32(-1); |
88 | mark_buffer_dirty(bh); | 88 | mark_buffer_dirty(bh); |
@@ -129,12 +129,12 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
129 | } | 129 | } |
130 | if (a == node && fnod) { | 130 | if (a == node && fnod) { |
131 | anode->up = cpu_to_le32(node); | 131 | anode->up = cpu_to_le32(node); |
132 | anode->btree.fnode_parent = 1; | 132 | anode->btree.flags |= BP_fnode_parent; |
133 | anode->btree.n_used_nodes = btree->n_used_nodes; | 133 | anode->btree.n_used_nodes = btree->n_used_nodes; |
134 | anode->btree.first_free = btree->first_free; | 134 | anode->btree.first_free = btree->first_free; |
135 | anode->btree.n_free_nodes = 40 - anode->btree.n_used_nodes; | 135 | anode->btree.n_free_nodes = 40 - anode->btree.n_used_nodes; |
136 | memcpy(&anode->u, &btree->u, btree->n_used_nodes * 12); | 136 | memcpy(&anode->u, &btree->u, btree->n_used_nodes * 12); |
137 | btree->internal = 1; | 137 | btree->flags |= BP_internal; |
138 | btree->n_free_nodes = 11; | 138 | btree->n_free_nodes = 11; |
139 | btree->n_used_nodes = 1; | 139 | btree->n_used_nodes = 1; |
140 | btree->first_free = cpu_to_le16((char *)&(btree->u.internal[1]) - (char *)btree); | 140 | btree->first_free = cpu_to_le16((char *)&(btree->u.internal[1]) - (char *)btree); |
@@ -184,7 +184,10 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
184 | hpfs_free_sectors(s, ra, 1); | 184 | hpfs_free_sectors(s, ra, 1); |
185 | if ((anode = hpfs_map_anode(s, na, &bh))) { | 185 | if ((anode = hpfs_map_anode(s, na, &bh))) { |
186 | anode->up = cpu_to_le32(up); | 186 | anode->up = cpu_to_le32(up); |
187 | anode->btree.fnode_parent = up == node && fnod; | 187 | if (up == node && fnod) |
188 | anode->btree.flags |= BP_fnode_parent; | ||
189 | else | ||
190 | anode->btree.flags &= ~BP_fnode_parent; | ||
188 | mark_buffer_dirty(bh); | 191 | mark_buffer_dirty(bh); |
189 | brelse(bh); | 192 | brelse(bh); |
190 | } | 193 | } |
@@ -198,7 +201,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
198 | if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { | 201 | if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { |
199 | anode = new_anode; | 202 | anode = new_anode; |
200 | /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/ | 203 | /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/ |
201 | anode->btree.internal = 1; | 204 | anode->btree.flags |= BP_internal; |
202 | anode->btree.n_used_nodes = 1; | 205 | anode->btree.n_used_nodes = 1; |
203 | anode->btree.n_free_nodes = 59; | 206 | anode->btree.n_free_nodes = 59; |
204 | anode->btree.first_free = cpu_to_le16(16); | 207 | anode->btree.first_free = cpu_to_le16(16); |
@@ -215,7 +218,8 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
215 | } | 218 | } |
216 | if ((anode = hpfs_map_anode(s, na, &bh))) { | 219 | if ((anode = hpfs_map_anode(s, na, &bh))) { |
217 | anode->up = cpu_to_le32(node); | 220 | anode->up = cpu_to_le32(node); |
218 | if (fnod) anode->btree.fnode_parent = 1; | 221 | if (fnod) |
222 | anode->btree.flags |= BP_fnode_parent; | ||
219 | mark_buffer_dirty(bh); | 223 | mark_buffer_dirty(bh); |
220 | brelse(bh); | 224 | brelse(bh); |
221 | } | 225 | } |
@@ -234,18 +238,19 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
234 | } | 238 | } |
235 | ranode->up = cpu_to_le32(node); | 239 | ranode->up = cpu_to_le32(node); |
236 | memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free)); | 240 | memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free)); |
237 | if (fnod) ranode->btree.fnode_parent = 1; | 241 | if (fnod) |
238 | ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes; | 242 | ranode->btree.flags |= BP_fnode_parent; |
239 | if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) { | 243 | ranode->btree.n_free_nodes = (bp_internal(&ranode->btree) ? 60 : 40) - ranode->btree.n_used_nodes; |
244 | if (bp_internal(&ranode->btree)) for (n = 0; n < ranode->btree.n_used_nodes; n++) { | ||
240 | struct anode *unode; | 245 | struct anode *unode; |
241 | if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) { | 246 | if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) { |
242 | unode->up = cpu_to_le32(ra); | 247 | unode->up = cpu_to_le32(ra); |
243 | unode->btree.fnode_parent = 0; | 248 | unode->btree.flags &= ~BP_fnode_parent; |
244 | mark_buffer_dirty(bh1); | 249 | mark_buffer_dirty(bh1); |
245 | brelse(bh1); | 250 | brelse(bh1); |
246 | } | 251 | } |
247 | } | 252 | } |
248 | btree->internal = 1; | 253 | btree->flags |= BP_internal; |
249 | btree->n_free_nodes = fnod ? 10 : 58; | 254 | btree->n_free_nodes = fnod ? 10 : 58; |
250 | btree->n_used_nodes = 2; | 255 | btree->n_used_nodes = 2; |
251 | btree->first_free = cpu_to_le16((char *)&btree->u.internal[2] - (char *)btree); | 256 | btree->first_free = cpu_to_le16((char *)&btree->u.internal[2] - (char *)btree); |
@@ -278,7 +283,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree) | |||
278 | int d1, d2; | 283 | int d1, d2; |
279 | go_down: | 284 | go_down: |
280 | d2 = 0; | 285 | d2 = 0; |
281 | while (btree1->internal) { | 286 | while (bp_internal(btree1)) { |
282 | ano = le32_to_cpu(btree1->u.internal[pos].down); | 287 | ano = le32_to_cpu(btree1->u.internal[pos].down); |
283 | if (level) brelse(bh); | 288 | if (level) brelse(bh); |
284 | if (hpfs_sb(s)->sb_chk) | 289 | if (hpfs_sb(s)->sb_chk) |
@@ -412,13 +417,13 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs) | |||
412 | btree->n_free_nodes = 8; | 417 | btree->n_free_nodes = 8; |
413 | btree->n_used_nodes = 0; | 418 | btree->n_used_nodes = 0; |
414 | btree->first_free = cpu_to_le16(8); | 419 | btree->first_free = cpu_to_le16(8); |
415 | btree->internal = 0; | 420 | btree->flags &= ~BP_internal; |
416 | mark_buffer_dirty(bh); | 421 | mark_buffer_dirty(bh); |
417 | } else hpfs_free_sectors(s, f, 1); | 422 | } else hpfs_free_sectors(s, f, 1); |
418 | brelse(bh); | 423 | brelse(bh); |
419 | return; | 424 | return; |
420 | } | 425 | } |
421 | while (btree->internal) { | 426 | while (bp_internal(btree)) { |
422 | nodes = btree->n_used_nodes + btree->n_free_nodes; | 427 | nodes = btree->n_used_nodes + btree->n_free_nodes; |
423 | for (i = 0; i < btree->n_used_nodes; i++) | 428 | for (i = 0; i < btree->n_used_nodes; i++) |
424 | if (le32_to_cpu(btree->u.internal[i].file_secno) >= secs) goto f; | 429 | if (le32_to_cpu(btree->u.internal[i].file_secno) >= secs) goto f; |
@@ -479,13 +484,13 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno) | |||
479 | struct extended_attribute *ea; | 484 | struct extended_attribute *ea; |
480 | struct extended_attribute *ea_end; | 485 | struct extended_attribute *ea_end; |
481 | if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; | 486 | if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; |
482 | if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); | 487 | if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, &fnode->btree); |
483 | else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); | 488 | else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); |
484 | ea_end = fnode_end_ea(fnode); | 489 | ea_end = fnode_end_ea(fnode); |
485 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 490 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
486 | if (ea->indirect) | 491 | if (ea_indirect(ea)) |
487 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 492 | hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); |
488 | hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); | 493 | hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l)); |
489 | brelse(bh); | 494 | brelse(bh); |
490 | hpfs_free_sectors(s, fno, 1); | 495 | hpfs_free_sectors(s, fno, 1); |
491 | } | 496 | } |
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index 2fa0089a02a8..b8472f803f4e 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -87,7 +87,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
87 | ret = -EIOERROR; | 87 | ret = -EIOERROR; |
88 | goto out; | 88 | goto out; |
89 | } | 89 | } |
90 | if (!fno->dirflag) { | 90 | if (!fnode_is_dir(fno)) { |
91 | e = 1; | 91 | e = 1; |
92 | hpfs_error(inode->i_sb, "not a directory, fnode %08lx", | 92 | hpfs_error(inode->i_sb, "not a directory, fnode %08lx", |
93 | (unsigned long)inode->i_ino); | 93 | (unsigned long)inode->i_ino); |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 1e0e2ac30fd3..3228c524ebe5 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -153,7 +153,7 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
153 | } | 153 | } |
154 | de->length = cpu_to_le16(36); | 154 | de->length = cpu_to_le16(36); |
155 | de->down = 1; | 155 | de->down = 1; |
156 | *(dnode_secno *)((char *)de + 32) = cpu_to_le32(ptr); | 156 | *(__le32 *)((char *)de + 32) = cpu_to_le32(ptr); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
@@ -177,7 +177,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
177 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); | 177 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); |
178 | memset(de, 0, d_size); | 178 | memset(de, 0, d_size); |
179 | if (down_ptr) { | 179 | if (down_ptr) { |
180 | *(dnode_secno *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); | 180 | *(__le32 *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); |
181 | de->down = 1; | 181 | de->down = 1; |
182 | } | 182 | } |
183 | de->length = cpu_to_le16(d_size); | 183 | de->length = cpu_to_le16(d_size); |
@@ -656,7 +656,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
656 | del->down = 0; | 656 | del->down = 0; |
657 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); | 657 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); |
658 | } else if (down) | 658 | } else if (down) |
659 | *(dnode_secno *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); | 659 | *(__le32 *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); |
660 | } else goto endm; | 660 | } else goto endm; |
661 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { | 661 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { |
662 | printk("HPFS: out of memory for dtree balancing\n"); | 662 | printk("HPFS: out of memory for dtree balancing\n"); |
@@ -672,7 +672,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
672 | de_prev->down = 1; | 672 | de_prev->down = 1; |
673 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); | 673 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); |
674 | } | 674 | } |
675 | *(dnode_secno *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); | 675 | *(__le32 *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); |
676 | hpfs_mark_4buffers_dirty(&qbh); | 676 | hpfs_mark_4buffers_dirty(&qbh); |
677 | hpfs_brelse4(&qbh); | 677 | hpfs_brelse4(&qbh); |
678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); | 678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); |
@@ -1015,7 +1015,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1015 | kfree(name2); | 1015 | kfree(name2); |
1016 | return NULL; | 1016 | return NULL; |
1017 | } | 1017 | } |
1018 | if (!upf->dirflag) { | 1018 | if (!fnode_is_dir(upf)) { |
1019 | brelse(bh); | 1019 | brelse(bh); |
1020 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); | 1020 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); |
1021 | kfree(name2); | 1021 | kfree(name2); |
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index d8b84d113c89..bcaafcd2666a 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -23,15 +23,15 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len) | |||
23 | return; | 23 | return; |
24 | } | 24 | } |
25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; | 25 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; |
26 | if (ea->indirect) { | 26 | if (ea_indirect(ea)) { |
27 | if (ea_valuelen(ea) != 8) { | 27 | if (ea_valuelen(ea) != 8) { |
28 | hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", | 28 | hpfs_error(s, "ea_indirect(ea) set while ea->valuelen!=8, %s %08x, pos %08x", |
29 | ano ? "anode" : "sectors", a, pos); | 29 | ano ? "anode" : "sectors", a, pos); |
30 | return; | 30 | return; |
31 | } | 31 | } |
32 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 9, ex+4)) | 32 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 9, ex+4)) |
33 | return; | 33 | return; |
34 | hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); | 34 | hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); |
35 | } | 35 | } |
36 | pos += ea->namelen + ea_valuelen(ea) + 5; | 36 | pos += ea->namelen + ea_valuelen(ea) + 5; |
37 | } | 37 | } |
@@ -81,7 +81,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
81 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 81 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
82 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 82 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
83 | if (!strcmp(ea->name, key)) { | 83 | if (!strcmp(ea->name, key)) { |
84 | if (ea->indirect) | 84 | if (ea_indirect(ea)) |
85 | goto indirect; | 85 | goto indirect; |
86 | if (ea_valuelen(ea) >= size) | 86 | if (ea_valuelen(ea) >= size) |
87 | return -EINVAL; | 87 | return -EINVAL; |
@@ -91,7 +91,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
91 | } | 91 | } |
92 | a = le32_to_cpu(fnode->ea_secno); | 92 | a = le32_to_cpu(fnode->ea_secno); |
93 | len = le32_to_cpu(fnode->ea_size_l); | 93 | len = le32_to_cpu(fnode->ea_size_l); |
94 | ano = fnode->ea_anode; | 94 | ano = fnode_in_anode(fnode); |
95 | pos = 0; | 95 | pos = 0; |
96 | while (pos < len) { | 96 | while (pos < len) { |
97 | ea = (struct extended_attribute *)ex; | 97 | ea = (struct extended_attribute *)ex; |
@@ -101,10 +101,10 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
101 | return -EIO; | 101 | return -EIO; |
102 | } | 102 | } |
103 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return -EIO; | 103 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return -EIO; |
104 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 104 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
105 | return -EIO; | 105 | return -EIO; |
106 | if (!strcmp(ea->name, key)) { | 106 | if (!strcmp(ea->name, key)) { |
107 | if (ea->indirect) | 107 | if (ea_indirect(ea)) |
108 | goto indirect; | 108 | goto indirect; |
109 | if (ea_valuelen(ea) >= size) | 109 | if (ea_valuelen(ea) >= size) |
110 | return -EINVAL; | 110 | return -EINVAL; |
@@ -119,7 +119,7 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key, | |||
119 | indirect: | 119 | indirect: |
120 | if (ea_len(ea) >= size) | 120 | if (ea_len(ea) >= size) |
121 | return -EINVAL; | 121 | return -EINVAL; |
122 | if (hpfs_ea_read(s, ea_sec(ea), ea->anode, 0, ea_len(ea), buf)) | 122 | if (hpfs_ea_read(s, ea_sec(ea), ea_in_anode(ea), 0, ea_len(ea), buf)) |
123 | return -EIO; | 123 | return -EIO; |
124 | buf[ea_len(ea)] = 0; | 124 | buf[ea_len(ea)] = 0; |
125 | return 0; | 125 | return 0; |
@@ -136,8 +136,8 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
136 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 136 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
137 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 137 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
138 | if (!strcmp(ea->name, key)) { | 138 | if (!strcmp(ea->name, key)) { |
139 | if (ea->indirect) | 139 | if (ea_indirect(ea)) |
140 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 140 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 141 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
142 | printk("HPFS: out of memory for EA\n"); | 142 | printk("HPFS: out of memory for EA\n"); |
143 | return NULL; | 143 | return NULL; |
@@ -148,7 +148,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
148 | } | 148 | } |
149 | a = le32_to_cpu(fnode->ea_secno); | 149 | a = le32_to_cpu(fnode->ea_secno); |
150 | len = le32_to_cpu(fnode->ea_size_l); | 150 | len = le32_to_cpu(fnode->ea_size_l); |
151 | ano = fnode->ea_anode; | 151 | ano = fnode_in_anode(fnode); |
152 | pos = 0; | 152 | pos = 0; |
153 | while (pos < len) { | 153 | while (pos < len) { |
154 | char ex[4 + 255 + 1 + 8]; | 154 | char ex[4 + 255 + 1 + 8]; |
@@ -159,11 +159,11 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si | |||
159 | return NULL; | 159 | return NULL; |
160 | } | 160 | } |
161 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return NULL; | 161 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return NULL; |
162 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 162 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
163 | return NULL; | 163 | return NULL; |
164 | if (!strcmp(ea->name, key)) { | 164 | if (!strcmp(ea->name, key)) { |
165 | if (ea->indirect) | 165 | if (ea_indirect(ea)) |
166 | return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); | 166 | return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); |
167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { | 167 | if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { |
168 | printk("HPFS: out of memory for EA\n"); | 168 | printk("HPFS: out of memory for EA\n"); |
169 | return NULL; | 169 | return NULL; |
@@ -199,9 +199,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
199 | struct extended_attribute *ea_end = fnode_end_ea(fnode); | 199 | struct extended_attribute *ea_end = fnode_end_ea(fnode); |
200 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) | 200 | for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) |
201 | if (!strcmp(ea->name, key)) { | 201 | if (!strcmp(ea->name, key)) { |
202 | if (ea->indirect) { | 202 | if (ea_indirect(ea)) { |
203 | if (ea_len(ea) == size) | 203 | if (ea_len(ea) == size) |
204 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 204 | set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); |
205 | } else if (ea_valuelen(ea) == size) { | 205 | } else if (ea_valuelen(ea) == size) { |
206 | memcpy(ea_data(ea), data, size); | 206 | memcpy(ea_data(ea), data, size); |
207 | } | 207 | } |
@@ -209,7 +209,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
209 | } | 209 | } |
210 | a = le32_to_cpu(fnode->ea_secno); | 210 | a = le32_to_cpu(fnode->ea_secno); |
211 | len = le32_to_cpu(fnode->ea_size_l); | 211 | len = le32_to_cpu(fnode->ea_size_l); |
212 | ano = fnode->ea_anode; | 212 | ano = fnode_in_anode(fnode); |
213 | pos = 0; | 213 | pos = 0; |
214 | while (pos < len) { | 214 | while (pos < len) { |
215 | char ex[4 + 255 + 1 + 8]; | 215 | char ex[4 + 255 + 1 + 8]; |
@@ -220,12 +220,12 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; | 222 | if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; |
223 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) | 223 | if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) |
224 | return; | 224 | return; |
225 | if (!strcmp(ea->name, key)) { | 225 | if (!strcmp(ea->name, key)) { |
226 | if (ea->indirect) { | 226 | if (ea_indirect(ea)) { |
227 | if (ea_len(ea) == size) | 227 | if (ea_len(ea) == size) |
228 | set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); | 228 | set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); |
229 | } | 229 | } |
230 | else { | 230 | else { |
231 | if (ea_valuelen(ea) == size) | 231 | if (ea_valuelen(ea) == size) |
@@ -246,7 +246,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
246 | if (le16_to_cpu(fnode->ea_offs) < 0xc4 || le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200) { | 246 | if (le16_to_cpu(fnode->ea_offs) < 0xc4 || le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200) { |
247 | hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x", | 247 | hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x", |
248 | (unsigned long)inode->i_ino, | 248 | (unsigned long)inode->i_ino, |
249 | le32_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); | 249 | le16_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) && | 252 | if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) && |
@@ -276,7 +276,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
276 | fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); | 276 | fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); |
277 | fnode->ea_size_s = cpu_to_le16(0); | 277 | fnode->ea_size_s = cpu_to_le16(0); |
278 | fnode->ea_secno = cpu_to_le32(n); | 278 | fnode->ea_secno = cpu_to_le32(n); |
279 | fnode->ea_anode = cpu_to_le32(0); | 279 | fnode->flags &= ~FNODE_anode; |
280 | mark_buffer_dirty(bh); | 280 | mark_buffer_dirty(bh); |
281 | brelse(bh); | 281 | brelse(bh); |
282 | } | 282 | } |
@@ -288,9 +288,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
288 | secno q = hpfs_alloc_sector(s, fno, 1, 0); | 288 | secno q = hpfs_alloc_sector(s, fno, 1, 0); |
289 | if (!q) goto bail; | 289 | if (!q) goto bail; |
290 | fnode->ea_secno = cpu_to_le32(q); | 290 | fnode->ea_secno = cpu_to_le32(q); |
291 | fnode->ea_anode = 0; | 291 | fnode->flags &= ~FNODE_anode; |
292 | len++; | 292 | len++; |
293 | } else if (!fnode->ea_anode) { | 293 | } else if (!fnode_in_anode(fnode)) { |
294 | if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { | 294 | if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { |
295 | len++; | 295 | len++; |
296 | } else { | 296 | } else { |
@@ -310,7 +310,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
310 | anode->u.external[0].length = cpu_to_le32(len); | 310 | anode->u.external[0].length = cpu_to_le32(len); |
311 | mark_buffer_dirty(bh); | 311 | mark_buffer_dirty(bh); |
312 | brelse(bh); | 312 | brelse(bh); |
313 | fnode->ea_anode = 1; | 313 | fnode->flags |= FNODE_anode; |
314 | fnode->ea_secno = cpu_to_le32(a_s);*/ | 314 | fnode->ea_secno = cpu_to_le32(a_s);*/ |
315 | secno new_sec; | 315 | secno new_sec; |
316 | int i; | 316 | int i; |
@@ -338,7 +338,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
338 | len = (pos + 511) >> 9; | 338 | len = (pos + 511) >> 9; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | if (fnode->ea_anode) { | 341 | if (fnode_in_anode(fnode)) { |
342 | if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), | 342 | if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), |
343 | 0, len) != -1) { | 343 | 0, len) != -1) { |
344 | len++; | 344 | len++; |
@@ -351,16 +351,16 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
351 | h[1] = strlen(key); | 351 | h[1] = strlen(key); |
352 | h[2] = size & 0xff; | 352 | h[2] = size & 0xff; |
353 | h[3] = size >> 8; | 353 | h[3] = size >> 8; |
354 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; | 354 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; |
355 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; | 355 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; |
356 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; | 356 | if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; |
357 | fnode->ea_size_l = cpu_to_le32(pos); | 357 | fnode->ea_size_l = cpu_to_le32(pos); |
358 | ret: | 358 | ret: |
359 | hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; | 359 | hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; |
360 | return; | 360 | return; |
361 | bail: | 361 | bail: |
362 | if (le32_to_cpu(fnode->ea_secno)) | 362 | if (le32_to_cpu(fnode->ea_secno)) |
363 | if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); | 363 | if (fnode_in_anode(fnode)) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); |
364 | else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); | 364 | else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); |
365 | else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); | 365 | else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); |
366 | } | 366 | } |
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 | ||
76 | struct hpfs_super_block | 76 | struct 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 | ||
110 | struct hpfs_spare_block | 110 | struct 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 | ||
203 | struct code_page_directory | 203 | struct 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 | ||
225 | struct code_page_data | 225 | struct 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 | ||
280 | struct dnode { | 280 | struct 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 | ||
302 | struct hpfs_dirent { | 302 | struct 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 | ||
376 | struct bplus_leaf_node | 376 | struct 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 | ||
383 | struct bplus_internal_node | 383 | struct 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 | ||
389 | enum { | ||
390 | BP_hbff = 1, | ||
391 | BP_fnode_parent = 0x20, | ||
392 | BP_binary_search = 0x40, | ||
393 | BP_internal = 0x80 | ||
394 | }; | ||
389 | struct bplus_header | 395 | struct 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 | ||
417 | static inline bool bp_internal(struct bplus_header *bp) | ||
418 | { | ||
419 | return bp->flags & BP_internal; | ||
420 | } | ||
421 | |||
422 | static 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 | ||
435 | enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)}; | ||
439 | struct fnode | 436 | struct 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 | ||
475 | static inline bool fnode_in_anode(struct fnode *p) | ||
476 | { | ||
477 | return (p->flags & FNODE_anode) != 0; | ||
478 | } | ||
479 | |||
480 | static 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 | ||
500 | struct anode | 490 | struct 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 | ||
521 | enum {EA_indirect = 1, EA_anode = 2, EA_needea = 128 }; | ||
531 | struct extended_attribute | 522 | struct 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 | ||
545 | static inline bool ea_indirect(struct extended_attribute *ea) | ||
546 | { | ||
547 | return ea->flags & EA_indirect; | ||
548 | } | ||
549 | |||
550 | static 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 |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 6d2d5008fa43..c07ef1f1ced6 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -75,7 +75,7 @@ struct hpfs_sb_info { | |||
75 | unsigned char *sb_cp_table; /* code page tables: */ | 75 | unsigned char *sb_cp_table; /* code page tables: */ |
76 | /* 128 bytes uppercasing table & */ | 76 | /* 128 bytes uppercasing table & */ |
77 | /* 128 bytes lowercasing table */ | 77 | /* 128 bytes lowercasing table */ |
78 | unsigned *sb_bmp_dir; /* main bitmap directory */ | 78 | __le32 *sb_bmp_dir; /* main bitmap directory */ |
79 | unsigned sb_c_bitmap; /* current bitmap */ | 79 | unsigned sb_c_bitmap; /* current bitmap */ |
80 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ | 80 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ |
81 | int sb_timeshift; | 81 | int sb_timeshift; |
@@ -93,7 +93,7 @@ struct quad_buffer_head { | |||
93 | static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) | 93 | static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) |
94 | { | 94 | { |
95 | CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); | 95 | CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); |
96 | return le32_to_cpu(*(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4)); | 96 | return le32_to_cpu(*(__le32 *) ((void *) de + le16_to_cpu(de->length) - 4)); |
97 | } | 97 | } |
98 | 98 | ||
99 | /* The first dir entry in a dnode */ | 99 | /* The first dir entry in a dnode */ |
@@ -141,12 +141,12 @@ static inline struct extended_attribute *next_ea(struct extended_attribute *ea) | |||
141 | 141 | ||
142 | static inline secno ea_sec(struct extended_attribute *ea) | 142 | static inline secno ea_sec(struct extended_attribute *ea) |
143 | { | 143 | { |
144 | return le32_to_cpu(get_unaligned((secno *)((char *)ea + 9 + ea->namelen))); | 144 | return le32_to_cpu(get_unaligned((__le32 *)((char *)ea + 9 + ea->namelen))); |
145 | } | 145 | } |
146 | 146 | ||
147 | static inline secno ea_len(struct extended_attribute *ea) | 147 | static inline secno ea_len(struct extended_attribute *ea) |
148 | { | 148 | { |
149 | return le32_to_cpu(get_unaligned((secno *)((char *)ea + 5 + ea->namelen))); | 149 | return le32_to_cpu(get_unaligned((__le32 *)((char *)ea + 5 + ea->namelen))); |
150 | } | 150 | } |
151 | 151 | ||
152 | static inline char *ea_data(struct extended_attribute *ea) | 152 | static inline char *ea_data(struct extended_attribute *ea) |
@@ -171,7 +171,7 @@ static inline void copy_de(struct hpfs_dirent *dst, struct hpfs_dirent *src) | |||
171 | dst->not_8x3 = n; | 171 | dst->not_8x3 = n; |
172 | } | 172 | } |
173 | 173 | ||
174 | static inline unsigned tstbits(u32 *bmp, unsigned b, unsigned n) | 174 | static inline unsigned tstbits(__le32 *bmp, unsigned b, unsigned n) |
175 | { | 175 | { |
176 | int i; | 176 | int i; |
177 | if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; | 177 | if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; |
@@ -268,10 +268,10 @@ void hpfs_evict_inode(struct inode *); | |||
268 | 268 | ||
269 | /* map.c */ | 269 | /* map.c */ |
270 | 270 | ||
271 | unsigned *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); | 271 | __le32 *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); |
272 | unsigned *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); | 272 | __le32 *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); |
273 | unsigned char *hpfs_load_code_page(struct super_block *, secno); | 273 | unsigned char *hpfs_load_code_page(struct super_block *, secno); |
274 | secno *hpfs_load_bitmap_directory(struct super_block *, secno bmp); | 274 | __le32 *hpfs_load_bitmap_directory(struct super_block *, secno bmp); |
275 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); | 275 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); |
276 | struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); | 276 | struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); |
277 | struct dnode *hpfs_map_dnode(struct super_block *s, dnode_secno, struct quad_buffer_head *); | 277 | struct dnode *hpfs_map_dnode(struct super_block *s, dnode_secno, struct quad_buffer_head *); |
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index b43066cbdc6a..ed671e0ea784 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -110,7 +110,7 @@ void hpfs_read_inode(struct inode *i) | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | if (fnode->dirflag) { | 113 | if (fnode_is_dir(fnode)) { |
114 | int n_dnodes, n_subdirs; | 114 | int n_dnodes, n_subdirs; |
115 | i->i_mode |= S_IFDIR; | 115 | i->i_mode |= S_IFDIR; |
116 | i->i_op = &hpfs_dir_iops; | 116 | i->i_op = &hpfs_dir_iops; |
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index a790821366a7..4acb19d78359 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
@@ -8,12 +8,12 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | unsigned *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) | 11 | __le32 *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) |
12 | { | 12 | { |
13 | return hpfs_map_4sectors(s, hpfs_sb(s)->sb_dmap, qbh, 0); | 13 | return hpfs_map_4sectors(s, hpfs_sb(s)->sb_dmap, qbh, 0); |
14 | } | 14 | } |
15 | 15 | ||
16 | unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, | 16 | __le32 *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, |
17 | struct quad_buffer_head *qbh, char *id) | 17 | struct quad_buffer_head *qbh, char *id) |
18 | { | 18 | { |
19 | secno sec; | 19 | secno sec; |
@@ -89,18 +89,18 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps) | |||
89 | return cp_table; | 89 | return cp_table; |
90 | } | 90 | } |
91 | 91 | ||
92 | secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) | 92 | __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) |
93 | { | 93 | { |
94 | struct buffer_head *bh; | 94 | struct buffer_head *bh; |
95 | int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; | 95 | int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; |
96 | int i; | 96 | int i; |
97 | secno *b; | 97 | __le32 *b; |
98 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { | 98 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { |
99 | printk("HPFS: can't allocate memory for bitmap directory\n"); | 99 | printk("HPFS: can't allocate memory for bitmap directory\n"); |
100 | return NULL; | 100 | return NULL; |
101 | } | 101 | } |
102 | for (i=0;i<n;i++) { | 102 | for (i=0;i<n;i++) { |
103 | secno *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); | 103 | __le32 *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); |
104 | if (!d) { | 104 | if (!d) { |
105 | kfree(b); | 105 | kfree(b); |
106 | return NULL; | 106 | return NULL; |
@@ -130,16 +130,16 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea | |||
130 | (unsigned long)ino); | 130 | (unsigned long)ino); |
131 | goto bail; | 131 | goto bail; |
132 | } | 132 | } |
133 | if (!fnode->dirflag) { | 133 | if (!fnode_is_dir(fnode)) { |
134 | if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != | 134 | if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != |
135 | (fnode->btree.internal ? 12 : 8)) { | 135 | (bp_internal(&fnode->btree) ? 12 : 8)) { |
136 | hpfs_error(s, | 136 | hpfs_error(s, |
137 | "bad number of nodes in fnode %08lx", | 137 | "bad number of nodes in fnode %08lx", |
138 | (unsigned long)ino); | 138 | (unsigned long)ino); |
139 | goto bail; | 139 | goto bail; |
140 | } | 140 | } |
141 | if (le16_to_cpu(fnode->btree.first_free) != | 141 | if (le16_to_cpu(fnode->btree.first_free) != |
142 | 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { | 142 | 8 + fnode->btree.n_used_nodes * (bp_internal(&fnode->btree) ? 8 : 12)) { |
143 | hpfs_error(s, | 143 | hpfs_error(s, |
144 | "bad first_free pointer in fnode %08lx", | 144 | "bad first_free pointer in fnode %08lx", |
145 | (unsigned long)ino); | 145 | (unsigned long)ino); |
@@ -187,12 +187,12 @@ struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buff | |||
187 | goto bail; | 187 | goto bail; |
188 | } | 188 | } |
189 | if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != | 189 | if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != |
190 | (anode->btree.internal ? 60 : 40)) { | 190 | (bp_internal(&anode->btree) ? 60 : 40)) { |
191 | hpfs_error(s, "bad number of nodes in anode %08x", ano); | 191 | hpfs_error(s, "bad number of nodes in anode %08x", ano); |
192 | goto bail; | 192 | goto bail; |
193 | } | 193 | } |
194 | if (le16_to_cpu(anode->btree.first_free) != | 194 | if (le16_to_cpu(anode->btree.first_free) != |
195 | 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) { | 195 | 8 + anode->btree.n_used_nodes * (bp_internal(&anode->btree) ? 8 : 12)) { |
196 | hpfs_error(s, "bad first_free pointer in anode %08x", ano); | 196 | hpfs_error(s, "bad first_free pointer in anode %08x", ano); |
197 | goto bail; | 197 | goto bail; |
198 | } | 198 | } |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index 30dd7b10b507..9083ef8af58c 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -70,7 +70,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
70 | fnode->len = len; | 70 | fnode->len = len; |
71 | memcpy(fnode->name, name, len > 15 ? 15 : len); | 71 | memcpy(fnode->name, name, len > 15 ? 15 : len); |
72 | fnode->up = cpu_to_le32(dir->i_ino); | 72 | fnode->up = cpu_to_le32(dir->i_ino); |
73 | fnode->dirflag = 1; | 73 | fnode->flags |= FNODE_dir; |
74 | fnode->btree.n_free_nodes = 7; | 74 | fnode->btree.n_free_nodes = 7; |
75 | fnode->btree.n_used_nodes = 1; | 75 | fnode->btree.n_used_nodes = 1; |
76 | fnode->btree.first_free = cpu_to_le16(0x14); | 76 | fnode->btree.first_free = cpu_to_le16(0x14); |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 54f6eccb79d9..706a12c083ea 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -572,7 +572,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
572 | mark_buffer_dirty(bh2); | 572 | mark_buffer_dirty(bh2); |
573 | } | 573 | } |
574 | 574 | ||
575 | if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) { | 575 | if (spareblock->hotfixes_used || spareblock->n_spares_used) { |
576 | if (errs >= 2) { | 576 | if (errs >= 2) { |
577 | printk("HPFS: Hotfixes not supported here, try chkdsk\n"); | 577 | printk("HPFS: Hotfixes not supported here, try chkdsk\n"); |
578 | mark_dirty(s, 0); | 578 | mark_dirty(s, 0); |
@@ -645,7 +645,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
645 | root->i_mtime.tv_nsec = 0; | 645 | root->i_mtime.tv_nsec = 0; |
646 | root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date)); | 646 | root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date)); |
647 | root->i_ctime.tv_nsec = 0; | 647 | root->i_ctime.tv_nsec = 0; |
648 | hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size); | 648 | hpfs_i(root)->i_ea_size = le32_to_cpu(de->ea_size); |
649 | hpfs_i(root)->i_parent_dir = root->i_ino; | 649 | hpfs_i(root)->i_parent_dir = root->i_ino; |
650 | if (root->i_size == -1) | 650 | if (root->i_size == -1) |
651 | root->i_size = 2048; | 651 | root->i_size = 2048; |