aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs
diff options
context:
space:
mode:
authorMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>2011-05-08 14:44:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-09 12:04:24 -0400
commit0b69760be6968c528869d4aec95ecf64dbf3e8bd (patch)
treeebc1f353c7df72bfe28b9da64af810c20ca8cdd4 /fs/hpfs
parentbc8728ee56bca62df269b2dd159bc60838ac8e80 (diff)
HPFS: Fix endianity. Make hpfs work on big-endian machines
Fix endianity. Make hpfs work on big-endian machines. Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hpfs')
-rw-r--r--fs/hpfs/alloc.c68
-rw-r--r--fs/hpfs/anode.c136
-rw-r--r--fs/hpfs/dir.c20
-rw-r--r--fs/hpfs/dnode.c127
-rw-r--r--fs/hpfs/ea.c129
-rw-r--r--fs/hpfs/hpfs.h219
-rw-r--r--fs/hpfs/hpfs_fn.h27
-rw-r--r--fs/hpfs/inode.c34
-rw-r--r--fs/hpfs/map.c56
-rw-r--r--fs/hpfs/namei.c50
-rw-r--r--fs/hpfs/super.c50
11 files changed, 498 insertions, 418 deletions
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c
index 995472de92a0..7a5eb2c718c8 100644
--- a/fs/hpfs/alloc.c
+++ b/fs/hpfs/alloc.c
@@ -16,9 +16,9 @@
16static int chk_if_allocated(struct super_block *s, secno sec, char *msg) 16static 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 unsigned *bmp; 19 u32 *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 ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f)) & 1) { 21 if ((cpu_to_le32(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 }
@@ -26,7 +26,7 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg)
26 if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { 26 if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
27 unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; 27 unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4;
28 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; 28 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail;
29 if ((bmp[ssec >> 5] >> (ssec & 0x1f)) & 1) { 29 if ((le32_to_cpu(bmp[ssec >> 5]) >> (ssec & 0x1f)) & 1) {
30 hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); 30 hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec);
31 goto fail1; 31 goto fail1;
32 } 32 }
@@ -82,10 +82,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne
82 ret = bs + nr; 82 ret = bs + nr;
83 goto rt; 83 goto rt;
84 } 84 }
85 /*if (!tstbits(bmp, nr + n, n + forward)) {
86 ret = bs + nr + n;
87 goto rt;
88 }*/
89 q = nr + n; b = 0; 85 q = nr + n; b = 0;
90 while ((a = tstbits(bmp, q, n + forward)) != 0) { 86 while ((a = tstbits(bmp, q, n + forward)) != 0) {
91 q += a; 87 q += a;
@@ -102,14 +98,14 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne
102 goto rt; 98 goto rt;
103 } 99 }
104 nr >>= 5; 100 nr >>= 5;
105 /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) {*/ 101 /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) */
106 i = nr; 102 i = nr;
107 do { 103 do {
108 if (!bmp[i]) goto cont; 104 if (!le32_to_cpu(bmp[i])) goto cont;
109 if (n + forward >= 0x3f && bmp[i] != -1) goto cont; 105 if (n + forward >= 0x3f && le32_to_cpu(bmp[i]) != 0xffffffff) goto cont;
110 q = i<<5; 106 q = i<<5;
111 if (i > 0) { 107 if (i > 0) {
112 unsigned k = bmp[i-1]; 108 unsigned k = le32_to_cpu(bmp[i-1]);
113 while (k & 0x80000000) { 109 while (k & 0x80000000) {
114 q--; k <<= 1; 110 q--; k <<= 1;
115 } 111 }
@@ -129,12 +125,12 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne
129 } while (i != nr); 125 } while (i != nr);
130 rt: 126 rt:
131 if (ret) { 127 if (ret) {
132 if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (bmp[(ret & 0x3fff) >> 5] | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) { 128 if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (le32_to_cpu(bmp[(ret & 0x3fff) >> 5]) | ~(((1 << n) - 1) << (ret & 0x1f))) != 0xffffffff)) {
133 hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); 129 hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret);
134 ret = 0; 130 ret = 0;
135 goto b; 131 goto b;
136 } 132 }
137 bmp[(ret & 0x3fff) >> 5] &= ~(((1 << n) - 1) << (ret & 0x1f)); 133 bmp[(ret & 0x3fff) >> 5] &= cpu_to_le32(~(((1 << n) - 1) << (ret & 0x1f)));
138 hpfs_mark_4buffers_dirty(&qbh); 134 hpfs_mark_4buffers_dirty(&qbh);
139 } 135 }
140 b: 136 b:
@@ -240,10 +236,10 @@ static secno alloc_in_dirband(struct super_block *s, secno near)
240int hpfs_alloc_if_possible(struct super_block *s, secno sec) 236int hpfs_alloc_if_possible(struct super_block *s, secno sec)
241{ 237{
242 struct quad_buffer_head qbh; 238 struct quad_buffer_head qbh;
243 unsigned *bmp; 239 u32 *bmp;
244 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;
245 if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { 241 if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) {
246 bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); 242 bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f)));
247 hpfs_mark_4buffers_dirty(&qbh); 243 hpfs_mark_4buffers_dirty(&qbh);
248 hpfs_brelse4(&qbh); 244 hpfs_brelse4(&qbh);
249 return 1; 245 return 1;
@@ -258,7 +254,7 @@ int hpfs_alloc_if_possible(struct super_block *s, secno sec)
258void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) 254void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n)
259{ 255{
260 struct quad_buffer_head qbh; 256 struct quad_buffer_head qbh;
261 unsigned *bmp; 257 u32 *bmp;
262 struct hpfs_sb_info *sbi = hpfs_sb(s); 258 struct hpfs_sb_info *sbi = hpfs_sb(s);
263 /*printk("2 - ");*/ 259 /*printk("2 - ");*/
264 if (!n) return; 260 if (!n) return;
@@ -273,12 +269,12 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n)
273 return; 269 return;
274 } 270 }
275 new_tst: 271 new_tst:
276 if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { 272 if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f) & 1)) {
277 hpfs_error(s, "sector %08x not allocated", sec); 273 hpfs_error(s, "sector %08x not allocated", sec);
278 hpfs_brelse4(&qbh); 274 hpfs_brelse4(&qbh);
279 return; 275 return;
280 } 276 }
281 bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); 277 bmp[(sec & 0x3fff) >> 5] |= cpu_to_le32(1 << (sec & 0x1f));
282 if (!--n) { 278 if (!--n) {
283 hpfs_mark_4buffers_dirty(&qbh); 279 hpfs_mark_4buffers_dirty(&qbh);
284 hpfs_brelse4(&qbh); 280 hpfs_brelse4(&qbh);
@@ -303,13 +299,13 @@ int hpfs_check_free_dnodes(struct super_block *s, int n)
303 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;
304 int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; 300 int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff;
305 int i, j; 301 int i, j;
306 unsigned *bmp; 302 u32 *bmp;
307 struct quad_buffer_head qbh; 303 struct quad_buffer_head qbh;
308 if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 304 if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) {
309 for (j = 0; j < 512; j++) { 305 for (j = 0; j < 512; j++) {
310 unsigned k; 306 unsigned k;
311 if (!bmp[j]) continue; 307 if (!le32_to_cpu(bmp[j])) continue;
312 for (k = bmp[j]; k; k >>= 1) if (k & 1) if (!--n) { 308 for (k = le32_to_cpu(bmp[j]); k; k >>= 1) if (k & 1) if (!--n) {
313 hpfs_brelse4(&qbh); 309 hpfs_brelse4(&qbh);
314 return 0; 310 return 0;
315 } 311 }
@@ -328,10 +324,10 @@ int hpfs_check_free_dnodes(struct super_block *s, int n)
328 chk_bmp: 324 chk_bmp:
329 if (bmp) { 325 if (bmp) {
330 for (j = 0; j < 512; j++) { 326 for (j = 0; j < 512; j++) {
331 unsigned k; 327 u32 k;
332 if (!bmp[j]) continue; 328 if (!le32_to_cpu(bmp[j])) continue;
333 for (k = 0xf; k; k <<= 4) 329 for (k = 0xf; k; k <<= 4)
334 if ((bmp[j] & k) == k) { 330 if ((le32_to_cpu(bmp[j]) & k) == k) {
335 if (!--n) { 331 if (!--n) {
336 hpfs_brelse4(&qbh); 332 hpfs_brelse4(&qbh);
337 return 0; 333 return 0;
@@ -355,12 +351,12 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno)
355 hpfs_free_sectors(s, dno, 4); 351 hpfs_free_sectors(s, dno, 4);
356 } else { 352 } else {
357 struct quad_buffer_head qbh; 353 struct quad_buffer_head qbh;
358 unsigned *bmp; 354 u32 *bmp;
359 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; 355 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4;
360 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 356 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) {
361 return; 357 return;
362 } 358 }
363 bmp[ssec >> 5] |= 1 << (ssec & 0x1f); 359 bmp[ssec >> 5] |= cpu_to_le32(1 << (ssec & 0x1f));
364 hpfs_mark_4buffers_dirty(&qbh); 360 hpfs_mark_4buffers_dirty(&qbh);
365 hpfs_brelse4(&qbh); 361 hpfs_brelse4(&qbh);
366 } 362 }
@@ -382,13 +378,13 @@ struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near,
382 return NULL; 378 return NULL;
383 } 379 }
384 memset(d, 0, 2048); 380 memset(d, 0, 2048);
385 d->magic = DNODE_MAGIC; 381 d->magic = cpu_to_le32(DNODE_MAGIC);
386 d->first_free = 52; 382 d->first_free = cpu_to_le32(52);
387 d->dirent[0] = 32; 383 d->dirent[0] = 32;
388 d->dirent[2] = 8; 384 d->dirent[2] = 8;
389 d->dirent[30] = 1; 385 d->dirent[30] = 1;
390 d->dirent[31] = 255; 386 d->dirent[31] = 255;
391 d->self = *dno; 387 d->self = cpu_to_le32(*dno);
392 return d; 388 return d;
393} 389}
394 390
@@ -402,10 +398,10 @@ struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *f
402 return NULL; 398 return NULL;
403 } 399 }
404 memset(f, 0, 512); 400 memset(f, 0, 512);
405 f->magic = FNODE_MAGIC; 401 f->magic = cpu_to_le32(FNODE_MAGIC);
406 f->ea_offs = 0xc4; 402 f->ea_offs = cpu_to_le16(0xc4);
407 f->btree.n_free_nodes = 8; 403 f->btree.n_free_nodes = 8;
408 f->btree.first_free = 8; 404 f->btree.first_free = cpu_to_le16(8);
409 return f; 405 return f;
410} 406}
411 407
@@ -419,10 +415,10 @@ struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *a
419 return NULL; 415 return NULL;
420 } 416 }
421 memset(a, 0, 512); 417 memset(a, 0, 512);
422 a->magic = ANODE_MAGIC; 418 a->magic = cpu_to_le32(ANODE_MAGIC);
423 a->self = *ano; 419 a->self = cpu_to_le32(*ano);
424 a->btree.n_free_nodes = 40; 420 a->btree.n_free_nodes = 40;
425 a->btree.n_used_nodes = 0; 421 a->btree.n_used_nodes = 0;
426 a->btree.first_free = 8; 422 a->btree.first_free = cpu_to_le16(8);
427 return a; 423 return a;
428} 424}
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c
index f2a038411e3c..08b503e8ed29 100644
--- a/fs/hpfs/anode.c
+++ b/fs/hpfs/anode.c
@@ -22,8 +22,8 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
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 (btree->internal) {
24 for (i = 0; i < btree->n_used_nodes; i++) 24 for (i = 0; i < btree->n_used_nodes; i++)
25 if (btree->u.internal[i].file_secno > sec) { 25 if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) {
26 a = btree->u.internal[i].down; 26 a = le32_to_cpu(btree->u.internal[i].down);
27 brelse(bh); 27 brelse(bh);
28 if (!(anode = hpfs_map_anode(s, a, &bh))) return -1; 28 if (!(anode = hpfs_map_anode(s, a, &bh))) return -1;
29 btree = &anode->btree; 29 btree = &anode->btree;
@@ -34,18 +34,18 @@ secno hpfs_bplus_lookup(struct super_block *s, struct inode *inode,
34 return -1; 34 return -1;
35 } 35 }
36 for (i = 0; i < btree->n_used_nodes; i++) 36 for (i = 0; i < btree->n_used_nodes; i++)
37 if (btree->u.external[i].file_secno <= sec && 37 if (le32_to_cpu(btree->u.external[i].file_secno) <= sec &&
38 btree->u.external[i].file_secno + btree->u.external[i].length > sec) { 38 le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) > sec) {
39 a = btree->u.external[i].disk_secno + sec - btree->u.external[i].file_secno; 39 a = le32_to_cpu(btree->u.external[i].disk_secno) + sec - le32_to_cpu(btree->u.external[i].file_secno);
40 if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, a, 1, "data")) { 40 if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, a, 1, "data")) {
41 brelse(bh); 41 brelse(bh);
42 return -1; 42 return -1;
43 } 43 }
44 if (inode) { 44 if (inode) {
45 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); 45 struct hpfs_inode_info *hpfs_inode = hpfs_i(inode);
46 hpfs_inode->i_file_sec = btree->u.external[i].file_secno; 46 hpfs_inode->i_file_sec = le32_to_cpu(btree->u.external[i].file_secno);
47 hpfs_inode->i_disk_sec = btree->u.external[i].disk_secno; 47 hpfs_inode->i_disk_sec = le32_to_cpu(btree->u.external[i].disk_secno);
48 hpfs_inode->i_n_secs = btree->u.external[i].length; 48 hpfs_inode->i_n_secs = le32_to_cpu(btree->u.external[i].length);
49 } 49 }
50 brelse(bh); 50 brelse(bh);
51 return a; 51 return a;
@@ -83,8 +83,8 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
83 return -1; 83 return -1;
84 } 84 }
85 if (btree->internal) { 85 if (btree->internal) {
86 a = btree->u.internal[n].down; 86 a = le32_to_cpu(btree->u.internal[n].down);
87 btree->u.internal[n].file_secno = -1; 87 btree->u.internal[n].file_secno = cpu_to_le32(-1);
88 mark_buffer_dirty(bh); 88 mark_buffer_dirty(bh);
89 brelse(bh); 89 brelse(bh);
90 if (hpfs_sb(s)->sb_chk) 90 if (hpfs_sb(s)->sb_chk)
@@ -94,15 +94,15 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
94 goto go_down; 94 goto go_down;
95 } 95 }
96 if (n >= 0) { 96 if (n >= 0) {
97 if (btree->u.external[n].file_secno + btree->u.external[n].length != fsecno) { 97 if (le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length) != fsecno) {
98 hpfs_error(s, "allocated size %08x, trying to add sector %08x, %cnode %08x", 98 hpfs_error(s, "allocated size %08x, trying to add sector %08x, %cnode %08x",
99 btree->u.external[n].file_secno + btree->u.external[n].length, fsecno, 99 le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length), fsecno,
100 fnod?'f':'a', node); 100 fnod?'f':'a', node);
101 brelse(bh); 101 brelse(bh);
102 return -1; 102 return -1;
103 } 103 }
104 if (hpfs_alloc_if_possible(s, se = btree->u.external[n].disk_secno + btree->u.external[n].length)) { 104 if (hpfs_alloc_if_possible(s, se = le32_to_cpu(btree->u.external[n].disk_secno) + le32_to_cpu(btree->u.external[n].length))) {
105 btree->u.external[n].length++; 105 btree->u.external[n].length = cpu_to_le32(le32_to_cpu(btree->u.external[n].length) + 1);
106 mark_buffer_dirty(bh); 106 mark_buffer_dirty(bh);
107 brelse(bh); 107 brelse(bh);
108 return se; 108 return se;
@@ -119,16 +119,16 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
119 brelse(bh); 119 brelse(bh);
120 return -1; 120 return -1;
121 } 121 }
122 fs = n < 0 ? 0 : btree->u.external[n].file_secno + btree->u.external[n].length; 122 fs = n < 0 ? 0 : le32_to_cpu(btree->u.external[n].file_secno) + le32_to_cpu(btree->u.external[n].length);
123 if (!btree->n_free_nodes) { 123 if (!btree->n_free_nodes) {
124 up = a != node ? anode->up : -1; 124 up = a != node ? le32_to_cpu(anode->up) : -1;
125 if (!(anode = hpfs_alloc_anode(s, a, &na, &bh1))) { 125 if (!(anode = hpfs_alloc_anode(s, a, &na, &bh1))) {
126 brelse(bh); 126 brelse(bh);
127 hpfs_free_sectors(s, se, 1); 127 hpfs_free_sectors(s, se, 1);
128 return -1; 128 return -1;
129 } 129 }
130 if (a == node && fnod) { 130 if (a == node && fnod) {
131 anode->up = node; 131 anode->up = cpu_to_le32(node);
132 anode->btree.fnode_parent = 1; 132 anode->btree.fnode_parent = 1;
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;
@@ -137,9 +137,9 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
137 btree->internal = 1; 137 btree->internal = 1;
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 = (char *)&(btree->u.internal[1]) - (char *)btree; 140 btree->first_free = cpu_to_le16((char *)&(btree->u.internal[1]) - (char *)btree);
141 btree->u.internal[0].file_secno = -1; 141 btree->u.internal[0].file_secno = cpu_to_le32(-1);
142 btree->u.internal[0].down = na; 142 btree->u.internal[0].down = cpu_to_le32(na);
143 mark_buffer_dirty(bh); 143 mark_buffer_dirty(bh);
144 } else if (!(ranode = hpfs_alloc_anode(s, /*a*/0, &ra, &bh2))) { 144 } else if (!(ranode = hpfs_alloc_anode(s, /*a*/0, &ra, &bh2))) {
145 brelse(bh); 145 brelse(bh);
@@ -153,15 +153,15 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
153 btree = &anode->btree; 153 btree = &anode->btree;
154 } 154 }
155 btree->n_free_nodes--; n = btree->n_used_nodes++; 155 btree->n_free_nodes--; n = btree->n_used_nodes++;
156 btree->first_free += 12; 156 btree->first_free = cpu_to_le16(le16_to_cpu(btree->first_free) + 12);
157 btree->u.external[n].disk_secno = se; 157 btree->u.external[n].disk_secno = cpu_to_le32(se);
158 btree->u.external[n].file_secno = fs; 158 btree->u.external[n].file_secno = cpu_to_le32(fs);
159 btree->u.external[n].length = 1; 159 btree->u.external[n].length = cpu_to_le32(1);
160 mark_buffer_dirty(bh); 160 mark_buffer_dirty(bh);
161 brelse(bh); 161 brelse(bh);
162 if ((a == node && fnod) || na == -1) return se; 162 if ((a == node && fnod) || na == -1) return se;
163 c2 = 0; 163 c2 = 0;
164 while (up != -1) { 164 while (up != (anode_secno)-1) {
165 struct anode *new_anode; 165 struct anode *new_anode;
166 if (hpfs_sb(s)->sb_chk) 166 if (hpfs_sb(s)->sb_chk)
167 if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1; 167 if (hpfs_stop_cycles(s, up, &c1, &c2, "hpfs_add_sector_to_btree #2")) return -1;
@@ -174,47 +174,47 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
174 } 174 }
175 if (btree->n_free_nodes) { 175 if (btree->n_free_nodes) {
176 btree->n_free_nodes--; n = btree->n_used_nodes++; 176 btree->n_free_nodes--; n = btree->n_used_nodes++;
177 btree->first_free += 8; 177 btree->first_free = cpu_to_le16(le16_to_cpu(btree->first_free) + 8);
178 btree->u.internal[n].file_secno = -1; 178 btree->u.internal[n].file_secno = cpu_to_le32(-1);
179 btree->u.internal[n].down = na; 179 btree->u.internal[n].down = cpu_to_le32(na);
180 btree->u.internal[n-1].file_secno = fs; 180 btree->u.internal[n-1].file_secno = cpu_to_le32(fs);
181 mark_buffer_dirty(bh); 181 mark_buffer_dirty(bh);
182 brelse(bh); 182 brelse(bh);
183 brelse(bh2); 183 brelse(bh2);
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 = up; 186 anode->up = cpu_to_le32(up);
187 anode->btree.fnode_parent = up == node && fnod; 187 anode->btree.fnode_parent = up == node && fnod;
188 mark_buffer_dirty(bh); 188 mark_buffer_dirty(bh);
189 brelse(bh); 189 brelse(bh);
190 } 190 }
191 return se; 191 return se;
192 } 192 }
193 up = up != node ? anode->up : -1; 193 up = up != node ? le32_to_cpu(anode->up) : -1;
194 btree->u.internal[btree->n_used_nodes - 1].file_secno = /*fs*/-1; 194 btree->u.internal[btree->n_used_nodes - 1].file_secno = cpu_to_le32(/*fs*/-1);
195 mark_buffer_dirty(bh); 195 mark_buffer_dirty(bh);
196 brelse(bh); 196 brelse(bh);
197 a = na; 197 a = na;
198 if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { 198 if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) {
199 anode = new_anode; 199 anode = new_anode;
200 /*anode->up = up != -1 ? up : ra;*/ 200 /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/
201 anode->btree.internal = 1; 201 anode->btree.internal = 1;
202 anode->btree.n_used_nodes = 1; 202 anode->btree.n_used_nodes = 1;
203 anode->btree.n_free_nodes = 59; 203 anode->btree.n_free_nodes = 59;
204 anode->btree.first_free = 16; 204 anode->btree.first_free = cpu_to_le16(16);
205 anode->btree.u.internal[0].down = a; 205 anode->btree.u.internal[0].down = cpu_to_le32(a);
206 anode->btree.u.internal[0].file_secno = -1; 206 anode->btree.u.internal[0].file_secno = cpu_to_le32(-1);
207 mark_buffer_dirty(bh); 207 mark_buffer_dirty(bh);
208 brelse(bh); 208 brelse(bh);
209 if ((anode = hpfs_map_anode(s, a, &bh))) { 209 if ((anode = hpfs_map_anode(s, a, &bh))) {
210 anode->up = na; 210 anode->up = cpu_to_le32(na);
211 mark_buffer_dirty(bh); 211 mark_buffer_dirty(bh);
212 brelse(bh); 212 brelse(bh);
213 } 213 }
214 } else na = a; 214 } else na = a;
215 } 215 }
216 if ((anode = hpfs_map_anode(s, na, &bh))) { 216 if ((anode = hpfs_map_anode(s, na, &bh))) {
217 anode->up = node; 217 anode->up = cpu_to_le32(node);
218 if (fnod) anode->btree.fnode_parent = 1; 218 if (fnod) anode->btree.fnode_parent = 1;
219 mark_buffer_dirty(bh); 219 mark_buffer_dirty(bh);
220 brelse(bh); 220 brelse(bh);
@@ -232,14 +232,14 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
232 } 232 }
233 btree = &fnode->btree; 233 btree = &fnode->btree;
234 } 234 }
235 ranode->up = node; 235 ranode->up = cpu_to_le32(node);
236 memcpy(&ranode->btree, btree, btree->first_free); 236 memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free));
237 if (fnod) ranode->btree.fnode_parent = 1; 237 if (fnod) ranode->btree.fnode_parent = 1;
238 ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes; 238 ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes;
239 if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) { 239 if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) {
240 struct anode *unode; 240 struct anode *unode;
241 if ((unode = hpfs_map_anode(s, ranode->u.internal[n].down, &bh1))) { 241 if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) {
242 unode->up = ra; 242 unode->up = cpu_to_le32(ra);
243 unode->btree.fnode_parent = 0; 243 unode->btree.fnode_parent = 0;
244 mark_buffer_dirty(bh1); 244 mark_buffer_dirty(bh1);
245 brelse(bh1); 245 brelse(bh1);
@@ -248,11 +248,11 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi
248 btree->internal = 1; 248 btree->internal = 1;
249 btree->n_free_nodes = fnod ? 10 : 58; 249 btree->n_free_nodes = fnod ? 10 : 58;
250 btree->n_used_nodes = 2; 250 btree->n_used_nodes = 2;
251 btree->first_free = (char *)&btree->u.internal[2] - (char *)btree; 251 btree->first_free = cpu_to_le16((char *)&btree->u.internal[2] - (char *)btree);
252 btree->u.internal[0].file_secno = fs; 252 btree->u.internal[0].file_secno = cpu_to_le32(fs);
253 btree->u.internal[0].down = ra; 253 btree->u.internal[0].down = cpu_to_le32(ra);
254 btree->u.internal[1].file_secno = -1; 254 btree->u.internal[1].file_secno = cpu_to_le32(-1);
255 btree->u.internal[1].down = na; 255 btree->u.internal[1].down = cpu_to_le32(na);
256 mark_buffer_dirty(bh); 256 mark_buffer_dirty(bh);
257 brelse(bh); 257 brelse(bh);
258 mark_buffer_dirty(bh2); 258 mark_buffer_dirty(bh2);
@@ -279,7 +279,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
279 go_down: 279 go_down:
280 d2 = 0; 280 d2 = 0;
281 while (btree1->internal) { 281 while (btree1->internal) {
282 ano = btree1->u.internal[pos].down; 282 ano = le32_to_cpu(btree1->u.internal[pos].down);
283 if (level) brelse(bh); 283 if (level) brelse(bh);
284 if (hpfs_sb(s)->sb_chk) 284 if (hpfs_sb(s)->sb_chk)
285 if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1")) 285 if (hpfs_stop_cycles(s, ano, &d1, &d2, "hpfs_remove_btree #1"))
@@ -290,7 +290,7 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
290 pos = 0; 290 pos = 0;
291 } 291 }
292 for (i = 0; i < btree1->n_used_nodes; i++) 292 for (i = 0; i < btree1->n_used_nodes; i++)
293 hpfs_free_sectors(s, btree1->u.external[i].disk_secno, btree1->u.external[i].length); 293 hpfs_free_sectors(s, le32_to_cpu(btree1->u.external[i].disk_secno), le32_to_cpu(btree1->u.external[i].length));
294 go_up: 294 go_up:
295 if (!level) return; 295 if (!level) return;
296 brelse(bh); 296 brelse(bh);
@@ -298,13 +298,13 @@ void hpfs_remove_btree(struct super_block *s, struct bplus_header *btree)
298 if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return; 298 if (hpfs_stop_cycles(s, ano, &c1, &c2, "hpfs_remove_btree #2")) return;
299 hpfs_free_sectors(s, ano, 1); 299 hpfs_free_sectors(s, ano, 1);
300 oano = ano; 300 oano = ano;
301 ano = anode->up; 301 ano = le32_to_cpu(anode->up);
302 if (--level) { 302 if (--level) {
303 if (!(anode = hpfs_map_anode(s, ano, &bh))) return; 303 if (!(anode = hpfs_map_anode(s, ano, &bh))) return;
304 btree1 = &anode->btree; 304 btree1 = &anode->btree;
305 } else btree1 = btree; 305 } else btree1 = btree;
306 for (i = 0; i < btree1->n_used_nodes; i++) { 306 for (i = 0; i < btree1->n_used_nodes; i++) {
307 if (btree1->u.internal[i].down == oano) { 307 if (le32_to_cpu(btree1->u.internal[i].down) == oano) {
308 if ((pos = i + 1) < btree1->n_used_nodes) 308 if ((pos = i + 1) < btree1->n_used_nodes)
309 goto go_down; 309 goto go_down;
310 else 310 else
@@ -411,7 +411,7 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs)
411 if (fno) { 411 if (fno) {
412 btree->n_free_nodes = 8; 412 btree->n_free_nodes = 8;
413 btree->n_used_nodes = 0; 413 btree->n_used_nodes = 0;
414 btree->first_free = 8; 414 btree->first_free = cpu_to_le16(8);
415 btree->internal = 0; 415 btree->internal = 0;
416 mark_buffer_dirty(bh); 416 mark_buffer_dirty(bh);
417 } else hpfs_free_sectors(s, f, 1); 417 } else hpfs_free_sectors(s, f, 1);
@@ -421,22 +421,22 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs)
421 while (btree->internal) { 421 while (btree->internal) {
422 nodes = btree->n_used_nodes + btree->n_free_nodes; 422 nodes = btree->n_used_nodes + btree->n_free_nodes;
423 for (i = 0; i < btree->n_used_nodes; i++) 423 for (i = 0; i < btree->n_used_nodes; i++)
424 if (btree->u.internal[i].file_secno >= secs) goto f; 424 if (le32_to_cpu(btree->u.internal[i].file_secno) >= secs) goto f;
425 brelse(bh); 425 brelse(bh);
426 hpfs_error(s, "internal btree %08x doesn't end with -1", node); 426 hpfs_error(s, "internal btree %08x doesn't end with -1", node);
427 return; 427 return;
428 f: 428 f:
429 for (j = i + 1; j < btree->n_used_nodes; j++) 429 for (j = i + 1; j < btree->n_used_nodes; j++)
430 hpfs_ea_remove(s, btree->u.internal[j].down, 1, 0); 430 hpfs_ea_remove(s, le32_to_cpu(btree->u.internal[j].down), 1, 0);
431 btree->n_used_nodes = i + 1; 431 btree->n_used_nodes = i + 1;
432 btree->n_free_nodes = nodes - btree->n_used_nodes; 432 btree->n_free_nodes = nodes - btree->n_used_nodes;
433 btree->first_free = 8 + 8 * btree->n_used_nodes; 433 btree->first_free = cpu_to_le16(8 + 8 * btree->n_used_nodes);
434 mark_buffer_dirty(bh); 434 mark_buffer_dirty(bh);
435 if (btree->u.internal[i].file_secno == secs) { 435 if (btree->u.internal[i].file_secno == cpu_to_le32(secs)) {
436 brelse(bh); 436 brelse(bh);
437 return; 437 return;
438 } 438 }
439 node = btree->u.internal[i].down; 439 node = le32_to_cpu(btree->u.internal[i].down);
440 brelse(bh); 440 brelse(bh);
441 if (hpfs_sb(s)->sb_chk) 441 if (hpfs_sb(s)->sb_chk)
442 if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree")) 442 if (hpfs_stop_cycles(s, node, &c1, &c2, "hpfs_truncate_btree"))
@@ -446,25 +446,25 @@ void hpfs_truncate_btree(struct super_block *s, secno f, int fno, unsigned secs)
446 } 446 }
447 nodes = btree->n_used_nodes + btree->n_free_nodes; 447 nodes = btree->n_used_nodes + btree->n_free_nodes;
448 for (i = 0; i < btree->n_used_nodes; i++) 448 for (i = 0; i < btree->n_used_nodes; i++)
449 if (btree->u.external[i].file_secno + btree->u.external[i].length >= secs) goto ff; 449 if (le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) >= secs) goto ff;
450 brelse(bh); 450 brelse(bh);
451 return; 451 return;
452 ff: 452 ff:
453 if (secs <= btree->u.external[i].file_secno) { 453 if (secs <= le32_to_cpu(btree->u.external[i].file_secno)) {
454 hpfs_error(s, "there is an allocation error in file %08x, sector %08x", f, secs); 454 hpfs_error(s, "there is an allocation error in file %08x, sector %08x", f, secs);
455 if (i) i--; 455 if (i) i--;
456 } 456 }
457 else if (btree->u.external[i].file_secno + btree->u.external[i].length > secs) { 457 else if (le32_to_cpu(btree->u.external[i].file_secno) + le32_to_cpu(btree->u.external[i].length) > secs) {
458 hpfs_free_sectors(s, btree->u.external[i].disk_secno + secs - 458 hpfs_free_sectors(s, le32_to_cpu(btree->u.external[i].disk_secno) + secs -
459 btree->u.external[i].file_secno, btree->u.external[i].length 459 le32_to_cpu(btree->u.external[i].file_secno), le32_to_cpu(btree->u.external[i].length)
460 - secs + btree->u.external[i].file_secno); /* I hope gcc optimizes this :-) */ 460 - secs + le32_to_cpu(btree->u.external[i].file_secno)); /* I hope gcc optimizes this :-) */
461 btree->u.external[i].length = secs - btree->u.external[i].file_secno; 461 btree->u.external[i].length = cpu_to_le32(secs - le32_to_cpu(btree->u.external[i].file_secno));
462 } 462 }
463 for (j = i + 1; j < btree->n_used_nodes; j++) 463 for (j = i + 1; j < btree->n_used_nodes; j++)
464 hpfs_free_sectors(s, btree->u.external[j].disk_secno, btree->u.external[j].length); 464 hpfs_free_sectors(s, le32_to_cpu(btree->u.external[j].disk_secno), le32_to_cpu(btree->u.external[j].length));
465 btree->n_used_nodes = i + 1; 465 btree->n_used_nodes = i + 1;
466 btree->n_free_nodes = nodes - btree->n_used_nodes; 466 btree->n_free_nodes = nodes - btree->n_used_nodes;
467 btree->first_free = 8 + 12 * btree->n_used_nodes; 467 btree->first_free = cpu_to_le16(8 + 12 * btree->n_used_nodes);
468 mark_buffer_dirty(bh); 468 mark_buffer_dirty(bh);
469 brelse(bh); 469 brelse(bh);
470} 470}
@@ -480,12 +480,12 @@ void hpfs_remove_fnode(struct super_block *s, fnode_secno fno)
480 struct extended_attribute *ea_end; 480 struct extended_attribute *ea_end;
481 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; 481 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return;
482 if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); 482 if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree);
483 else hpfs_remove_dtree(s, fnode->u.external[0].disk_secno); 483 else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno));
484 ea_end = fnode_end_ea(fnode); 484 ea_end = fnode_end_ea(fnode);
485 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 485 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea))
486 if (ea->indirect) 486 if (ea->indirect)
487 hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); 487 hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea));
488 hpfs_ea_ext_remove(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l); 488 hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l));
489 brelse(bh); 489 brelse(bh);
490 hpfs_free_sectors(s, fno, 1); 490 hpfs_free_sectors(s, fno, 1);
491} 491}
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 208f3d7769d5..f46ae025bfb5 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -88,9 +88,9 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
88 hpfs_error(inode->i_sb, "not a directory, fnode %08lx", 88 hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
89 (unsigned long)inode->i_ino); 89 (unsigned long)inode->i_ino);
90 } 90 }
91 if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) { 91 if (hpfs_inode->i_dno != le32_to_cpu(fno->u.external[0].disk_secno)) {
92 e = 1; 92 e = 1;
93 hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, fno->u.external[0].disk_secno); 93 hpfs_error(inode->i_sb, "corrupted inode: i_dno == %08x, fnode -> dnode == %08x", hpfs_inode->i_dno, le32_to_cpu(fno->u.external[0].disk_secno));
94 } 94 }
95 brelse(bh); 95 brelse(bh);
96 if (e) { 96 if (e) {
@@ -156,7 +156,7 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
156 goto again; 156 goto again;
157 } 157 }
158 tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); 158 tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3);
159 if (filldir(dirent, tempname, de->namelen, old_pos, de->fnode, DT_UNKNOWN) < 0) { 159 if (filldir(dirent, tempname, de->namelen, old_pos, le32_to_cpu(de->fnode), DT_UNKNOWN) < 0) {
160 filp->f_pos = old_pos; 160 filp->f_pos = old_pos;
161 if (tempname != de->name) kfree(tempname); 161 if (tempname != de->name) kfree(tempname);
162 hpfs_brelse4(&qbh); 162 hpfs_brelse4(&qbh);
@@ -221,7 +221,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
221 * Get inode number, what we're after. 221 * Get inode number, what we're after.
222 */ 222 */
223 223
224 ino = de->fnode; 224 ino = le32_to_cpu(de->fnode);
225 225
226 /* 226 /*
227 * Go find or make an inode. 227 * Go find or make an inode.
@@ -236,7 +236,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
236 hpfs_init_inode(result); 236 hpfs_init_inode(result);
237 if (de->directory) 237 if (de->directory)
238 hpfs_read_inode(result); 238 hpfs_read_inode(result);
239 else if (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas) 239 else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas)
240 hpfs_read_inode(result); 240 hpfs_read_inode(result);
241 else { 241 else {
242 result->i_mode |= S_IFREG; 242 result->i_mode |= S_IFREG;
@@ -261,19 +261,19 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
261 */ 261 */
262 262
263 if (!result->i_ctime.tv_sec) { 263 if (!result->i_ctime.tv_sec) {
264 if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, de->creation_date))) 264 if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date))))
265 result->i_ctime.tv_sec = 1; 265 result->i_ctime.tv_sec = 1;
266 result->i_ctime.tv_nsec = 0; 266 result->i_ctime.tv_nsec = 0;
267 result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, de->write_date); 267 result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date));
268 result->i_mtime.tv_nsec = 0; 268 result->i_mtime.tv_nsec = 0;
269 result->i_atime.tv_sec = local_to_gmt(dir->i_sb, de->read_date); 269 result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date));
270 result->i_atime.tv_nsec = 0; 270 result->i_atime.tv_nsec = 0;
271 hpfs_result->i_ea_size = de->ea_size; 271 hpfs_result->i_ea_size = le32_to_cpu(de->ea_size);
272 if (!hpfs_result->i_ea_mode && de->read_only) 272 if (!hpfs_result->i_ea_mode && de->read_only)
273 result->i_mode &= ~0222; 273 result->i_mode &= ~0222;
274 if (!de->directory) { 274 if (!de->directory) {
275 if (result->i_size == -1) { 275 if (result->i_size == -1) {
276 result->i_size = de->file_size; 276 result->i_size = le32_to_cpu(de->file_size);
277 result->i_data.a_ops = &hpfs_aops; 277 result->i_data.a_ops = &hpfs_aops;
278 hpfs_i(result)->mmu_private = result->i_size; 278 hpfs_i(result)->mmu_private = result->i_size;
279 /* 279 /*
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 07711c392f8b..1e0e2ac30fd3 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -14,11 +14,11 @@ static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde)
14 struct hpfs_dirent *de_end = dnode_end_de(d); 14 struct hpfs_dirent *de_end = dnode_end_de(d);
15 int i = 1; 15 int i = 1;
16 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { 16 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) {
17 if (de == fde) return ((loff_t) d->self << 4) | (loff_t)i; 17 if (de == fde) return ((loff_t) le32_to_cpu(d->self) << 4) | (loff_t)i;
18 i++; 18 i++;
19 } 19 }
20 printk("HPFS: get_pos: not_found\n"); 20 printk("HPFS: get_pos: not_found\n");
21 return ((loff_t)d->self << 4) | (loff_t)1; 21 return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1;
22} 22}
23 23
24void hpfs_add_pos(struct inode *inode, loff_t *pos) 24void hpfs_add_pos(struct inode *inode, loff_t *pos)
@@ -130,30 +130,30 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno
130{ 130{
131 struct hpfs_dirent *de; 131 struct hpfs_dirent *de;
132 if (!(de = dnode_last_de(d))) { 132 if (!(de = dnode_last_de(d))) {
133 hpfs_error(s, "set_last_pointer: empty dnode %08x", d->self); 133 hpfs_error(s, "set_last_pointer: empty dnode %08x", le32_to_cpu(d->self));
134 return; 134 return;
135 } 135 }
136 if (hpfs_sb(s)->sb_chk) { 136 if (hpfs_sb(s)->sb_chk) {
137 if (de->down) { 137 if (de->down) {
138 hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", 138 hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x",
139 d->self, de_down_pointer(de)); 139 le32_to_cpu(d->self), de_down_pointer(de));
140 return; 140 return;
141 } 141 }
142 if (de->length != 32) { 142 if (le16_to_cpu(de->length) != 32) {
143 hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", d->self); 143 hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", le32_to_cpu(d->self));
144 return; 144 return;
145 } 145 }
146 } 146 }
147 if (ptr) { 147 if (ptr) {
148 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); 148 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4);
149 if (le32_to_cpu(d->first_free) > 2048) { 149 if (le32_to_cpu(d->first_free) > 2048) {
150 hpfs_error(s, "set_last_pointer: too long dnode %08x", d->self); 150 hpfs_error(s, "set_last_pointer: too long dnode %08x", le32_to_cpu(d->self));
151 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4); 151 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4);
152 return; 152 return;
153 } 153 }
154 de->length = 36; 154 de->length = cpu_to_le16(36);
155 de->down = 1; 155 de->down = 1;
156 *(dnode_secno *)((char *)de + 32) = ptr; 156 *(dnode_secno *)((char *)de + 32) = cpu_to_le32(ptr);
157 } 157 }
158} 158}
159 159
@@ -169,7 +169,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d,
169 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { 169 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) {
170 int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last); 170 int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last);
171 if (!c) { 171 if (!c) {
172 hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, d->self); 172 hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, le32_to_cpu(d->self));
173 return NULL; 173 return NULL;
174 } 174 }
175 if (c < 0) break; 175 if (c < 0) break;
@@ -177,11 +177,10 @@ 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 *(int *)((char *)de + d_size - 4) = down_ptr; 180 *(dnode_secno *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr);
181 de->down = 1; 181 de->down = 1;
182 } 182 }
183 de->length = d_size; 183 de->length = cpu_to_le16(d_size);
184 if (down_ptr) de->down = 1;
185 de->not_8x3 = hpfs_is_name_long(name, namelen); 184 de->not_8x3 = hpfs_is_name_long(name, namelen);
186 de->namelen = namelen; 185 de->namelen = namelen;
187 memcpy(de->name, name, namelen); 186 memcpy(de->name, name, namelen);
@@ -195,10 +194,10 @@ static void hpfs_delete_de(struct super_block *s, struct dnode *d,
195 struct hpfs_dirent *de) 194 struct hpfs_dirent *de)
196{ 195{
197 if (de->last) { 196 if (de->last) {
198 hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); 197 hpfs_error(s, "attempt to delete last dirent in dnode %08x", le32_to_cpu(d->self));
199 return; 198 return;
200 } 199 }
201 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - de->length); 200 d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - le16_to_cpu(de->length));
202 memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); 201 memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de);
203} 202}
204 203
@@ -206,14 +205,14 @@ static void fix_up_ptrs(struct super_block *s, struct dnode *d)
206{ 205{
207 struct hpfs_dirent *de; 206 struct hpfs_dirent *de;
208 struct hpfs_dirent *de_end = dnode_end_de(d); 207 struct hpfs_dirent *de_end = dnode_end_de(d);
209 dnode_secno dno = d->self; 208 dnode_secno dno = le32_to_cpu(d->self);
210 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) 209 for (de = dnode_first_de(d); de < de_end; de = de_next_de(de))
211 if (de->down) { 210 if (de->down) {
212 struct quad_buffer_head qbh; 211 struct quad_buffer_head qbh;
213 struct dnode *dd; 212 struct dnode *dd;
214 if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) { 213 if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) {
215 if (dd->up != dno || dd->root_dnode) { 214 if (le32_to_cpu(dd->up) != dno || dd->root_dnode) {
216 dd->up = dno; 215 dd->up = cpu_to_le32(dno);
217 dd->root_dnode = 0; 216 dd->root_dnode = 0;
218 hpfs_mark_4buffers_dirty(&qbh); 217 hpfs_mark_4buffers_dirty(&qbh);
219 } 218 }
@@ -291,7 +290,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
291 copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); 290 copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de);
292 for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); 291 for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1);
293 h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; 292 h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10;
294 if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1))) { 293 if (!(ad = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &adno, &qbh1))) {
295 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); 294 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted");
296 hpfs_brelse4(&qbh); 295 hpfs_brelse4(&qbh);
297 kfree(nd); 296 kfree(nd);
@@ -315,19 +314,20 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
315 set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); 314 set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0);
316 de = de_next_de(de); 315 de = de_next_de(de);
317 memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); 316 memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de);
318 nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - (char *)de - (char *)nd - 20); 317 nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - ((char *)de - (char *)nd - 20));
319 memcpy(d, nd, le32_to_cpu(nd->first_free)); 318 memcpy(d, nd, le32_to_cpu(nd->first_free));
320 for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); 319 for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos);
321 fix_up_ptrs(i->i_sb, ad); 320 fix_up_ptrs(i->i_sb, ad);
322 if (!d->root_dnode) { 321 if (!d->root_dnode) {
323 dno = ad->up = d->up; 322 ad->up = d->up;
323 dno = le32_to_cpu(ad->up);
324 hpfs_mark_4buffers_dirty(&qbh); 324 hpfs_mark_4buffers_dirty(&qbh);
325 hpfs_brelse4(&qbh); 325 hpfs_brelse4(&qbh);
326 hpfs_mark_4buffers_dirty(&qbh1); 326 hpfs_mark_4buffers_dirty(&qbh1);
327 hpfs_brelse4(&qbh1); 327 hpfs_brelse4(&qbh1);
328 goto go_up; 328 goto go_up;
329 } 329 }
330 if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2))) { 330 if (!(rd = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &rdno, &qbh2))) {
331 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); 331 hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted");
332 hpfs_brelse4(&qbh); 332 hpfs_brelse4(&qbh);
333 hpfs_brelse4(&qbh1); 333 hpfs_brelse4(&qbh1);
@@ -339,7 +339,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
339 i->i_blocks += 4; 339 i->i_blocks += 4;
340 rd->root_dnode = 1; 340 rd->root_dnode = 1;
341 rd->up = d->up; 341 rd->up = d->up;
342 if (!(fnode = hpfs_map_fnode(i->i_sb, d->up, &bh))) { 342 if (!(fnode = hpfs_map_fnode(i->i_sb, le32_to_cpu(d->up), &bh))) {
343 hpfs_free_dnode(i->i_sb, rdno); 343 hpfs_free_dnode(i->i_sb, rdno);
344 hpfs_brelse4(&qbh); 344 hpfs_brelse4(&qbh);
345 hpfs_brelse4(&qbh1); 345 hpfs_brelse4(&qbh1);
@@ -348,10 +348,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno,
348 kfree(nname); 348 kfree(nname);
349 return 1; 349 return 1;
350 } 350 }
351 fnode->u.external[0].disk_secno = rdno; 351 fnode->u.external[0].disk_secno = cpu_to_le32(rdno);
352 mark_buffer_dirty(bh); 352 mark_buffer_dirty(bh);
353 brelse(bh); 353 brelse(bh);
354 d->up = ad->up = hpfs_i(i)->i_dno = rdno; 354 hpfs_i(i)->i_dno = rdno;
355 d->up = ad->up = cpu_to_le32(rdno);
355 d->root_dnode = ad->root_dnode = 0; 356 d->root_dnode = ad->root_dnode = 0;
356 hpfs_mark_4buffers_dirty(&qbh); 357 hpfs_mark_4buffers_dirty(&qbh);
357 hpfs_brelse4(&qbh); 358 hpfs_brelse4(&qbh);
@@ -436,9 +437,9 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
436 return 0; 437 return 0;
437 if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; 438 if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0;
438 if (hpfs_sb(i->i_sb)->sb_chk) { 439 if (hpfs_sb(i->i_sb)->sb_chk) {
439 if (dnode->up != chk_up) { 440 if (le32_to_cpu(dnode->up) != chk_up) {
440 hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", 441 hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x",
441 dno, chk_up, dnode->up); 442 dno, chk_up, le32_to_cpu(dnode->up));
442 hpfs_brelse4(&qbh); 443 hpfs_brelse4(&qbh);
443 return 0; 444 return 0;
444 } 445 }
@@ -454,7 +455,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
454 hpfs_brelse4(&qbh); 455 hpfs_brelse4(&qbh);
455 } 456 }
456 while (!(de = dnode_pre_last_de(dnode))) { 457 while (!(de = dnode_pre_last_de(dnode))) {
457 dnode_secno up = dnode->up; 458 dnode_secno up = le32_to_cpu(dnode->up);
458 hpfs_brelse4(&qbh); 459 hpfs_brelse4(&qbh);
459 hpfs_free_dnode(i->i_sb, dno); 460 hpfs_free_dnode(i->i_sb, dno);
460 i->i_size -= 2048; 461 i->i_size -= 2048;
@@ -474,7 +475,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
474 return 0; 475 return 0;
475 } 476 }
476 dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); 477 dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4);
477 de->length -= 4; 478 de->length = cpu_to_le16(le16_to_cpu(de->length) - 4);
478 de->down = 0; 479 de->down = 0;
479 hpfs_mark_4buffers_dirty(&qbh); 480 hpfs_mark_4buffers_dirty(&qbh);
480 dno = up; 481 dno = up;
@@ -482,12 +483,12 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to)
482 t = get_pos(dnode, de); 483 t = get_pos(dnode, de);
483 for_all_poss(i, hpfs_pos_subst, t, 4); 484 for_all_poss(i, hpfs_pos_subst, t, 4);
484 for_all_poss(i, hpfs_pos_subst, t + 1, 5); 485 for_all_poss(i, hpfs_pos_subst, t + 1, 5);
485 if (!(nde = kmalloc(de->length, GFP_NOFS))) { 486 if (!(nde = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) {
486 hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted"); 487 hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted");
487 hpfs_brelse4(&qbh); 488 hpfs_brelse4(&qbh);
488 return 0; 489 return 0;
489 } 490 }
490 memcpy(nde, de, de->length); 491 memcpy(nde, de, le16_to_cpu(de->length));
491 ddno = de->down ? de_down_pointer(de) : 0; 492 ddno = de->down ? de_down_pointer(de) : 0;
492 hpfs_delete_de(i->i_sb, dnode, de); 493 hpfs_delete_de(i->i_sb, dnode, de);
493 set_last_pointer(i->i_sb, dnode, ddno); 494 set_last_pointer(i->i_sb, dnode, ddno);
@@ -520,7 +521,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
520 if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { 521 if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) {
521 struct hpfs_dirent *de_end; 522 struct hpfs_dirent *de_end;
522 int root = dnode->root_dnode; 523 int root = dnode->root_dnode;
523 up = dnode->up; 524 up = le32_to_cpu(dnode->up);
524 de = dnode_first_de(dnode); 525 de = dnode_first_de(dnode);
525 down = de->down ? de_down_pointer(de) : 0; 526 down = de->down ? de_down_pointer(de) : 0;
526 if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) { 527 if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) {
@@ -544,13 +545,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
544 return; 545 return;
545 } 546 }
546 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { 547 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
547 d1->up = up; 548 d1->up = cpu_to_le32(up);
548 d1->root_dnode = 1; 549 d1->root_dnode = 1;
549 hpfs_mark_4buffers_dirty(&qbh1); 550 hpfs_mark_4buffers_dirty(&qbh1);
550 hpfs_brelse4(&qbh1); 551 hpfs_brelse4(&qbh1);
551 } 552 }
552 if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) { 553 if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) {
553 fnode->u.external[0].disk_secno = down; 554 fnode->u.external[0].disk_secno = cpu_to_le32(down);
554 mark_buffer_dirty(bh); 555 mark_buffer_dirty(bh);
555 brelse(bh); 556 brelse(bh);
556 } 557 }
@@ -569,16 +570,16 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
569 for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p); 570 for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p);
570 if (!down) { 571 if (!down) {
571 de->down = 0; 572 de->down = 0;
572 de->length -= 4; 573 de->length = cpu_to_le16(le16_to_cpu(de->length) - 4);
573 dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); 574 dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4);
574 memmove(de_next_de(de), (char *)de_next_de(de) + 4, 575 memmove(de_next_de(de), (char *)de_next_de(de) + 4,
575 (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); 576 (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de));
576 } else { 577 } else {
577 struct dnode *d1; 578 struct dnode *d1;
578 struct quad_buffer_head qbh1; 579 struct quad_buffer_head qbh1;
579 *(dnode_secno *) ((void *) de + de->length - 4) = down; 580 *(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4) = down;
580 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { 581 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
581 d1->up = up; 582 d1->up = cpu_to_le32(up);
582 hpfs_mark_4buffers_dirty(&qbh1); 583 hpfs_mark_4buffers_dirty(&qbh1);
583 hpfs_brelse4(&qbh1); 584 hpfs_brelse4(&qbh1);
584 } 585 }
@@ -595,18 +596,18 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
595 struct quad_buffer_head qbh1; 596 struct quad_buffer_head qbh1;
596 if (!de_next->down) goto endm; 597 if (!de_next->down) goto endm;
597 ndown = de_down_pointer(de_next); 598 ndown = de_down_pointer(de_next);
598 if (!(de_cp = kmalloc(de->length, GFP_NOFS))) { 599 if (!(de_cp = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) {
599 printk("HPFS: out of memory for dtree balancing\n"); 600 printk("HPFS: out of memory for dtree balancing\n");
600 goto endm; 601 goto endm;
601 } 602 }
602 memcpy(de_cp, de, de->length); 603 memcpy(de_cp, de, le16_to_cpu(de->length));
603 hpfs_delete_de(i->i_sb, dnode, de); 604 hpfs_delete_de(i->i_sb, dnode, de);
604 hpfs_mark_4buffers_dirty(&qbh); 605 hpfs_mark_4buffers_dirty(&qbh);
605 hpfs_brelse4(&qbh); 606 hpfs_brelse4(&qbh);
606 for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4); 607 for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4);
607 for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1); 608 for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1);
608 if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) { 609 if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) {
609 d1->up = ndown; 610 d1->up = cpu_to_le32(ndown);
610 hpfs_mark_4buffers_dirty(&qbh1); 611 hpfs_mark_4buffers_dirty(&qbh1);
611 hpfs_brelse4(&qbh1); 612 hpfs_brelse4(&qbh1);
612 } 613 }
@@ -646,38 +647,38 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
646 printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); 647 printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n");
647 printk("HPFS: warning: goin'on\n"); 648 printk("HPFS: warning: goin'on\n");
648 } 649 }
649 del->length += 4; 650 del->length = cpu_to_le16(le16_to_cpu(del->length) + 4);
650 del->down = 1; 651 del->down = 1;
651 d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); 652 d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4);
652 } 653 }
653 if (dlp && !down) { 654 if (dlp && !down) {
654 del->length -= 4; 655 del->length = cpu_to_le16(le16_to_cpu(del->length) - 4);
655 del->down = 0; 656 del->down = 0;
656 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);
657 } else if (down) 658 } else if (down)
658 *(dnode_secno *) ((void *) del + del->length - 4) = down; 659 *(dnode_secno *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down);
659 } else goto endm; 660 } else goto endm;
660 if (!(de_cp = kmalloc(de_prev->length, GFP_NOFS))) { 661 if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) {
661 printk("HPFS: out of memory for dtree balancing\n"); 662 printk("HPFS: out of memory for dtree balancing\n");
662 hpfs_brelse4(&qbh1); 663 hpfs_brelse4(&qbh1);
663 goto endm; 664 goto endm;
664 } 665 }
665 hpfs_mark_4buffers_dirty(&qbh1); 666 hpfs_mark_4buffers_dirty(&qbh1);
666 hpfs_brelse4(&qbh1); 667 hpfs_brelse4(&qbh1);
667 memcpy(de_cp, de_prev, de_prev->length); 668 memcpy(de_cp, de_prev, le16_to_cpu(de_prev->length));
668 hpfs_delete_de(i->i_sb, dnode, de_prev); 669 hpfs_delete_de(i->i_sb, dnode, de_prev);
669 if (!de_prev->down) { 670 if (!de_prev->down) {
670 de_prev->length += 4; 671 de_prev->length = cpu_to_le16(le16_to_cpu(de_prev->length) + 4);
671 de_prev->down = 1; 672 de_prev->down = 1;
672 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);
673 } 674 }
674 *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; 675 *(dnode_secno *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown);
675 hpfs_mark_4buffers_dirty(&qbh); 676 hpfs_mark_4buffers_dirty(&qbh);
676 hpfs_brelse4(&qbh); 677 hpfs_brelse4(&qbh);
677 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);
678 for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1)); 679 for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1));
679 if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) { 680 if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) {
680 d1->up = ndown; 681 d1->up = cpu_to_le32(ndown);
681 hpfs_mark_4buffers_dirty(&qbh1); 682 hpfs_mark_4buffers_dirty(&qbh1);
682 hpfs_brelse4(&qbh1); 683 hpfs_brelse4(&qbh1);
683 } 684 }
@@ -744,8 +745,8 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes,
744 ptr = 0; 745 ptr = 0;
745 go_up: 746 go_up:
746 if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; 747 if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return;
747 if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && dnode->up != odno) 748 if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && le32_to_cpu(dnode->up) != odno)
748 hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, dnode->up); 749 hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, le32_to_cpu(dnode->up));
749 de = dnode_first_de(dnode); 750 de = dnode_first_de(dnode);
750 if (ptr) while(1) { 751 if (ptr) while(1) {
751 if (de->down) if (de_down_pointer(de) == ptr) goto process_de; 752 if (de->down) if (de_down_pointer(de) == ptr) goto process_de;
@@ -769,7 +770,7 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes,
769 if (!de->first && !de->last && n_items) (*n_items)++; 770 if (!de->first && !de->last && n_items) (*n_items)++;
770 if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de; 771 if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de;
771 ptr = dno; 772 ptr = dno;
772 dno = dnode->up; 773 dno = le32_to_cpu(dnode->up);
773 if (dnode->root_dnode) { 774 if (dnode->root_dnode) {
774 hpfs_brelse4(&qbh); 775 hpfs_brelse4(&qbh);
775 return; 776 return;
@@ -817,8 +818,8 @@ dnode_secno hpfs_de_as_down_as_possible(struct super_block *s, dnode_secno dno)
817 return d; 818 return d;
818 if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; 819 if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno;
819 if (hpfs_sb(s)->sb_chk) 820 if (hpfs_sb(s)->sb_chk)
820 if (up && ((struct dnode *)qbh.data)->up != up) 821 if (up && le32_to_cpu(((struct dnode *)qbh.data)->up) != up)
821 hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, ((struct dnode *)qbh.data)->up); 822 hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, le32_to_cpu(((struct dnode *)qbh.data)->up));
822 if (!de->down) { 823 if (!de->down) {
823 hpfs_brelse4(&qbh); 824 hpfs_brelse4(&qbh);
824 return d; 825 return d;
@@ -867,7 +868,7 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
867 /* Going up */ 868 /* Going up */
868 if (dnode->root_dnode) goto bail; 869 if (dnode->root_dnode) goto bail;
869 870
870 if (!(up_dnode = hpfs_map_dnode(inode->i_sb, dnode->up, &qbh0))) 871 if (!(up_dnode = hpfs_map_dnode(inode->i_sb, le32_to_cpu(dnode->up), &qbh0)))
871 goto bail; 872 goto bail;
872 873
873 end_up_de = dnode_end_de(up_dnode); 874 end_up_de = dnode_end_de(up_dnode);
@@ -875,16 +876,16 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
875 for (up_de = dnode_first_de(up_dnode); up_de < end_up_de; 876 for (up_de = dnode_first_de(up_dnode); up_de < end_up_de;
876 up_de = de_next_de(up_de)) { 877 up_de = de_next_de(up_de)) {
877 if (!(++c & 077)) hpfs_error(inode->i_sb, 878 if (!(++c & 077)) hpfs_error(inode->i_sb,
878 "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", dnode->up); 879 "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", le32_to_cpu(dnode->up));
879 if (up_de->down && de_down_pointer(up_de) == dno) { 880 if (up_de->down && de_down_pointer(up_de) == dno) {
880 *posp = ((loff_t) dnode->up << 4) + c; 881 *posp = ((loff_t) le32_to_cpu(dnode->up) << 4) + c;
881 hpfs_brelse4(&qbh0); 882 hpfs_brelse4(&qbh0);
882 return de; 883 return de;
883 } 884 }
884 } 885 }
885 886
886 hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x", 887 hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x",
887 dno, dnode->up); 888 dno, le32_to_cpu(dnode->up));
888 hpfs_brelse4(&qbh0); 889 hpfs_brelse4(&qbh0);
889 890
890 bail: 891 bail:
@@ -1010,17 +1011,17 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
1010 /*name2[15] = 0xff;*/ 1011 /*name2[15] = 0xff;*/
1011 name1len = 15; name2len = 256; 1012 name1len = 15; name2len = 256;
1012 } 1013 }
1013 if (!(upf = hpfs_map_fnode(s, f->up, &bh))) { 1014 if (!(upf = hpfs_map_fnode(s, le32_to_cpu(f->up), &bh))) {
1014 kfree(name2); 1015 kfree(name2);
1015 return NULL; 1016 return NULL;
1016 } 1017 }
1017 if (!upf->dirflag) { 1018 if (!upf->dirflag) {
1018 brelse(bh); 1019 brelse(bh);
1019 hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, f->up); 1020 hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up));
1020 kfree(name2); 1021 kfree(name2);
1021 return NULL; 1022 return NULL;
1022 } 1023 }
1023 dno = upf->u.external[0].disk_secno; 1024 dno = le32_to_cpu(upf->u.external[0].disk_secno);
1024 brelse(bh); 1025 brelse(bh);
1025 go_down: 1026 go_down:
1026 downd = 0; 1027 downd = 0;
@@ -1042,7 +1043,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
1042 return NULL; 1043 return NULL;
1043 } 1044 }
1044 next_de: 1045 next_de:
1045 if (de->fnode == fno) { 1046 if (le32_to_cpu(de->fnode) == fno) {
1046 kfree(name2); 1047 kfree(name2);
1047 return de; 1048 return de;
1048 } 1049 }
@@ -1058,7 +1059,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
1058 goto go_down; 1059 goto go_down;
1059 } 1060 }
1060 f: 1061 f:
1061 if (de->fnode == fno) { 1062 if (le32_to_cpu(de->fnode) == fno) {
1062 kfree(name2); 1063 kfree(name2);
1063 return de; 1064 return de;
1064 } 1065 }
@@ -1067,7 +1068,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno,
1067 if ((de = de_next_de(de)) < de_end) goto next_de; 1068 if ((de = de_next_de(de)) < de_end) goto next_de;
1068 if (d->root_dnode) goto not_found; 1069 if (d->root_dnode) goto not_found;
1069 downd = dno; 1070 downd = dno;
1070 dno = d->up; 1071 dno = le32_to_cpu(d->up);
1071 hpfs_brelse4(qbh); 1072 hpfs_brelse4(qbh);
1072 if (hpfs_sb(s)->sb_chk) 1073 if (hpfs_sb(s)->sb_chk)
1073 if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { 1074 if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) {
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 1ac05bb6de37..1bbc37ddff40 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -24,7 +24,7 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len)
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) {
27 if (ea->valuelen != 8) { 27 if (le16_to_cpu(ea->valuelen) != 8) {
28 hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", 28 hpfs_error(s, "ea->indirect 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;
@@ -33,7 +33,7 @@ void hpfs_ea_ext_remove(struct super_block *s, secno a, int ano, unsigned len)
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->anode, ea_len(ea));
35 } 35 }
36 pos += ea->namelen + ea->valuelen + 5; 36 pos += ea->namelen + le16_to_cpu(ea->valuelen) + 5;
37 } 37 }
38 if (!ano) hpfs_free_sectors(s, a, (len+511) >> 9); 38 if (!ano) hpfs_free_sectors(s, a, (len+511) >> 9);
39 else { 39 else {
@@ -82,14 +82,14 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key,
82 if (!strcmp(ea->name, key)) { 82 if (!strcmp(ea->name, key)) {
83 if (ea->indirect) 83 if (ea->indirect)
84 goto indirect; 84 goto indirect;
85 if (ea->valuelen >= size) 85 if (le16_to_cpu(ea->valuelen) >= size)
86 return -EINVAL; 86 return -EINVAL;
87 memcpy(buf, ea_data(ea), ea->valuelen); 87 memcpy(buf, ea_data(ea), le16_to_cpu(ea->valuelen));
88 buf[ea->valuelen] = 0; 88 buf[le16_to_cpu(ea->valuelen)] = 0;
89 return 0; 89 return 0;
90 } 90 }
91 a = fnode->ea_secno; 91 a = le32_to_cpu(fnode->ea_secno);
92 len = fnode->ea_size_l; 92 len = le32_to_cpu(fnode->ea_size_l);
93 ano = fnode->ea_anode; 93 ano = fnode->ea_anode;
94 pos = 0; 94 pos = 0;
95 while (pos < len) { 95 while (pos < len) {
@@ -106,14 +106,14 @@ int hpfs_read_ea(struct super_block *s, struct fnode *fnode, char *key,
106 if (!strcmp(ea->name, key)) { 106 if (!strcmp(ea->name, key)) {
107 if (ea->indirect) 107 if (ea->indirect)
108 goto indirect; 108 goto indirect;
109 if (ea->valuelen >= size) 109 if (le16_to_cpu(ea->valuelen) >= size)
110 return -EINVAL; 110 return -EINVAL;
111 if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea->valuelen, buf)) 111 if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, le16_to_cpu(ea->valuelen), buf))
112 return -EIO; 112 return -EIO;
113 buf[ea->valuelen] = 0; 113 buf[le16_to_cpu(ea->valuelen)] = 0;
114 return 0; 114 return 0;
115 } 115 }
116 pos += ea->namelen + ea->valuelen + 5; 116 pos += ea->namelen + le16_to_cpu(ea->valuelen) + 5;
117 } 117 }
118 return -ENOENT; 118 return -ENOENT;
119indirect: 119indirect:
@@ -138,16 +138,16 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si
138 if (!strcmp(ea->name, key)) { 138 if (!strcmp(ea->name, key)) {
139 if (ea->indirect) 139 if (ea->indirect)
140 return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); 140 return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea));
141 if (!(ret = kmalloc((*size = ea->valuelen) + 1, GFP_NOFS))) { 141 if (!(ret = kmalloc((*size = le16_to_cpu(ea->valuelen)) + 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;
144 } 144 }
145 memcpy(ret, ea_data(ea), ea->valuelen); 145 memcpy(ret, ea_data(ea), le16_to_cpu(ea->valuelen));
146 ret[ea->valuelen] = 0; 146 ret[le16_to_cpu(ea->valuelen)] = 0;
147 return ret; 147 return ret;
148 } 148 }
149 a = fnode->ea_secno; 149 a = le32_to_cpu(fnode->ea_secno);
150 len = fnode->ea_size_l; 150 len = le32_to_cpu(fnode->ea_size_l);
151 ano = fnode->ea_anode; 151 ano = fnode->ea_anode;
152 pos = 0; 152 pos = 0;
153 while (pos < len) { 153 while (pos < len) {
@@ -164,18 +164,18 @@ char *hpfs_get_ea(struct super_block *s, struct fnode *fnode, char *key, int *si
164 if (!strcmp(ea->name, key)) { 164 if (!strcmp(ea->name, key)) {
165 if (ea->indirect) 165 if (ea->indirect)
166 return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); 166 return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea));
167 if (!(ret = kmalloc((*size = ea->valuelen) + 1, GFP_NOFS))) { 167 if (!(ret = kmalloc((*size = le16_to_cpu(ea->valuelen)) + 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;
170 } 170 }
171 if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, ea->valuelen, ret)) { 171 if (hpfs_ea_read(s, a, ano, pos + 4 + ea->namelen + 1, le16_to_cpu(ea->valuelen), ret)) {
172 kfree(ret); 172 kfree(ret);
173 return NULL; 173 return NULL;
174 } 174 }
175 ret[ea->valuelen] = 0; 175 ret[le16_to_cpu(ea->valuelen)] = 0;
176 return ret; 176 return ret;
177 } 177 }
178 pos += ea->namelen + ea->valuelen + 5; 178 pos += ea->namelen + le16_to_cpu(ea->valuelen) + 5;
179 } 179 }
180 return NULL; 180 return NULL;
181} 181}
@@ -202,13 +202,13 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
202 if (ea->indirect) { 202 if (ea->indirect) {
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->anode, ea_sec(ea), data, size);
205 } else if (ea->valuelen == size) { 205 } else if (le16_to_cpu(ea->valuelen) == size) {
206 memcpy(ea_data(ea), data, size); 206 memcpy(ea_data(ea), data, size);
207 } 207 }
208 return; 208 return;
209 } 209 }
210 a = fnode->ea_secno; 210 a = le32_to_cpu(fnode->ea_secno);
211 len = fnode->ea_size_l; 211 len = le32_to_cpu(fnode->ea_size_l);
212 ano = fnode->ea_anode; 212 ano = fnode->ea_anode;
213 pos = 0; 213 pos = 0;
214 while (pos < len) { 214 while (pos < len) {
@@ -228,41 +228,41 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
228 set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); 228 set_indirect_ea(s, ea->anode, ea_sec(ea), data, size);
229 } 229 }
230 else { 230 else {
231 if (ea->valuelen == size) 231 if (le16_to_cpu(ea->valuelen) == size)
232 hpfs_ea_write(s, a, ano, pos + 4 + ea->namelen + 1, size, data); 232 hpfs_ea_write(s, a, ano, pos + 4 + ea->namelen + 1, size, data);
233 } 233 }
234 return; 234 return;
235 } 235 }
236 pos += ea->namelen + ea->valuelen + 5; 236 pos += ea->namelen + le16_to_cpu(ea->valuelen) + 5;
237 } 237 }
238 if (!fnode->ea_offs) { 238 if (!le16_to_cpu(fnode->ea_offs)) {
239 /*if (fnode->ea_size_s) { 239 /*if (le16_to_cpu(fnode->ea_size_s)) {
240 hpfs_error(s, "fnode %08x: ea_size_s == %03x, ea_offs == 0", 240 hpfs_error(s, "fnode %08x: ea_size_s == %03x, ea_offs == 0",
241 inode->i_ino, fnode->ea_size_s); 241 inode->i_ino, le16_to_cpu(fnode->ea_size_s));
242 return; 242 return;
243 }*/ 243 }*/
244 fnode->ea_offs = 0xc4; 244 fnode->ea_offs = cpu_to_le16(0xc4);
245 } 245 }
246 if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + 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 fnode->ea_offs, fnode->ea_size_s); 249 le32_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s));
250 return; 250 return;
251 } 251 }
252 if ((fnode->ea_size_s || !fnode->ea_size_l) && 252 if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) &&
253 fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s + strlen(key) + size + 5 <= 0x200) { 253 le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5 <= 0x200) {
254 ea = fnode_end_ea(fnode); 254 ea = fnode_end_ea(fnode);
255 *(char *)ea = 0; 255 *(char *)ea = 0;
256 ea->namelen = strlen(key); 256 ea->namelen = strlen(key);
257 ea->valuelen = size; 257 ea->valuelen = cpu_to_le16(size);
258 strcpy(ea->name, key); 258 strcpy(ea->name, key);
259 memcpy(ea_data(ea), data, size); 259 memcpy(ea_data(ea), data, size);
260 fnode->ea_size_s += strlen(key) + size + 5; 260 fnode->ea_size_s = cpu_to_le16(le16_to_cpu(fnode->ea_size_s) + strlen(key) + size + 5);
261 goto ret; 261 goto ret;
262 } 262 }
263 /* Most the code here is 99.9993422% unused. I hope there are no bugs. 263 /* Most the code here is 99.9993422% unused. I hope there are no bugs.
264 But what .. HPFS.IFS has also bugs in ea management. */ 264 But what .. HPFS.IFS has also bugs in ea management. */
265 if (fnode->ea_size_s && !fnode->ea_size_l) { 265 if (le16_to_cpu(fnode->ea_size_s) && !le32_to_cpu(fnode->ea_size_l)) {
266 secno n; 266 secno n;
267 struct buffer_head *bh; 267 struct buffer_head *bh;
268 char *data; 268 char *data;
@@ -271,25 +271,26 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
271 hpfs_free_sectors(s, n, 1); 271 hpfs_free_sectors(s, n, 1);
272 return; 272 return;
273 } 273 }
274 memcpy(data, fnode_ea(fnode), fnode->ea_size_s); 274 memcpy(data, fnode_ea(fnode), le16_to_cpu(fnode->ea_size_s));
275 fnode->ea_size_l = fnode->ea_size_s; 275 fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s));
276 fnode->ea_size_s = 0; 276 fnode->ea_size_s = cpu_to_le16(0);
277 fnode->ea_secno = n; 277 fnode->ea_secno = cpu_to_le32(n);
278 fnode->ea_anode = 0; 278 fnode->ea_anode = cpu_to_le32(0);
279 mark_buffer_dirty(bh); 279 mark_buffer_dirty(bh);
280 brelse(bh); 280 brelse(bh);
281 } 281 }
282 pos = fnode->ea_size_l + 5 + strlen(key) + size; 282 pos = le32_to_cpu(fnode->ea_size_l) + 5 + strlen(key) + size;
283 len = (fnode->ea_size_l + 511) >> 9; 283 len = (le32_to_cpu(fnode->ea_size_l) + 511) >> 9;
284 if (pos >= 30000) goto bail; 284 if (pos >= 30000) goto bail;
285 while (((pos + 511) >> 9) > len) { 285 while (((pos + 511) >> 9) > len) {
286 if (!len) { 286 if (!len) {
287 if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0))) 287 secno q = hpfs_alloc_sector(s, fno, 1, 0);
288 goto bail; 288 if (!q) goto bail;
289 fnode->ea_secno = cpu_to_le32(q);
289 fnode->ea_anode = 0; 290 fnode->ea_anode = 0;
290 len++; 291 len++;
291 } else if (!fnode->ea_anode) { 292 } else if (!fnode->ea_anode) {
292 if (hpfs_alloc_if_possible(s, fnode->ea_secno + len)) { 293 if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) {
293 len++; 294 len++;
294 } else { 295 } else {
295 /* Aargh... don't know how to create ea anodes :-( */ 296 /* Aargh... don't know how to create ea anodes :-( */
@@ -298,18 +299,18 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
298 anode_secno a_s; 299 anode_secno a_s;
299 if (!(anode = hpfs_alloc_anode(s, fno, &a_s, &bh))) 300 if (!(anode = hpfs_alloc_anode(s, fno, &a_s, &bh)))
300 goto bail; 301 goto bail;
301 anode->up = fno; 302 anode->up = cpu_to_le32(fno);
302 anode->btree.fnode_parent = 1; 303 anode->btree.fnode_parent = 1;
303 anode->btree.n_free_nodes--; 304 anode->btree.n_free_nodes--;
304 anode->btree.n_used_nodes++; 305 anode->btree.n_used_nodes++;
305 anode->btree.first_free += 12; 306 anode->btree.first_free = cpu_to_le16(le16_to_cpu(anode->btree.first_free) + 12);
306 anode->u.external[0].disk_secno = fnode->ea_secno; 307 anode->u.external[0].disk_secno = cpu_to_le32(le32_to_cpu(fnode->ea_secno));
307 anode->u.external[0].file_secno = 0; 308 anode->u.external[0].file_secno = cpu_to_le32(0);
308 anode->u.external[0].length = len; 309 anode->u.external[0].length = cpu_to_le32(len);
309 mark_buffer_dirty(bh); 310 mark_buffer_dirty(bh);
310 brelse(bh); 311 brelse(bh);
311 fnode->ea_anode = 1; 312 fnode->ea_anode = 1;
312 fnode->ea_secno = a_s;*/ 313 fnode->ea_secno = cpu_to_le32(a_s);*/
313 secno new_sec; 314 secno new_sec;
314 int i; 315 int i;
315 if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9)))) 316 if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9))))
@@ -317,7 +318,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
317 for (i = 0; i < len; i++) { 318 for (i = 0; i < len; i++) {
318 struct buffer_head *bh1, *bh2; 319 struct buffer_head *bh1, *bh2;
319 void *b1, *b2; 320 void *b1, *b2;
320 if (!(b1 = hpfs_map_sector(s, fnode->ea_secno + i, &bh1, len - i - 1))) { 321 if (!(b1 = hpfs_map_sector(s, le32_to_cpu(fnode->ea_secno) + i, &bh1, len - i - 1))) {
321 hpfs_free_sectors(s, new_sec, (pos + 511) >> 9); 322 hpfs_free_sectors(s, new_sec, (pos + 511) >> 9);
322 goto bail; 323 goto bail;
323 } 324 }
@@ -331,13 +332,13 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
331 mark_buffer_dirty(bh2); 332 mark_buffer_dirty(bh2);
332 brelse(bh2); 333 brelse(bh2);
333 } 334 }
334 hpfs_free_sectors(s, fnode->ea_secno, len); 335 hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno), len);
335 fnode->ea_secno = new_sec; 336 fnode->ea_secno = cpu_to_le32(new_sec);
336 len = (pos + 511) >> 9; 337 len = (pos + 511) >> 9;
337 } 338 }
338 } 339 }
339 if (fnode->ea_anode) { 340 if (fnode->ea_anode) {
340 if (hpfs_add_sector_to_btree(s, fnode->ea_secno, 341 if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno),
341 0, len) != -1) { 342 0, len) != -1) {
342 len++; 343 len++;
343 } else { 344 } else {
@@ -349,17 +350,17 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key,
349 h[1] = strlen(key); 350 h[1] = strlen(key);
350 h[2] = size & 0xff; 351 h[2] = size & 0xff;
351 h[3] = size >> 8; 352 h[3] = size >> 8;
352 if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l, 4, h)) goto bail; 353 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;
353 if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l + 4, h[1] + 1, key)) goto bail; 354 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;
354 if (hpfs_ea_write(s, fnode->ea_secno, fnode->ea_anode, fnode->ea_size_l + 5 + h[1], size, data)) goto bail; 355 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;
355 fnode->ea_size_l = pos; 356 fnode->ea_size_l = cpu_to_le32(pos);
356 ret: 357 ret:
357 hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; 358 hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size;
358 return; 359 return;
359 bail: 360 bail:
360 if (fnode->ea_secno) 361 if (le32_to_cpu(fnode->ea_secno))
361 if (fnode->ea_anode) hpfs_truncate_btree(s, fnode->ea_secno, 1, (fnode->ea_size_l + 511) >> 9); 362 if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9);
362 else hpfs_free_sectors(s, fnode->ea_secno + ((fnode->ea_size_l + 511) >> 9), len - ((fnode->ea_size_l + 511) >> 9)); 363 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));
363 else fnode->ea_secno = fnode->ea_size_l = 0; 364 else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0);
364} 365}
365 366
diff --git a/fs/hpfs/hpfs.h b/fs/hpfs/hpfs.h
index 8cd5130247bc..91a6223893f9 100644
--- a/fs/hpfs/hpfs.h
+++ b/fs/hpfs/hpfs.h
@@ -19,6 +19,10 @@
19 For definitive information on HPFS, ask somebody else -- this is guesswork. 19 For definitive information on HPFS, ask somebody else -- this is guesswork.
20 There are certain to be many mistakes. */ 20 There are certain to be many mistakes. */
21 21
22#if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
23#error unknown endian
24#endif
25
22/* Notation */ 26/* Notation */
23 27
24typedef u32 secno; /* sector number, partition relative */ 28typedef u32 secno; /* sector number, partition relative */
@@ -86,7 +90,6 @@ struct hpfs_super_block
86 secno badblocks; /* bad block list */ 90 secno badblocks; /* bad block list */
87 u32 zero3; /* 0 */ 91 u32 zero3; /* 0 */
88 time32_t last_chkdsk; /* date last checked, 0 if never */ 92 time32_t last_chkdsk; /* date last checked, 0 if never */
89 /*u32 zero4;*/ /* 0 */
90 time32_t last_optimize; /* date last optimized, 0 if never */ 93 time32_t last_optimize; /* date last optimized, 0 if never */
91 secno n_dir_band; /* number of sectors in dir band */ 94 secno n_dir_band; /* number of sectors in dir band */
92 secno dir_band_start; /* first sector in dir band */ 95 secno dir_band_start; /* first sector in dir band */
@@ -109,21 +112,44 @@ struct hpfs_spare_block
109 u32 magic; /* f991 1849 */ 112 u32 magic; /* f991 1849 */
110 u32 magic1; /* fa52 29c5, more magic? */ 113 u32 magic1; /* fa52 29c5, more magic? */
111 114
112 unsigned dirty: 1; /* 0 clean, 1 "improperly stopped" */ 115#ifdef __LITTLE_ENDIAN
113 unsigned sparedir_used: 1; /* spare dirblks used */ 116 u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */
114 unsigned hotfixes_used: 1; /* hotfixes used */ 117 u8 sparedir_used: 1; /* spare dirblks used */
115 unsigned bad_sector: 1; /* bad sector, corrupted disk (???) */ 118 u8 hotfixes_used: 1; /* hotfixes used */
116 unsigned bad_bitmap: 1; /* bad bitmap */ 119 u8 bad_sector: 1; /* bad sector, corrupted disk (???) */
117 unsigned fast: 1; /* partition was fast formatted */ 120 u8 bad_bitmap: 1; /* bad bitmap */
118 unsigned old_wrote: 1; /* old version wrote to partion */ 121 u8 fast: 1; /* partition was fast formatted */
119 unsigned old_wrote_1: 1; /* old version wrote to partion (?) */ 122 u8 old_wrote: 1; /* old version wrote to partion */
120 unsigned install_dasd_limits: 1; /* HPFS386 flags */ 123 u8 old_wrote_1: 1; /* old version wrote to partion (?) */
121 unsigned resynch_dasd_limits: 1; 124#else
122 unsigned dasd_limits_operational: 1; 125 u8 old_wrote_1: 1; /* old version wrote to partion (?) */
123 unsigned multimedia_active: 1; 126 u8 old_wrote: 1; /* old version wrote to partion */
124 unsigned dce_acls_active: 1; 127 u8 fast: 1; /* partition was fast formatted */
125 unsigned dasd_limits_dirty: 1; 128 u8 bad_bitmap: 1; /* bad bitmap */
126 unsigned flag67: 2; 129 u8 bad_sector: 1; /* bad sector, corrupted disk (???) */
130 u8 hotfixes_used: 1; /* hotfixes used */
131 u8 sparedir_used: 1; /* spare dirblks used */
132 u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */
133#endif
134
135#ifdef __LITTLE_ENDIAN
136 u8 install_dasd_limits: 1; /* HPFS386 flags */
137 u8 resynch_dasd_limits: 1;
138 u8 dasd_limits_operational: 1;
139 u8 multimedia_active: 1;
140 u8 dce_acls_active: 1;
141 u8 dasd_limits_dirty: 1;
142 u8 flag67: 2;
143#else
144 u8 flag67: 2;
145 u8 dasd_limits_dirty: 1;
146 u8 dce_acls_active: 1;
147 u8 multimedia_active: 1;
148 u8 dasd_limits_operational: 1;
149 u8 resynch_dasd_limits: 1;
150 u8 install_dasd_limits: 1; /* HPFS386 flags */
151#endif
152
127 u8 mm_contlgulty; 153 u8 mm_contlgulty;
128 u8 unused; 154 u8 unused;
129 155
@@ -255,10 +281,18 @@ struct dnode {
255 u32 magic; /* 77e4 0aae */ 281 u32 magic; /* 77e4 0aae */
256 u32 first_free; /* offset from start of dnode to 282 u32 first_free; /* offset from start of dnode to
257 first free dir entry */ 283 first free dir entry */
258 unsigned root_dnode:1; /* Is it root dnode? */ 284#ifdef __LITTLE_ENDIAN
259 unsigned increment_me:31; /* some kind of activity counter? 285 u8 root_dnode: 1; /* Is it root dnode? */
260 Neither HPFS.IFS nor CHKDSK cares 286 u8 increment_me: 7; /* some kind of activity counter? */
287 /* Neither HPFS.IFS nor CHKDSK cares
261 if you change this word */ 288 if you change this word */
289#else
290 u8 increment_me: 7; /* some kind of activity counter? */
291 /* Neither HPFS.IFS nor CHKDSK cares
292 if you change this word */
293 u8 root_dnode: 1; /* Is it root dnode? */
294#endif
295 u8 increment_me2[3];
262 secno up; /* (root dnode) directory's fnode 296 secno up; /* (root dnode) directory's fnode
263 (nonroot) parent dnode */ 297 (nonroot) parent dnode */
264 dnode_secno self; /* pointer to this dnode */ 298 dnode_secno self; /* pointer to this dnode */
@@ -266,33 +300,59 @@ struct dnode {
266}; 300};
267 301
268struct hpfs_dirent { 302struct hpfs_dirent {
269 u16 length; /* offset to next dirent */ 303 u16 length; /* offset to next dirent */
270 unsigned first: 1; /* set on phony ^A^A (".") entry */ 304
271 unsigned has_acl: 1; 305#ifdef __LITTLE_ENDIAN
272 unsigned down: 1; /* down pointer present (after name) */ 306 u8 first: 1; /* set on phony ^A^A (".") entry */
273 unsigned last: 1; /* set on phony \377 entry */ 307 u8 has_acl: 1;
274 unsigned has_ea: 1; /* entry has EA */ 308 u8 down: 1; /* down pointer present (after name) */
275 unsigned has_xtd_perm: 1; /* has extended perm list (???) */ 309 u8 last: 1; /* set on phony \377 entry */
276 unsigned has_explicit_acl: 1; 310 u8 has_ea: 1; /* entry has EA */
277 unsigned has_needea: 1; /* ?? some EA has NEEDEA set 311 u8 has_xtd_perm: 1; /* has extended perm list (???) */
312 u8 has_explicit_acl: 1;
313 u8 has_needea: 1; /* ?? some EA has NEEDEA set
314 I have no idea why this is
315 interesting in a dir entry */
316#else
317 u8 has_needea: 1; /* ?? some EA has NEEDEA set
278 I have no idea why this is 318 I have no idea why this is
279 interesting in a dir entry */ 319 interesting in a dir entry */
280 unsigned read_only: 1; /* dos attrib */ 320 u8 has_explicit_acl: 1;
281 unsigned hidden: 1; /* dos attrib */ 321 u8 has_xtd_perm: 1; /* has extended perm list (???) */
282 unsigned system: 1; /* dos attrib */ 322 u8 has_ea: 1; /* entry has EA */
283 unsigned flag11: 1; /* would be volume label dos attrib */ 323 u8 last: 1; /* set on phony \377 entry */
284 unsigned directory: 1; /* dos attrib */ 324 u8 down: 1; /* down pointer present (after name) */
285 unsigned archive: 1; /* dos attrib */ 325 u8 has_acl: 1;
286 unsigned not_8x3: 1; /* name is not 8.3 */ 326 u8 first: 1; /* set on phony ^A^A (".") entry */
287 unsigned flag15: 1; 327#endif
328
329#ifdef __LITTLE_ENDIAN
330 u8 read_only: 1; /* dos attrib */
331 u8 hidden: 1; /* dos attrib */
332 u8 system: 1; /* dos attrib */
333 u8 flag11: 1; /* would be volume label dos attrib */
334 u8 directory: 1; /* dos attrib */
335 u8 archive: 1; /* dos attrib */
336 u8 not_8x3: 1; /* name is not 8.3 */
337 u8 flag15: 1;
338#else
339 u8 flag15: 1;
340 u8 not_8x3: 1; /* name is not 8.3 */
341 u8 archive: 1; /* dos attrib */
342 u8 directory: 1; /* dos attrib */
343 u8 flag11: 1; /* would be volume label dos attrib */
344 u8 system: 1; /* dos attrib */
345 u8 hidden: 1; /* dos attrib */
346 u8 read_only: 1; /* dos attrib */
347#endif
348
288 fnode_secno fnode; /* fnode giving allocation info */ 349 fnode_secno fnode; /* fnode giving allocation info */
289 time32_t write_date; /* mtime */ 350 time32_t write_date; /* mtime */
290 u32 file_size; /* file length, bytes */ 351 u32 file_size; /* file length, bytes */
291 time32_t read_date; /* atime */ 352 time32_t read_date; /* atime */
292 time32_t creation_date; /* ctime */ 353 time32_t creation_date; /* ctime */
293 u32 ea_size; /* total EA length, bytes */ 354 u32 ea_size; /* total EA length, bytes */
294 unsigned char no_of_acls : 3; /* number of ACL's */ 355 u8 no_of_acls; /* number of ACL's (low 3 bits) */
295 unsigned char reserver : 5;
296 u8 ix; /* code page index (of filename), see 356 u8 ix; /* code page index (of filename), see
297 struct code_page_data */ 357 struct code_page_data */
298 u8 namelen, name[1]; /* file name */ 358 u8 namelen, name[1]; /* file name */
@@ -328,21 +388,33 @@ struct bplus_internal_node
328 388
329struct bplus_header 389struct bplus_header
330{ 390{
331 unsigned hbff: 1; /* high bit of first free entry offset */ 391#ifdef __LITTLE_ENDIAN
332 unsigned flag1: 1; 392 u8 hbff: 1; /* high bit of first free entry offset */
333 unsigned flag2: 1; 393 u8 flag1234: 4;
334 unsigned flag3: 1; 394 u8 fnode_parent: 1; /* ? we're pointed to by an fnode,
335 unsigned flag4: 1;
336 unsigned fnode_parent: 1; /* ? we're pointed to by an fnode,
337 the data btree or some ea or the 395 the data btree or some ea or the
338 main ea bootage pointer ea_secno */ 396 main ea bootage pointer ea_secno */
339 /* also can get set in fnodes, which 397 /* also can get set in fnodes, which
340 may be a chkdsk glitch or may mean 398 may be a chkdsk glitch or may mean
341 this bit is irrelevant in fnodes, 399 this bit is irrelevant in fnodes,
342 or this interpretation is all wet */ 400 or this interpretation is all wet */
343 unsigned binary_search: 1; /* suggest binary search (unused) */ 401 u8 binary_search: 1; /* suggest binary search (unused) */
344 unsigned internal: 1; /* 1 -> (internal) tree of anodes 402 u8 internal: 1; /* 1 -> (internal) tree of anodes
345 0 -> (leaf) list of extents */ 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
410 main ea bootage pointer ea_secno */
411 /* also can get set in fnodes, which
412 may be a chkdsk glitch or may mean
413 this bit is irrelevant in fnodes,
414 or this interpretation is all wet */
415 u8 flag1234: 4;
416 u8 hbff: 1; /* high bit of first free entry offset */
417#endif
346 u8 fill[3]; 418 u8 fill[3];
347 u8 n_free_nodes; /* free nodes in following array */ 419 u8 n_free_nodes; /* free nodes in following array */
348 u8 n_used_nodes; /* used nodes in following array */ 420 u8 n_used_nodes; /* used nodes in following array */
@@ -379,23 +451,25 @@ struct fnode
379 secno ea_secno; /* first sector of disk-resident ea's*/ 451 secno ea_secno; /* first sector of disk-resident ea's*/
380 u16 ea_size_s; /* length of fnode-resident ea's */ 452 u16 ea_size_s; /* length of fnode-resident ea's */
381 453
382 unsigned flag0: 1; 454#ifdef __LITTLE_ENDIAN
383 unsigned ea_anode: 1; /* 1 -> ea_secno is an anode */ 455 u8 flag0: 1;
384 unsigned flag2: 1; 456 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
385 unsigned flag3: 1; 457 u8 flag234567: 6;
386 unsigned flag4: 1; 458#else
387 unsigned flag5: 1; 459 u8 flag234567: 6;
388 unsigned flag6: 1; 460 u8 ea_anode: 1; /* 1 -> ea_secno is an anode */
389 unsigned flag7: 1; 461 u8 flag0: 1;
390 unsigned dirflag: 1; /* 1 -> directory. first & only extent 462#endif
463
464#ifdef __LITTLE_ENDIAN
465 u8 dirflag: 1; /* 1 -> 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
391 points to dnode. */ 471 points to dnode. */
392 unsigned flag9: 1; 472#endif
393 unsigned flag10: 1;
394 unsigned flag11: 1;
395 unsigned flag12: 1;
396 unsigned flag13: 1;
397 unsigned flag14: 1;
398 unsigned flag15: 1;
399 473
400 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ 474 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */
401 union { 475 union {
@@ -456,16 +530,21 @@ struct anode
456 530
457struct extended_attribute 531struct extended_attribute
458{ 532{
459 unsigned indirect: 1; /* 1 -> value gives sector number 533#ifdef __LITTLE_ENDIAN
534 u8 indirect: 1; /* 1 -> value gives sector number
460 where real value starts */ 535 where real value starts */
461 unsigned anode: 1; /* 1 -> sector is an anode 536 u8 anode: 1; /* 1 -> sector is an anode
462 that points to fragmented value */ 537 that points to fragmented value */
463 unsigned flag2: 1; 538 u8 flag23456: 5;
464 unsigned flag3: 1; 539 u8 needea: 1; /* required ea */
465 unsigned flag4: 1; 540#else
466 unsigned flag5: 1; 541 u8 needea: 1; /* required ea */
467 unsigned flag6: 1; 542 u8 flag23456: 5;
468 unsigned needea: 1; /* required ea */ 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
469 u8 namelen; /* length of name, bytes */ 548 u8 namelen; /* length of name, bytes */
470 u16 valuelen; /* length of value, bytes */ 549 u16 valuelen; /* length of value, bytes */
471 u8 name[0]; 550 u8 name[0];
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index d10108690ed0..f99377306b13 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -84,7 +84,6 @@ struct hpfs_sb_info {
84 unsigned *sb_bmp_dir; /* main bitmap directory */ 84 unsigned *sb_bmp_dir; /* main bitmap directory */
85 unsigned sb_c_bitmap; /* current bitmap */ 85 unsigned sb_c_bitmap; /* current bitmap */
86 unsigned sb_max_fwd_alloc; /* max forwad allocation */ 86 unsigned sb_max_fwd_alloc; /* max forwad allocation */
87 /*unsigned sb_mounting : 1;*/
88 int sb_timeshift; 87 int sb_timeshift;
89}; 88};
90 89
@@ -100,7 +99,7 @@ struct quad_buffer_head {
100static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) 99static inline dnode_secno de_down_pointer (struct hpfs_dirent *de)
101{ 100{
102 CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); 101 CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n"));
103 return *(dnode_secno *) ((void *) de + de->length - 4); 102 return le32_to_cpu(*(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4));
104} 103}
105 104
106/* The first dir entry in a dnode */ 105/* The first dir entry in a dnode */
@@ -114,41 +113,41 @@ static inline struct hpfs_dirent *dnode_first_de (struct dnode *dnode)
114 113
115static inline struct hpfs_dirent *dnode_end_de (struct dnode *dnode) 114static inline struct hpfs_dirent *dnode_end_de (struct dnode *dnode)
116{ 115{
117 CHKCOND(dnode->first_free>=0x14 && dnode->first_free<=0xa00,("HPFS: dnode_end_de: dnode->first_free = %d\n",(int)dnode->first_free)); 116 CHKCOND(le32_to_cpu(dnode->first_free)>=0x14 && le32_to_cpu(dnode->first_free)<=0xa00,("HPFS: dnode_end_de: dnode->first_free = %x\n",(unsigned)le32_to_cpu(dnode->first_free)));
118 return (void *) dnode + dnode->first_free; 117 return (void *) dnode + le32_to_cpu(dnode->first_free);
119} 118}
120 119
121/* The dir entry after dir entry de */ 120/* The dir entry after dir entry de */
122 121
123static inline struct hpfs_dirent *de_next_de (struct hpfs_dirent *de) 122static inline struct hpfs_dirent *de_next_de (struct hpfs_dirent *de)
124{ 123{
125 CHKCOND(de->length>=0x20 && de->length<0x800,("HPFS: de_next_de: de->length = %d\n",(int)de->length)); 124 CHKCOND(le16_to_cpu(de->length)>=0x20 && le16_to_cpu(de->length)<0x800,("HPFS: de_next_de: de->length = %x\n",(unsigned)le16_to_cpu(de->length)));
126 return (void *) de + de->length; 125 return (void *) de + le16_to_cpu(de->length);
127} 126}
128 127
129static inline struct extended_attribute *fnode_ea(struct fnode *fnode) 128static inline struct extended_attribute *fnode_ea(struct fnode *fnode)
130{ 129{
131 return (struct extended_attribute *)((char *)fnode + fnode->ea_offs + fnode->acl_size_s); 130 return (struct extended_attribute *)((char *)fnode + le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s));
132} 131}
133 132
134static inline struct extended_attribute *fnode_end_ea(struct fnode *fnode) 133static inline struct extended_attribute *fnode_end_ea(struct fnode *fnode)
135{ 134{
136 return (struct extended_attribute *)((char *)fnode + fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s); 135 return (struct extended_attribute *)((char *)fnode + le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s));
137} 136}
138 137
139static inline struct extended_attribute *next_ea(struct extended_attribute *ea) 138static inline struct extended_attribute *next_ea(struct extended_attribute *ea)
140{ 139{
141 return (struct extended_attribute *)((char *)ea + 5 + ea->namelen + ea->valuelen); 140 return (struct extended_attribute *)((char *)ea + 5 + ea->namelen + le16_to_cpu(ea->valuelen));
142} 141}
143 142
144static inline secno ea_sec(struct extended_attribute *ea) 143static inline secno ea_sec(struct extended_attribute *ea)
145{ 144{
146 return *(secno *)((char *)ea + 9 + ea->namelen); 145 return le32_to_cpu(*((secno *)((char *)ea + 9 + ea->namelen)));
147} 146}
148 147
149static inline secno ea_len(struct extended_attribute *ea) 148static inline secno ea_len(struct extended_attribute *ea)
150{ 149{
151 return *(secno *)((char *)ea + 5 + ea->namelen); 150 return le32_to_cpu(*((secno *)((char *)ea + 5 + ea->namelen)));
152} 151}
153 152
154static inline char *ea_data(struct extended_attribute *ea) 153static inline char *ea_data(struct extended_attribute *ea)
@@ -173,13 +172,13 @@ static inline void copy_de(struct hpfs_dirent *dst, struct hpfs_dirent *src)
173 dst->not_8x3 = n; 172 dst->not_8x3 = n;
174} 173}
175 174
176static inline unsigned tstbits(unsigned *bmp, unsigned b, unsigned n) 175static inline unsigned tstbits(u32 *bmp, unsigned b, unsigned n)
177{ 176{
178 int i; 177 int i;
179 if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; 178 if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n;
180 if (!((bmp[(b & 0x3fff) >> 5] >> (b & 0x1f)) & 1)) return 1; 179 if (!((le32_to_cpu(bmp[(b & 0x3fff) >> 5]) >> (b & 0x1f)) & 1)) return 1;
181 for (i = 1; i < n; i++) 180 for (i = 1; i < n; i++)
182 if (/*b+i < 0x4000 &&*/ !((bmp[((b+i) & 0x3fff) >> 5] >> ((b+i) & 0x1f)) & 1)) 181 if (!((le32_to_cpu(bmp[((b+i) & 0x3fff) >> 5]) >> ((b+i) & 0x1f)) & 1))
183 return i + 1; 182 return i + 1;
184 return 0; 183 return 0;
185} 184}
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index bc61bb4fd38d..338cd8368451 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -115,8 +115,8 @@ void hpfs_read_inode(struct inode *i)
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;
117 i->i_fop = &hpfs_dir_ops; 117 i->i_fop = &hpfs_dir_ops;
118 hpfs_inode->i_parent_dir = fnode->up; 118 hpfs_inode->i_parent_dir = le32_to_cpu(fnode->up);
119 hpfs_inode->i_dno = fnode->u.external[0].disk_secno; 119 hpfs_inode->i_dno = le32_to_cpu(fnode->u.external[0].disk_secno);
120 if (hpfs_sb(sb)->sb_chk >= 2) { 120 if (hpfs_sb(sb)->sb_chk >= 2) {
121 struct buffer_head *bh0; 121 struct buffer_head *bh0;
122 if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0); 122 if (hpfs_map_fnode(sb, hpfs_inode->i_parent_dir, &bh0)) brelse(bh0);
@@ -132,7 +132,7 @@ void hpfs_read_inode(struct inode *i)
132 i->i_op = &hpfs_file_iops; 132 i->i_op = &hpfs_file_iops;
133 i->i_fop = &hpfs_file_ops; 133 i->i_fop = &hpfs_file_ops;
134 i->i_nlink = 1; 134 i->i_nlink = 1;
135 i->i_size = fnode->file_size; 135 i->i_size = le32_to_cpu(fnode->file_size);
136 i->i_blocks = ((i->i_size + 511) >> 9) + 1; 136 i->i_blocks = ((i->i_size + 511) >> 9) + 1;
137 i->i_data.a_ops = &hpfs_aops; 137 i->i_data.a_ops = &hpfs_aops;
138 hpfs_i(i)->mmu_private = i->i_size; 138 hpfs_i(i)->mmu_private = i->i_size;
@@ -143,7 +143,7 @@ void hpfs_read_inode(struct inode *i)
143static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode) 143static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
144{ 144{
145 struct hpfs_inode_info *hpfs_inode = hpfs_i(i); 145 struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
146 /*if (fnode->acl_size_l || fnode->acl_size_s) { 146 /*if (le32_to_cpu(fnode->acl_size_l) || le16_to_cpu(fnode->acl_size_s)) {
147 Some unknown structures like ACL may be in fnode, 147 Some unknown structures like ACL may be in fnode,
148 we'd better not overwrite them 148 we'd better not overwrite them
149 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); 149 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
@@ -218,30 +218,30 @@ void hpfs_write_inode_nolock(struct inode *i)
218 } 218 }
219 } else de = NULL; 219 } else de = NULL;
220 if (S_ISREG(i->i_mode)) { 220 if (S_ISREG(i->i_mode)) {
221 fnode->file_size = i->i_size; 221 fnode->file_size = cpu_to_le32(i->i_size);
222 if (de) de->file_size = i->i_size; 222 if (de) de->file_size = cpu_to_le32(i->i_size);
223 } else if (S_ISDIR(i->i_mode)) { 223 } else if (S_ISDIR(i->i_mode)) {
224 fnode->file_size = 0; 224 fnode->file_size = cpu_to_le32(0);
225 if (de) de->file_size = 0; 225 if (de) de->file_size = cpu_to_le32(0);
226 } 226 }
227 hpfs_write_inode_ea(i, fnode); 227 hpfs_write_inode_ea(i, fnode);
228 if (de) { 228 if (de) {
229 de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); 229 de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
230 de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); 230 de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
231 de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); 231 de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
232 de->read_only = !(i->i_mode & 0222); 232 de->read_only = !(i->i_mode & 0222);
233 de->ea_size = hpfs_inode->i_ea_size; 233 de->ea_size = cpu_to_le32(hpfs_inode->i_ea_size);
234 hpfs_mark_4buffers_dirty(&qbh); 234 hpfs_mark_4buffers_dirty(&qbh);
235 hpfs_brelse4(&qbh); 235 hpfs_brelse4(&qbh);
236 } 236 }
237 if (S_ISDIR(i->i_mode)) { 237 if (S_ISDIR(i->i_mode)) {
238 if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) { 238 if ((de = map_dirent(i, hpfs_inode->i_dno, "\001\001", 2, NULL, &qbh))) {
239 de->write_date = gmt_to_local(i->i_sb, i->i_mtime.tv_sec); 239 de->write_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_mtime.tv_sec));
240 de->read_date = gmt_to_local(i->i_sb, i->i_atime.tv_sec); 240 de->read_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_atime.tv_sec));
241 de->creation_date = gmt_to_local(i->i_sb, i->i_ctime.tv_sec); 241 de->creation_date = cpu_to_le32(gmt_to_local(i->i_sb, i->i_ctime.tv_sec));
242 de->read_only = !(i->i_mode & 0222); 242 de->read_only = !(i->i_mode & 0222);
243 de->ea_size = /*hpfs_inode->i_ea_size*/0; 243 de->ea_size = cpu_to_le32(/*hpfs_inode->i_ea_size*/0);
244 de->file_size = 0; 244 de->file_size = cpu_to_le32(0);
245 hpfs_mark_4buffers_dirty(&qbh); 245 hpfs_mark_4buffers_dirty(&qbh);
246 hpfs_brelse4(&qbh); 246 hpfs_brelse4(&qbh);
247 } else 247 } else
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index 840d033ecee8..a790821366a7 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -21,7 +21,7 @@ unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block,
21 hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); 21 hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id);
22 return NULL; 22 return NULL;
23 } 23 }
24 sec = hpfs_sb(s)->sb_bmp_dir[bmp_block]; 24 sec = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block]);
25 if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) { 25 if (!sec || sec > hpfs_sb(s)->sb_fs_size-4) {
26 hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); 26 hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id);
27 return NULL; 27 return NULL;
@@ -46,18 +46,18 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps)
46 struct code_page_data *cpd; 46 struct code_page_data *cpd;
47 struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0); 47 struct code_page_directory *cp = hpfs_map_sector(s, cps, &bh, 0);
48 if (!cp) return NULL; 48 if (!cp) return NULL;
49 if (cp->magic != CP_DIR_MAGIC) { 49 if (le32_to_cpu(cp->magic) != CP_DIR_MAGIC) {
50 printk("HPFS: Code page directory magic doesn't match (magic = %08x)\n", cp->magic); 50 printk("HPFS: Code page directory magic doesn't match (magic = %08x)\n", le32_to_cpu(cp->magic));
51 brelse(bh); 51 brelse(bh);
52 return NULL; 52 return NULL;
53 } 53 }
54 if (!cp->n_code_pages) { 54 if (!le32_to_cpu(cp->n_code_pages)) {
55 printk("HPFS: n_code_pages == 0\n"); 55 printk("HPFS: n_code_pages == 0\n");
56 brelse(bh); 56 brelse(bh);
57 return NULL; 57 return NULL;
58 } 58 }
59 cpds = cp->array[0].code_page_data; 59 cpds = le32_to_cpu(cp->array[0].code_page_data);
60 cpi = cp->array[0].index; 60 cpi = le16_to_cpu(cp->array[0].index);
61 brelse(bh); 61 brelse(bh);
62 62
63 if (cpi >= 3) { 63 if (cpi >= 3) {
@@ -66,12 +66,12 @@ unsigned char *hpfs_load_code_page(struct super_block *s, secno cps)
66 } 66 }
67 67
68 if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL; 68 if (!(cpd = hpfs_map_sector(s, cpds, &bh, 0))) return NULL;
69 if ((unsigned)cpd->offs[cpi] > 0x178) { 69 if (le16_to_cpu(cpd->offs[cpi]) > 0x178) {
70 printk("HPFS: Code page index out of sector\n"); 70 printk("HPFS: Code page index out of sector\n");
71 brelse(bh); 71 brelse(bh);
72 return NULL; 72 return NULL;
73 } 73 }
74 ptr = (unsigned char *)cpd + cpd->offs[cpi] + 6; 74 ptr = (unsigned char *)cpd + le16_to_cpu(cpd->offs[cpi]) + 6;
75 if (!(cp_table = kmalloc(256, GFP_KERNEL))) { 75 if (!(cp_table = kmalloc(256, GFP_KERNEL))) {
76 printk("HPFS: out of memory for code page table\n"); 76 printk("HPFS: out of memory for code page table\n");
77 brelse(bh); 77 brelse(bh);
@@ -125,7 +125,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
125 if (hpfs_sb(s)->sb_chk) { 125 if (hpfs_sb(s)->sb_chk) {
126 struct extended_attribute *ea; 126 struct extended_attribute *ea;
127 struct extended_attribute *ea_end; 127 struct extended_attribute *ea_end;
128 if (fnode->magic != FNODE_MAGIC) { 128 if (le32_to_cpu(fnode->magic) != FNODE_MAGIC) {
129 hpfs_error(s, "bad magic on fnode %08lx", 129 hpfs_error(s, "bad magic on fnode %08lx",
130 (unsigned long)ino); 130 (unsigned long)ino);
131 goto bail; 131 goto bail;
@@ -138,7 +138,7 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
138 (unsigned long)ino); 138 (unsigned long)ino);
139 goto bail; 139 goto bail;
140 } 140 }
141 if (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 * (fnode->btree.internal ? 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",
@@ -146,12 +146,12 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
146 goto bail; 146 goto bail;
147 } 147 }
148 } 148 }
149 if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 || 149 if (le16_to_cpu(fnode->ea_size_s) && (le16_to_cpu(fnode->ea_offs) < 0xc4 ||
150 (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) { 150 le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200)) {
151 hpfs_error(s, 151 hpfs_error(s,
152 "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x", 152 "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x",
153 (unsigned long)ino, 153 (unsigned long)ino,
154 fnode->ea_offs, fnode->ea_size_s); 154 le16_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s));
155 goto bail; 155 goto bail;
156 } 156 }
157 ea = fnode_ea(fnode); 157 ea = fnode_ea(fnode);
@@ -178,16 +178,20 @@ struct anode *hpfs_map_anode(struct super_block *s, anode_secno ano, struct buff
178 if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL; 178 if (hpfs_sb(s)->sb_chk) if (hpfs_chk_sectors(s, ano, 1, "anode")) return NULL;
179 if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD))) 179 if ((anode = hpfs_map_sector(s, ano, bhp, ANODE_RD_AHEAD)))
180 if (hpfs_sb(s)->sb_chk) { 180 if (hpfs_sb(s)->sb_chk) {
181 if (anode->magic != ANODE_MAGIC || anode->self != ano) { 181 if (le32_to_cpu(anode->magic) != ANODE_MAGIC) {
182 hpfs_error(s, "bad magic on anode %08x", ano); 182 hpfs_error(s, "bad magic on anode %08x", ano);
183 goto bail; 183 goto bail;
184 } 184 }
185 if (le32_to_cpu(anode->self) != ano) {
186 hpfs_error(s, "self pointer invalid on anode %08x", ano);
187 goto bail;
188 }
185 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 !=
186 (anode->btree.internal ? 60 : 40)) { 190 (anode->btree.internal ? 60 : 40)) {
187 hpfs_error(s, "bad number of nodes in anode %08x", ano); 191 hpfs_error(s, "bad number of nodes in anode %08x", ano);
188 goto bail; 192 goto bail;
189 } 193 }
190 if (anode->btree.first_free != 194 if (le16_to_cpu(anode->btree.first_free) !=
191 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) { 195 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) {
192 hpfs_error(s, "bad first_free pointer in anode %08x", ano); 196 hpfs_error(s, "bad first_free pointer in anode %08x", ano);
193 goto bail; 197 goto bail;
@@ -219,26 +223,26 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno,
219 unsigned p, pp = 0; 223 unsigned p, pp = 0;
220 unsigned char *d = (unsigned char *)dnode; 224 unsigned char *d = (unsigned char *)dnode;
221 int b = 0; 225 int b = 0;
222 if (dnode->magic != DNODE_MAGIC) { 226 if (le32_to_cpu(dnode->magic) != DNODE_MAGIC) {
223 hpfs_error(s, "bad magic on dnode %08x", secno); 227 hpfs_error(s, "bad magic on dnode %08x", secno);
224 goto bail; 228 goto bail;
225 } 229 }
226 if (dnode->self != secno) 230 if (le32_to_cpu(dnode->self) != secno)
227 hpfs_error(s, "bad self pointer on dnode %08x self = %08x", secno, dnode->self); 231 hpfs_error(s, "bad self pointer on dnode %08x self = %08x", secno, le32_to_cpu(dnode->self));
228 /* Check dirents - bad dirents would cause infinite 232 /* Check dirents - bad dirents would cause infinite
229 loops or shooting to memory */ 233 loops or shooting to memory */
230 if (dnode->first_free > 2048/* || dnode->first_free < 84*/) { 234 if (le32_to_cpu(dnode->first_free) > 2048) {
231 hpfs_error(s, "dnode %08x has first_free == %08x", secno, dnode->first_free); 235 hpfs_error(s, "dnode %08x has first_free == %08x", secno, le32_to_cpu(dnode->first_free));
232 goto bail; 236 goto bail;
233 } 237 }
234 for (p = 20; p < dnode->first_free; p += d[p] + (d[p+1] << 8)) { 238 for (p = 20; p < le32_to_cpu(dnode->first_free); p += d[p] + (d[p+1] << 8)) {
235 struct hpfs_dirent *de = (struct hpfs_dirent *)((char *)dnode + p); 239 struct hpfs_dirent *de = (struct hpfs_dirent *)((char *)dnode + p);
236 if (de->length > 292 || (de->length < 32) || (de->length & 3) || p + de->length > 2048) { 240 if (le16_to_cpu(de->length) > 292 || (le16_to_cpu(de->length) < 32) || (le16_to_cpu(de->length) & 3) || p + le16_to_cpu(de->length) > 2048) {
237 hpfs_error(s, "bad dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); 241 hpfs_error(s, "bad dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp);
238 goto bail; 242 goto bail;
239 } 243 }
240 if (((31 + de->namelen + de->down*4 + 3) & ~3) != de->length) { 244 if (((31 + de->namelen + de->down*4 + 3) & ~3) != le16_to_cpu(de->length)) {
241 if (((31 + de->namelen + de->down*4 + 3) & ~3) < de->length && s->s_flags & MS_RDONLY) goto ok; 245 if (((31 + de->namelen + de->down*4 + 3) & ~3) < le16_to_cpu(de->length) && s->s_flags & MS_RDONLY) goto ok;
242 hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp); 246 hpfs_error(s, "namelen does not match dirent size in dnode %08x, dirent %03x, last %03x", secno, p, pp);
243 goto bail; 247 goto bail;
244 } 248 }
@@ -251,7 +255,7 @@ struct dnode *hpfs_map_dnode(struct super_block *s, unsigned secno,
251 pp = p; 255 pp = p;
252 256
253 } 257 }
254 if (p != dnode->first_free) { 258 if (p != le32_to_cpu(dnode->first_free)) {
255 hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno); 259 hpfs_error(s, "size on last dirent does not match first_free; dnode %08x", secno);
256 goto bail; 260 goto bail;
257 } 261 }
@@ -277,7 +281,7 @@ dnode_secno hpfs_fnode_dno(struct super_block *s, ino_t ino)
277 if (!fnode) 281 if (!fnode)
278 return 0; 282 return 0;
279 283
280 dno = fnode->u.external[0].disk_secno; 284 dno = le32_to_cpu(fnode->u.external[0].disk_secno);
281 brelse(bh); 285 brelse(bh);
282 return dno; 286 return dno;
283} 287}
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 9c66f0ec8f8e..5a8de6a28e61 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -37,8 +37,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
37 if (!(mode & 0222)) dee.read_only = 1; 37 if (!(mode & 0222)) dee.read_only = 1;
38 /*dee.archive = 0;*/ 38 /*dee.archive = 0;*/
39 dee.hidden = name[0] == '.'; 39 dee.hidden = name[0] == '.';
40 dee.fnode = fno; 40 dee.fnode = cpu_to_le32(fno);
41 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 41 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
42 result = new_inode(dir->i_sb); 42 result = new_inode(dir->i_sb);
43 if (!result) 43 if (!result)
44 goto bail2; 44 goto bail2;
@@ -46,7 +46,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
46 result->i_ino = fno; 46 result->i_ino = fno;
47 hpfs_i(result)->i_parent_dir = dir->i_ino; 47 hpfs_i(result)->i_parent_dir = dir->i_ino;
48 hpfs_i(result)->i_dno = dno; 48 hpfs_i(result)->i_dno = dno;
49 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 49 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
50 result->i_ctime.tv_nsec = 0; 50 result->i_ctime.tv_nsec = 0;
51 result->i_mtime.tv_nsec = 0; 51 result->i_mtime.tv_nsec = 0;
52 result->i_atime.tv_nsec = 0; 52 result->i_atime.tv_nsec = 0;
@@ -69,21 +69,21 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
69 } 69 }
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 = dir->i_ino; 72 fnode->up = cpu_to_le32(dir->i_ino);
73 fnode->dirflag = 1; 73 fnode->dirflag = 1;
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 = 0x14; 76 fnode->btree.first_free = cpu_to_le16(0x14);
77 fnode->u.external[0].disk_secno = dno; 77 fnode->u.external[0].disk_secno = cpu_to_le32(dno);
78 fnode->u.external[0].file_secno = -1; 78 fnode->u.external[0].file_secno = cpu_to_le32(-1);
79 dnode->root_dnode = 1; 79 dnode->root_dnode = 1;
80 dnode->up = fno; 80 dnode->up = cpu_to_le32(fno);
81 de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0); 81 de = hpfs_add_de(dir->i_sb, dnode, "\001\001", 2, 0);
82 de->creation_date = de->write_date = de->read_date = gmt_to_local(dir->i_sb, get_seconds()); 82 de->creation_date = de->write_date = de->read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
83 if (!(mode & 0222)) de->read_only = 1; 83 if (!(mode & 0222)) de->read_only = 1;
84 de->first = de->directory = 1; 84 de->first = de->directory = 1;
85 /*de->hidden = de->system = 0;*/ 85 /*de->hidden = de->system = 0;*/
86 de->fnode = fno; 86 de->fnode = cpu_to_le32(fno);
87 mark_buffer_dirty(bh); 87 mark_buffer_dirty(bh);
88 brelse(bh); 88 brelse(bh);
89 hpfs_mark_4buffers_dirty(&qbh0); 89 hpfs_mark_4buffers_dirty(&qbh0);
@@ -137,8 +137,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
137 if (!(mode & 0222)) dee.read_only = 1; 137 if (!(mode & 0222)) dee.read_only = 1;
138 dee.archive = 1; 138 dee.archive = 1;
139 dee.hidden = name[0] == '.'; 139 dee.hidden = name[0] == '.';
140 dee.fnode = fno; 140 dee.fnode = cpu_to_le32(fno);
141 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 141 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
142 142
143 result = new_inode(dir->i_sb); 143 result = new_inode(dir->i_sb);
144 if (!result) 144 if (!result)
@@ -152,7 +152,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
152 result->i_fop = &hpfs_file_ops; 152 result->i_fop = &hpfs_file_ops;
153 result->i_nlink = 1; 153 result->i_nlink = 1;
154 hpfs_i(result)->i_parent_dir = dir->i_ino; 154 hpfs_i(result)->i_parent_dir = dir->i_ino;
155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
156 result->i_ctime.tv_nsec = 0; 156 result->i_ctime.tv_nsec = 0;
157 result->i_mtime.tv_nsec = 0; 157 result->i_mtime.tv_nsec = 0;
158 result->i_atime.tv_nsec = 0; 158 result->i_atime.tv_nsec = 0;
@@ -173,7 +173,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
173 } 173 }
174 fnode->len = len; 174 fnode->len = len;
175 memcpy(fnode->name, name, len > 15 ? 15 : len); 175 memcpy(fnode->name, name, len > 15 ? 15 : len);
176 fnode->up = dir->i_ino; 176 fnode->up = cpu_to_le32(dir->i_ino);
177 mark_buffer_dirty(bh); 177 mark_buffer_dirty(bh);
178 brelse(bh); 178 brelse(bh);
179 179
@@ -225,8 +225,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
225 if (!(mode & 0222)) dee.read_only = 1; 225 if (!(mode & 0222)) dee.read_only = 1;
226 dee.archive = 1; 226 dee.archive = 1;
227 dee.hidden = name[0] == '.'; 227 dee.hidden = name[0] == '.';
228 dee.fnode = fno; 228 dee.fnode = cpu_to_le32(fno);
229 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 229 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
230 230
231 result = new_inode(dir->i_sb); 231 result = new_inode(dir->i_sb);
232 if (!result) 232 if (!result)
@@ -235,7 +235,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
235 hpfs_init_inode(result); 235 hpfs_init_inode(result);
236 result->i_ino = fno; 236 result->i_ino = fno;
237 hpfs_i(result)->i_parent_dir = dir->i_ino; 237 hpfs_i(result)->i_parent_dir = dir->i_ino;
238 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 238 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
239 result->i_ctime.tv_nsec = 0; 239 result->i_ctime.tv_nsec = 0;
240 result->i_mtime.tv_nsec = 0; 240 result->i_mtime.tv_nsec = 0;
241 result->i_atime.tv_nsec = 0; 241 result->i_atime.tv_nsec = 0;
@@ -256,7 +256,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
256 } 256 }
257 fnode->len = len; 257 fnode->len = len;
258 memcpy(fnode->name, name, len > 15 ? 15 : len); 258 memcpy(fnode->name, name, len > 15 ? 15 : len);
259 fnode->up = dir->i_ino; 259 fnode->up = cpu_to_le32(dir->i_ino);
260 mark_buffer_dirty(bh); 260 mark_buffer_dirty(bh);
261 261
262 insert_inode_hash(result); 262 insert_inode_hash(result);
@@ -300,8 +300,8 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
300 memset(&dee, 0, sizeof dee); 300 memset(&dee, 0, sizeof dee);
301 dee.archive = 1; 301 dee.archive = 1;
302 dee.hidden = name[0] == '.'; 302 dee.hidden = name[0] == '.';
303 dee.fnode = fno; 303 dee.fnode = cpu_to_le32(fno);
304 dee.creation_date = dee.write_date = dee.read_date = gmt_to_local(dir->i_sb, get_seconds()); 304 dee.creation_date = dee.write_date = dee.read_date = cpu_to_le32(gmt_to_local(dir->i_sb, get_seconds()));
305 305
306 result = new_inode(dir->i_sb); 306 result = new_inode(dir->i_sb);
307 if (!result) 307 if (!result)
@@ -309,7 +309,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
309 result->i_ino = fno; 309 result->i_ino = fno;
310 hpfs_init_inode(result); 310 hpfs_init_inode(result);
311 hpfs_i(result)->i_parent_dir = dir->i_ino; 311 hpfs_i(result)->i_parent_dir = dir->i_ino;
312 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); 312 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
313 result->i_ctime.tv_nsec = 0; 313 result->i_ctime.tv_nsec = 0;
314 result->i_mtime.tv_nsec = 0; 314 result->i_mtime.tv_nsec = 0;
315 result->i_atime.tv_nsec = 0; 315 result->i_atime.tv_nsec = 0;
@@ -332,7 +332,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
332 } 332 }
333 fnode->len = len; 333 fnode->len = len;
334 memcpy(fnode->name, name, len > 15 ? 15 : len); 334 memcpy(fnode->name, name, len > 15 ? 15 : len);
335 fnode->up = dir->i_ino; 335 fnode->up = cpu_to_le32(dir->i_ino);
336 hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink)); 336 hpfs_set_ea(result, fnode, "SYMLINK", symlink, strlen(symlink));
337 mark_buffer_dirty(bh); 337 mark_buffer_dirty(bh);
338 brelse(bh); 338 brelse(bh);
@@ -382,7 +382,7 @@ again:
382 if (de->directory) 382 if (de->directory)
383 goto out1; 383 goto out1;
384 384
385 fno = de->fnode; 385 fno = le32_to_cpu(de->fnode);
386 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); 386 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
387 switch (r) { 387 switch (r) {
388 case 1: 388 case 1:
@@ -465,7 +465,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
465 if (n_items) 465 if (n_items)
466 goto out1; 466 goto out1;
467 467
468 fno = de->fnode; 468 fno = le32_to_cpu(de->fnode);
469 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1); 469 r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
470 switch (r) { 470 switch (r) {
471 case 1: 471 case 1:
@@ -608,7 +608,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
608 drop_nlink(old_dir); 608 drop_nlink(old_dir);
609 } 609 }
610 if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) { 610 if ((fnode = hpfs_map_fnode(i->i_sb, i->i_ino, &bh))) {
611 fnode->up = new_dir->i_ino; 611 fnode->up = cpu_to_le32(new_dir->i_ino);
612 fnode->len = new_len; 612 fnode->len = new_len;
613 memcpy(fnode->name, new_name, new_len>15?15:new_len); 613 memcpy(fnode->name, new_name, new_len>15?15:new_len);
614 if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len); 614 if (new_len < 15) memset(&fnode->name[new_len], 0, 15 - new_len);
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 4a7d0266342b..98580a3b5005 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -135,7 +135,7 @@ static unsigned count_bitmaps(struct super_block *s)
135 n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; 135 n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14;
136 count = 0; 136 count = 0;
137 for (n = 0; n < n_bands; n++) 137 for (n = 0; n < n_bands; n++)
138 count += hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_bmp_dir[n]); 138 count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n]));
139 return count; 139 return count;
140} 140}
141 141
@@ -509,9 +509,9 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
509 if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3; 509 if (!(spareblock = hpfs_map_sector(s, 17, &bh2, 0))) goto bail3;
510 510
511 /* Check magics */ 511 /* Check magics */
512 if (/*bootblock->magic != BB_MAGIC 512 if (/*le16_to_cpu(bootblock->magic) != BB_MAGIC
513 ||*/ superblock->magic != SB_MAGIC 513 ||*/ le32_to_cpu(superblock->magic) != SB_MAGIC
514 || spareblock->magic != SP_MAGIC) { 514 || le32_to_cpu(spareblock->magic) != SP_MAGIC) {
515 if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n"); 515 if (!silent) printk("HPFS: Bad magic ... probably not HPFS\n");
516 goto bail4; 516 goto bail4;
517 } 517 }
@@ -532,12 +532,12 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
532 s->s_op = &hpfs_sops; 532 s->s_op = &hpfs_sops;
533 s->s_d_op = &hpfs_dentry_operations; 533 s->s_d_op = &hpfs_dentry_operations;
534 534
535 sbi->sb_root = superblock->root; 535 sbi->sb_root = le32_to_cpu(superblock->root);
536 sbi->sb_fs_size = superblock->n_sectors; 536 sbi->sb_fs_size = le32_to_cpu(superblock->n_sectors);
537 sbi->sb_bitmaps = superblock->bitmaps; 537 sbi->sb_bitmaps = le32_to_cpu(superblock->bitmaps);
538 sbi->sb_dirband_start = superblock->dir_band_start; 538 sbi->sb_dirband_start = le32_to_cpu(superblock->dir_band_start);
539 sbi->sb_dirband_size = superblock->n_dir_band; 539 sbi->sb_dirband_size = le32_to_cpu(superblock->n_dir_band);
540 sbi->sb_dmap = superblock->dir_band_bitmap; 540 sbi->sb_dmap = le32_to_cpu(superblock->dir_band_bitmap);
541 sbi->sb_uid = uid; 541 sbi->sb_uid = uid;
542 sbi->sb_gid = gid; 542 sbi->sb_gid = gid;
543 sbi->sb_mode = 0777 & ~umask; 543 sbi->sb_mode = 0777 & ~umask;
@@ -555,7 +555,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
555 sbi->sb_max_fwd_alloc = 0xffffff; 555 sbi->sb_max_fwd_alloc = 0xffffff;
556 556
557 /* Load bitmap directory */ 557 /* Load bitmap directory */
558 if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, superblock->bitmaps))) 558 if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps))))
559 goto bail4; 559 goto bail4;
560 560
561 /* Check for general fs errors*/ 561 /* Check for general fs errors*/
@@ -573,7 +573,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
573 mark_buffer_dirty(bh2); 573 mark_buffer_dirty(bh2);
574 } 574 }
575 575
576 if (spareblock->hotfixes_used || spareblock->n_spares_used) { 576 if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) {
577 if (errs >= 2) { 577 if (errs >= 2) {
578 printk("HPFS: Hotfixes not supported here, try chkdsk\n"); 578 printk("HPFS: Hotfixes not supported here, try chkdsk\n");
579 mark_dirty(s, 0); 579 mark_dirty(s, 0);
@@ -583,7 +583,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
583 if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n"); 583 if (errs == 0) printk("HPFS: Proceeding, but your filesystem will be probably corrupted by this driver...\n");
584 else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n"); 584 else printk("HPFS: This driver may read bad files or crash when operating on disk with hotfixes.\n");
585 } 585 }
586 if (spareblock->n_dnode_spares != spareblock->n_dnode_spares_free) { 586 if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) {
587 if (errs >= 2) { 587 if (errs >= 2) {
588 printk("HPFS: Spare dnodes used, try chkdsk\n"); 588 printk("HPFS: Spare dnodes used, try chkdsk\n");
589 mark_dirty(s, 0); 589 mark_dirty(s, 0);
@@ -594,17 +594,17 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
594 } 594 }
595 if (chk) { 595 if (chk) {
596 unsigned a; 596 unsigned a;
597 if (superblock->dir_band_end - superblock->dir_band_start + 1 != superblock->n_dir_band || 597 if (le32_to_cpu(superblock->dir_band_end) - le32_to_cpu(superblock->dir_band_start) + 1 != le32_to_cpu(superblock->n_dir_band) ||
598 superblock->dir_band_end < superblock->dir_band_start || superblock->n_dir_band > 0x4000) { 598 le32_to_cpu(superblock->dir_band_end) < le32_to_cpu(superblock->dir_band_start) || le32_to_cpu(superblock->n_dir_band) > 0x4000) {
599 hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x", 599 hpfs_error(s, "dir band size mismatch: dir_band_start==%08x, dir_band_end==%08x, n_dir_band==%08x",
600 superblock->dir_band_start, superblock->dir_band_end, superblock->n_dir_band); 600 le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->dir_band_end), le32_to_cpu(superblock->n_dir_band));
601 goto bail4; 601 goto bail4;
602 } 602 }
603 a = sbi->sb_dirband_size; 603 a = sbi->sb_dirband_size;
604 sbi->sb_dirband_size = 0; 604 sbi->sb_dirband_size = 0;
605 if (hpfs_chk_sectors(s, superblock->dir_band_start, superblock->n_dir_band, "dir_band") || 605 if (hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_start), le32_to_cpu(superblock->n_dir_band), "dir_band") ||
606 hpfs_chk_sectors(s, superblock->dir_band_bitmap, 4, "dir_band_bitmap") || 606 hpfs_chk_sectors(s, le32_to_cpu(superblock->dir_band_bitmap), 4, "dir_band_bitmap") ||
607 hpfs_chk_sectors(s, superblock->bitmaps, 4, "bitmaps")) { 607 hpfs_chk_sectors(s, le32_to_cpu(superblock->bitmaps), 4, "bitmaps")) {
608 mark_dirty(s, 0); 608 mark_dirty(s, 0);
609 goto bail4; 609 goto bail4;
610 } 610 }
@@ -612,8 +612,8 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
612 } else printk("HPFS: You really don't want any checks? You are crazy...\n"); 612 } else printk("HPFS: You really don't want any checks? You are crazy...\n");
613 613
614 /* Load code page table */ 614 /* Load code page table */
615 if (spareblock->n_code_pages) 615 if (le32_to_cpu(spareblock->n_code_pages))
616 if (!(sbi->sb_cp_table = hpfs_load_code_page(s, spareblock->code_page_dir))) 616 if (!(sbi->sb_cp_table = hpfs_load_code_page(s, le32_to_cpu(spareblock->code_page_dir))))
617 printk("HPFS: Warning: code page support is disabled\n"); 617 printk("HPFS: Warning: code page support is disabled\n");
618 618
619 brelse(bh2); 619 brelse(bh2);
@@ -642,13 +642,13 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
642 if (!de) 642 if (!de)
643 hpfs_error(s, "unable to find root dir"); 643 hpfs_error(s, "unable to find root dir");
644 else { 644 else {
645 root->i_atime.tv_sec = local_to_gmt(s, de->read_date); 645 root->i_atime.tv_sec = local_to_gmt(s, le32_to_cpu(de->read_date));
646 root->i_atime.tv_nsec = 0; 646 root->i_atime.tv_nsec = 0;
647 root->i_mtime.tv_sec = local_to_gmt(s, de->write_date); 647 root->i_mtime.tv_sec = local_to_gmt(s, le32_to_cpu(de->write_date));
648 root->i_mtime.tv_nsec = 0; 648 root->i_mtime.tv_nsec = 0;
649 root->i_ctime.tv_sec = local_to_gmt(s, de->creation_date); 649 root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date));
650 root->i_ctime.tv_nsec = 0; 650 root->i_ctime.tv_nsec = 0;
651 hpfs_i(root)->i_ea_size = de->ea_size; 651 hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size);
652 hpfs_i(root)->i_parent_dir = root->i_ino; 652 hpfs_i(root)->i_parent_dir = root->i_ino;
653 if (root->i_size == -1) 653 if (root->i_size == -1)
654 root->i_size = 2048; 654 root->i_size = 2048;