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