11 #include <asm/unaligned.h>
56 #define GET_FRAG_ID(_map,_start,_idmask) \
58 unsigned char *_m = _map + (_start >> 3); \
59 u32 _frag = get_unaligned_le32(_m); \
60 _frag >>= (_start & 7); \
71 lookup_zone(
const struct adfs_discmap *dm,
const unsigned int idlen,
72 const unsigned int frag_id,
unsigned int *
offset)
74 const unsigned int mapsize = dm->
dm_endbit;
75 const u32 idmask = (1 << idlen) - 1;
76 unsigned char *
map = dm->
dm_bh->b_data + 4;
83 mapptr = start + idlen;
92 mapptr = (mapptr & ~31) + 32;
93 if (mapptr >= mapsize)
98 mapptr += 1 +
ffz(~v);
105 }
while (mapptr < mapsize);
110 frag, start, mapptr);
116 if (*offset >= length) {
133 const unsigned int mapsize = dm->
dm_endbit + 32;
134 const unsigned int idlen = asb->
s_idlen;
135 const unsigned int frag_idlen = idlen <= 15 ? idlen : 15;
136 const u32 idmask = (1 << frag_idlen) - 1;
137 unsigned char *
map = dm->
dm_bh->b_data;
138 unsigned int start = 8, mapptr;
140 unsigned long total = 0;
161 mapptr = start + idlen;
170 mapptr = (mapptr & ~31) + 32;
171 if (mapptr >= mapsize)
176 mapptr += 1 +
ffz(~v);
179 total += mapptr -
start;
180 }
while (frag >= idlen + 1);
193 const unsigned int frag_id,
unsigned int mapoff)
195 const unsigned int idlen = asb->
s_idlen;
199 dm = asb->
s_map + zone;
201 dm_end = asb->
s_map + zone;
204 result = lookup_zone(dm, idlen, frag_id, &mapoff);
212 }
while (--zone > 0);
234 unsigned int total = 0;
241 total += scan_free_map(asb, dm++);
242 }
while (--zone > 0);
244 return signed_asl(total, asb->
s_map2blk);
252 unsigned int zone, mapoff;
268 mapoff = signed_asl(offset, -asb->
s_map2blk);
271 result = scan_map(asb, zone, frag_id, mapoff);
278 secoff = offset - signed_asl(mapoff, asb->
s_map2blk);
279 return secoff + signed_asl(result, asb->
s_map2blk);
282 adfs_error(sb,
"fragment 0x%04x at offset %d not found in map",
287 adfs_error(sb,
"invalid fragment 0x%04x (zone = %d, max = %d)",