21 if ((
le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) {
22 hpfs_error(s,
"sector '%s' - %08x not allocated in bitmap", msg, sec);
26 if (sec >= hpfs_sb(s)->sb_dirband_start && sec < hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
27 unsigned ssec = (sec - hpfs_sb(s)->sb_dirband_start) / 4;
29 if ((
le32_to_cpu(bmp[ssec >> 5]) >> (ssec & 0x1f)) & 1) {
30 hpfs_error(s,
"sector '%s' - %08x not allocated in directory bitmap", msg, sec);
49 if (start + len < start || start < 0x12 ||
50 start + len > hpfs_sb(s)->sb_fs_size) {
51 hpfs_error(s,
"sector(s) '%s' badly placed at %08x", msg, start);
54 if (hpfs_sb(s)->sb_chk>=2) {
56 for (i = 0; i < len; i++)
57 if (chk_if_allocated(s, start + i, msg))
return 1;
66 unsigned bs = near & ~0x3fff;
67 unsigned nr = (near & 0x3fff) & ~(n - 1);
72 if (n != 1 && n != 4) {
81 if (!tstbits(bmp, nr, n + forward)) {
86 while ((a = tstbits(bmp, q, n + forward)) != 0) {
88 if (n != 1) q = ((q-1)&~(n-1))+n;
94 }
else if (q > nr)
break;
105 if (n + forward >= 0x3f &&
le32_to_cpu(bmp[i]) != 0xffffffff)
goto cont;
109 while (k & 0x80000000) {
113 if (n != 1) q = ((q-1)&~(n-1))+n;
114 while ((a = tstbits(bmp, q, n + forward)) != 0) {
116 if (n != 1) q = ((q-1)&~(n-1))+n;
128 if (hpfs_sb(s)->sb_chk && ((ret >> 14) != (bs >> 14) || (
le32_to_cpu(bmp[(ret & 0x3fff) >> 5]) | ~(((1 <<
n) - 1) << (ret & 0x1f))) != 0xffffffff)) {
129 hpfs_error(s,
"Allocation doesn't work! Wanted %d, allocated at %08x", n, ret);
133 bmp[(ret & 0x3fff) >> 5] &=
cpu_to_le32(~(((1 << n) - 1) << (ret & 0x1f)));
162 n_bmps = (sbi->
sb_fs_size + 0x4000 - 1) >> 14;
164 if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4)))
goto ret;
165 near_bmp = near >> 14;
166 }
else near_bmp = n_bmps / 2;
177 for (i = 0; i < n_bmps; i++) {
178 if (near_bmp+i < n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i) << 14, n, forward)))) {
183 if (near_bmp-i-1 >= 0 && ((sec = alloc_in_bmp(s, (near_bmp-i-1) << 14, n, forward)))) {
188 if (near_bmp+i >= n_bmps && ((sec = alloc_in_bmp(s, (near_bmp+i-n_bmps) << 14, n, forward)))) {
193 if (i == 1 && sbi->
sb_c_bitmap != -1 && ((sec = alloc_in_bmp(s, (sbi->
sb_c_bitmap) << 14, n, forward)))) {
207 for (i = 0; i < forward; i++) {
209 hpfs_error(s,
"Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i);
229 sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0);
241 if (
le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) {
242 bmp[(sec & 0x3fff) >> 5] &=
cpu_to_le32(~(1 << (sec & 0x1f)));
262 hpfs_error(s,
"Trying to free reserved sector %08x", sec);
272 if ((
le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f) & 1)) {
273 hpfs_error(s,
"sector %08x not allocated", sec);
277 bmp[(sec & 0x3fff) >> 5] |=
cpu_to_le32(1 << (sec & 0x1f));
283 if (!(++sec & 0x3fff)) {
299 int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14;
300 int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff;
305 for (j = 0; j < 512; j++) {
308 for (k =
le32_to_cpu(bmp[j]);
k; k >>= 1)
if (k & 1)
if (!--n) {
316 if (hpfs_sb(s)->sb_c_bitmap != -1) {
322 if (i >= n_bmps)
return 1;
326 for (j = 0; j < 512; j++) {
329 for (k = 0xf;
k; k <<= 4)
345 if (hpfs_sb(s)->sb_chk)
if (dno & 3) {
346 hpfs_error(s,
"hpfs_free_dnode: dnode %08x not aligned", dno);
349 if (dno < hpfs_sb(s)->sb_dirband_start ||
350 dno >= hpfs_sb(s)->sb_dirband_start + hpfs_sb(s)->sb_dirband_size) {
355 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4;
370 if (!(*dno = alloc_in_dirband(s, near)))
374 if (!(*dno = alloc_in_dirband(s, near)))
return NULL;
392 struct buffer_head **bh)
403 f->
btree.n_free_nodes = 8;
409 struct buffer_head **bh)
420 a->
btree.n_free_nodes = 40;
421 a->
btree.n_used_nodes = 0;