diff options
Diffstat (limited to 'fs/hpfs/alloc.c')
-rw-r--r-- | fs/hpfs/alloc.c | 118 |
1 files changed, 43 insertions, 75 deletions
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 5503e2c28910..7a5eb2c718c8 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -8,8 +8,6 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | ||
12 | |||
13 | /* | 11 | /* |
14 | * Check if a sector is allocated in bitmap | 12 | * Check if a sector is allocated in bitmap |
15 | * This is really slow. Turned on only if chk==2 | 13 | * This is really slow. Turned on only if chk==2 |
@@ -18,9 +16,9 @@ static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | |||
18 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) | 16 | static int chk_if_allocated(struct super_block *s, secno sec, char *msg) |
19 | { | 17 | { |
20 | struct quad_buffer_head qbh; | 18 | struct quad_buffer_head qbh; |
21 | unsigned *bmp; | 19 | u32 *bmp; |
22 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; | 20 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; |
23 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f)) & 1) { | 21 | if ((cpu_to_le32(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { |
24 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); | 22 | hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); |
25 | goto fail1; | 23 | goto fail1; |
26 | } | 24 | } |
@@ -28,7 +26,7 @@ static int chk_if_allocated(struct super_block *s, secno sec, char *msg) | |||
28 | if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { | 26 | if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) { |
29 | unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; | 27 | unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4; |
30 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; | 28 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) goto fail; |
31 | if ((bmp[ssec >> 5] >> (ssec & 0x1f)) & 1) { | 29 | if ((le32_to_cpu(bmp[ssec >> 5]) >> (ssec & 0x1f)) & 1) { |
32 | hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); | 30 | hpfs_error(s, "sector '%s' - %08x not allocated in directory bitmap", msg, sec); |
33 | goto fail1; | 31 | goto fail1; |
34 | } | 32 | } |
@@ -75,7 +73,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
75 | hpfs_error(s, "Bad allocation size: %d", n); | 73 | hpfs_error(s, "Bad allocation size: %d", n); |
76 | return 0; | 74 | return 0; |
77 | } | 75 | } |
78 | lock_super(s); | ||
79 | if (bs != ~0x3fff) { | 76 | if (bs != ~0x3fff) { |
80 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; | 77 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; |
81 | } else { | 78 | } else { |
@@ -85,10 +82,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
85 | ret = bs + nr; | 82 | ret = bs + nr; |
86 | goto rt; | 83 | goto rt; |
87 | } | 84 | } |
88 | /*if (!tstbits(bmp, nr + n, n + forward)) { | ||
89 | ret = bs + nr + n; | ||
90 | goto rt; | ||
91 | }*/ | ||
92 | q = nr + n; b = 0; | 85 | q = nr + n; b = 0; |
93 | while ((a = tstbits(bmp, q, n + forward)) != 0) { | 86 | while ((a = tstbits(bmp, q, n + forward)) != 0) { |
94 | q += a; | 87 | q += a; |
@@ -105,14 +98,14 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
105 | goto rt; | 98 | goto rt; |
106 | } | 99 | } |
107 | nr >>= 5; | 100 | nr >>= 5; |
108 | /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) {*/ | 101 | /*for (i = nr + 1; i != nr; i++, i &= 0x1ff) */ |
109 | i = nr; | 102 | i = nr; |
110 | do { | 103 | do { |
111 | if (!bmp[i]) goto cont; | 104 | if (!le32_to_cpu(bmp[i])) goto cont; |
112 | if (n + forward >= 0x3f && bmp[i] != -1) goto cont; | 105 | if (n + forward >= 0x3f && le32_to_cpu(bmp[i]) != 0xffffffff) goto cont; |
113 | q = i<<5; | 106 | q = i<<5; |
114 | if (i > 0) { | 107 | if (i > 0) { |
115 | unsigned k = bmp[i-1]; | 108 | unsigned k = le32_to_cpu(bmp[i-1]); |
116 | while (k & 0x80000000) { | 109 | while (k & 0x80000000) { |
117 | q--; k <<= 1; | 110 | q--; k <<= 1; |
118 | } | 111 | } |
@@ -132,18 +125,17 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
132 | } while (i != nr); | 125 | } while (i != nr); |
133 | rt: | 126 | rt: |
134 | if (ret) { | 127 | if (ret) { |
135 | 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)) { |
136 | hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); | 129 | hpfs_error(s, "Allocation doesn't work! Wanted %d, allocated at %08x", n, ret); |
137 | ret = 0; | 130 | ret = 0; |
138 | goto b; | 131 | goto b; |
139 | } | 132 | } |
140 | bmp[(ret & 0x3fff) >> 5] &= ~(((1 << n) - 1) << (ret & 0x1f)); | 133 | bmp[(ret & 0x3fff) >> 5] &= cpu_to_le32(~(((1 << n) - 1) << (ret & 0x1f))); |
141 | hpfs_mark_4buffers_dirty(&qbh); | 134 | hpfs_mark_4buffers_dirty(&qbh); |
142 | } | 135 | } |
143 | b: | 136 | b: |
144 | hpfs_brelse4(&qbh); | 137 | hpfs_brelse4(&qbh); |
145 | uls: | 138 | uls: |
146 | unlock_super(s); | ||
147 | return ret; | 139 | return ret; |
148 | } | 140 | } |
149 | 141 | ||
@@ -155,7 +147,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
155 | * sectors | 147 | * sectors |
156 | */ | 148 | */ |
157 | 149 | ||
158 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward, int lock) | 150 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) |
159 | { | 151 | { |
160 | secno sec; | 152 | secno sec; |
161 | int i; | 153 | int i; |
@@ -167,7 +159,6 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
167 | forward = -forward; | 159 | forward = -forward; |
168 | f_p = 1; | 160 | f_p = 1; |
169 | } | 161 | } |
170 | if (lock) hpfs_lock_creation(s); | ||
171 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; | 162 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; |
172 | if (near && near < sbi->sb_fs_size) { | 163 | if (near && near < sbi->sb_fs_size) { |
173 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; | 164 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; |
@@ -214,18 +205,17 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
214 | ret: | 205 | ret: |
215 | if (sec && f_p) { | 206 | if (sec && f_p) { |
216 | for (i = 0; i < forward; i++) { | 207 | for (i = 0; i < forward; i++) { |
217 | if (!hpfs_alloc_if_possible_nolock(s, sec + i + 1)) { | 208 | if (!hpfs_alloc_if_possible(s, sec + i + 1)) { |
218 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); | 209 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); |
219 | sec = 0; | 210 | sec = 0; |
220 | break; | 211 | break; |
221 | } | 212 | } |
222 | } | 213 | } |
223 | } | 214 | } |
224 | if (lock) hpfs_unlock_creation(s); | ||
225 | return sec; | 215 | return sec; |
226 | } | 216 | } |
227 | 217 | ||
228 | static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | 218 | static secno alloc_in_dirband(struct super_block *s, secno near) |
229 | { | 219 | { |
230 | unsigned nr = near; | 220 | unsigned nr = near; |
231 | secno sec; | 221 | secno sec; |
@@ -236,49 +226,35 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | |||
236 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; | 226 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; |
237 | nr -= sbi->sb_dirband_start; | 227 | nr -= sbi->sb_dirband_start; |
238 | nr >>= 2; | 228 | nr >>= 2; |
239 | if (lock) hpfs_lock_creation(s); | ||
240 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); | 229 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); |
241 | if (lock) hpfs_unlock_creation(s); | ||
242 | if (!sec) return 0; | 230 | if (!sec) return 0; |
243 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; | 231 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; |
244 | } | 232 | } |
245 | 233 | ||
246 | /* Alloc sector if it's free */ | 234 | /* Alloc sector if it's free */ |
247 | 235 | ||
248 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec) | 236 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) |
249 | { | 237 | { |
250 | struct quad_buffer_head qbh; | 238 | struct quad_buffer_head qbh; |
251 | unsigned *bmp; | 239 | u32 *bmp; |
252 | lock_super(s); | ||
253 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; | 240 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; |
254 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { | 241 | if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) { |
255 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); | 242 | bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f))); |
256 | hpfs_mark_4buffers_dirty(&qbh); | 243 | hpfs_mark_4buffers_dirty(&qbh); |
257 | hpfs_brelse4(&qbh); | 244 | hpfs_brelse4(&qbh); |
258 | unlock_super(s); | ||
259 | return 1; | 245 | return 1; |
260 | } | 246 | } |
261 | hpfs_brelse4(&qbh); | 247 | hpfs_brelse4(&qbh); |
262 | end: | 248 | end: |
263 | unlock_super(s); | ||
264 | return 0; | 249 | return 0; |
265 | } | 250 | } |
266 | 251 | ||
267 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) | ||
268 | { | ||
269 | int r; | ||
270 | hpfs_lock_creation(s); | ||
271 | r = hpfs_alloc_if_possible_nolock(s, sec); | ||
272 | hpfs_unlock_creation(s); | ||
273 | return r; | ||
274 | } | ||
275 | |||
276 | /* Free sectors in bitmaps */ | 252 | /* Free sectors in bitmaps */ |
277 | 253 | ||
278 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | 254 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) |
279 | { | 255 | { |
280 | struct quad_buffer_head qbh; | 256 | struct quad_buffer_head qbh; |
281 | unsigned *bmp; | 257 | u32 *bmp; |
282 | struct hpfs_sb_info *sbi = hpfs_sb(s); | 258 | struct hpfs_sb_info *sbi = hpfs_sb(s); |
283 | /*printk("2 - ");*/ | 259 | /*printk("2 - ");*/ |
284 | if (!n) return; | 260 | if (!n) return; |
@@ -286,26 +262,22 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | |||
286 | hpfs_error(s, "Trying to free reserved sector %08x", sec); | 262 | hpfs_error(s, "Trying to free reserved sector %08x", sec); |
287 | return; | 263 | return; |
288 | } | 264 | } |
289 | lock_super(s); | ||
290 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; | 265 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; |
291 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; | 266 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; |
292 | new_map: | 267 | new_map: |
293 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { | 268 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { |
294 | unlock_super(s); | ||
295 | return; | 269 | return; |
296 | } | 270 | } |
297 | new_tst: | 271 | new_tst: |
298 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { | 272 | if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f) & 1)) { |
299 | hpfs_error(s, "sector %08x not allocated", sec); | 273 | hpfs_error(s, "sector %08x not allocated", sec); |
300 | hpfs_brelse4(&qbh); | 274 | hpfs_brelse4(&qbh); |
301 | unlock_super(s); | ||
302 | return; | 275 | return; |
303 | } | 276 | } |
304 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); | 277 | bmp[(sec & 0x3fff) >> 5] |= cpu_to_le32(1 << (sec & 0x1f)); |
305 | if (!--n) { | 278 | if (!--n) { |
306 | hpfs_mark_4buffers_dirty(&qbh); | 279 | hpfs_mark_4buffers_dirty(&qbh); |
307 | hpfs_brelse4(&qbh); | 280 | hpfs_brelse4(&qbh); |
308 | unlock_super(s); | ||
309 | return; | 281 | return; |
310 | } | 282 | } |
311 | if (!(++sec & 0x3fff)) { | 283 | if (!(++sec & 0x3fff)) { |
@@ -327,13 +299,13 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) | |||
327 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; | 299 | int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; |
328 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; | 300 | int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; |
329 | int i, j; | 301 | int i, j; |
330 | unsigned *bmp; | 302 | u32 *bmp; |
331 | struct quad_buffer_head qbh; | 303 | struct quad_buffer_head qbh; |
332 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 304 | if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
333 | for (j = 0; j < 512; j++) { | 305 | for (j = 0; j < 512; j++) { |
334 | unsigned k; | 306 | unsigned k; |
335 | if (!bmp[j]) continue; | 307 | if (!le32_to_cpu(bmp[j])) continue; |
336 | for (k = bmp[j]; k; k >>= 1) if (k & 1) if (!--n) { | 308 | for (k = le32_to_cpu(bmp[j]); k; k >>= 1) if (k & 1) if (!--n) { |
337 | hpfs_brelse4(&qbh); | 309 | hpfs_brelse4(&qbh); |
338 | return 0; | 310 | return 0; |
339 | } | 311 | } |
@@ -352,10 +324,10 @@ int hpfs_check_free_dnodes(struct super_block *s, int n) | |||
352 | chk_bmp: | 324 | chk_bmp: |
353 | if (bmp) { | 325 | if (bmp) { |
354 | for (j = 0; j < 512; j++) { | 326 | for (j = 0; j < 512; j++) { |
355 | unsigned k; | 327 | u32 k; |
356 | if (!bmp[j]) continue; | 328 | if (!le32_to_cpu(bmp[j])) continue; |
357 | for (k = 0xf; k; k <<= 4) | 329 | for (k = 0xf; k; k <<= 4) |
358 | if ((bmp[j] & k) == k) { | 330 | if ((le32_to_cpu(bmp[j]) & k) == k) { |
359 | if (!--n) { | 331 | if (!--n) { |
360 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
361 | return 0; | 333 | return 0; |
@@ -379,44 +351,40 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno) | |||
379 | hpfs_free_sectors(s, dno, 4); | 351 | hpfs_free_sectors(s, dno, 4); |
380 | } else { | 352 | } else { |
381 | struct quad_buffer_head qbh; | 353 | struct quad_buffer_head qbh; |
382 | unsigned *bmp; | 354 | u32 *bmp; |
383 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; | 355 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; |
384 | lock_super(s); | ||
385 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 356 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
386 | unlock_super(s); | ||
387 | return; | 357 | return; |
388 | } | 358 | } |
389 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); | 359 | bmp[ssec >> 5] |= cpu_to_le32(1 << (ssec & 0x1f)); |
390 | hpfs_mark_4buffers_dirty(&qbh); | 360 | hpfs_mark_4buffers_dirty(&qbh); |
391 | hpfs_brelse4(&qbh); | 361 | hpfs_brelse4(&qbh); |
392 | unlock_super(s); | ||
393 | } | 362 | } |
394 | } | 363 | } |
395 | 364 | ||
396 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, | 365 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, |
397 | dnode_secno *dno, struct quad_buffer_head *qbh, | 366 | dnode_secno *dno, struct quad_buffer_head *qbh) |
398 | int lock) | ||
399 | { | 367 | { |
400 | struct dnode *d; | 368 | struct dnode *d; |
401 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { | 369 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { |
402 | if (!(*dno = alloc_in_dirband(s, near, lock))) | 370 | if (!(*dno = alloc_in_dirband(s, near))) |
403 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; | 371 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; |
404 | } else { | 372 | } else { |
405 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) | 373 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) |
406 | if (!(*dno = alloc_in_dirband(s, near, lock))) return NULL; | 374 | if (!(*dno = alloc_in_dirband(s, near))) return NULL; |
407 | } | 375 | } |
408 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { | 376 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { |
409 | hpfs_free_dnode(s, *dno); | 377 | hpfs_free_dnode(s, *dno); |
410 | return NULL; | 378 | return NULL; |
411 | } | 379 | } |
412 | memset(d, 0, 2048); | 380 | memset(d, 0, 2048); |
413 | d->magic = DNODE_MAGIC; | 381 | d->magic = cpu_to_le32(DNODE_MAGIC); |
414 | d->first_free = 52; | 382 | d->first_free = cpu_to_le32(52); |
415 | d->dirent[0] = 32; | 383 | d->dirent[0] = 32; |
416 | d->dirent[2] = 8; | 384 | d->dirent[2] = 8; |
417 | d->dirent[30] = 1; | 385 | d->dirent[30] = 1; |
418 | d->dirent[31] = 255; | 386 | d->dirent[31] = 255; |
419 | d->self = *dno; | 387 | d->self = cpu_to_le32(*dno); |
420 | return d; | 388 | return d; |
421 | } | 389 | } |
422 | 390 | ||
@@ -424,16 +392,16 @@ struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *f | |||
424 | struct buffer_head **bh) | 392 | struct buffer_head **bh) |
425 | { | 393 | { |
426 | struct fnode *f; | 394 | struct fnode *f; |
427 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD, 1))) return NULL; | 395 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; |
428 | if (!(f = hpfs_get_sector(s, *fno, bh))) { | 396 | if (!(f = hpfs_get_sector(s, *fno, bh))) { |
429 | hpfs_free_sectors(s, *fno, 1); | 397 | hpfs_free_sectors(s, *fno, 1); |
430 | return NULL; | 398 | return NULL; |
431 | } | 399 | } |
432 | memset(f, 0, 512); | 400 | memset(f, 0, 512); |
433 | f->magic = FNODE_MAGIC; | 401 | f->magic = cpu_to_le32(FNODE_MAGIC); |
434 | f->ea_offs = 0xc4; | 402 | f->ea_offs = cpu_to_le16(0xc4); |
435 | f->btree.n_free_nodes = 8; | 403 | f->btree.n_free_nodes = 8; |
436 | f->btree.first_free = 8; | 404 | f->btree.first_free = cpu_to_le16(8); |
437 | return f; | 405 | return f; |
438 | } | 406 | } |
439 | 407 | ||
@@ -441,16 +409,16 @@ struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *a | |||
441 | struct buffer_head **bh) | 409 | struct buffer_head **bh) |
442 | { | 410 | { |
443 | struct anode *a; | 411 | struct anode *a; |
444 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD, 1))) return NULL; | 412 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; |
445 | if (!(a = hpfs_get_sector(s, *ano, bh))) { | 413 | if (!(a = hpfs_get_sector(s, *ano, bh))) { |
446 | hpfs_free_sectors(s, *ano, 1); | 414 | hpfs_free_sectors(s, *ano, 1); |
447 | return NULL; | 415 | return NULL; |
448 | } | 416 | } |
449 | memset(a, 0, 512); | 417 | memset(a, 0, 512); |
450 | a->magic = ANODE_MAGIC; | 418 | a->magic = cpu_to_le32(ANODE_MAGIC); |
451 | a->self = *ano; | 419 | a->self = cpu_to_le32(*ano); |
452 | a->btree.n_free_nodes = 40; | 420 | a->btree.n_free_nodes = 40; |
453 | a->btree.n_used_nodes = 0; | 421 | a->btree.n_used_nodes = 0; |
454 | a->btree.first_free = 8; | 422 | a->btree.first_free = cpu_to_le16(8); |
455 | return a; | 423 | return a; |
456 | } | 424 | } |