diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 12:19:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 12:19:03 -0400 |
commit | 396b122f6af3d329df3b4d688f6e66de3e2a399a (patch) | |
tree | 0b4185d529c1ba4c8eca1de23f14beecbe460323 /fs/ubifs/lpt.c | |
parent | ed402af3c23a4804b3f8899263e8d0f97c62ab49 (diff) | |
parent | 54779aabb0183bbe049d2b52e96cd148366dfb0b (diff) |
Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
* 'linux-next' of git://git.infradead.org/ubifs-2.6: (25 commits)
UBIFS: fix ubifs_compress commentary
UBIFS: amend printk
UBIFS: do not read unnecessary bytes when unpacking bits
UBIFS: check buffer length when scanning for LPT nodes
UBIFS: correct condition to eliminate unecessary assignment
UBIFS: add more debugging messages for LPT
UBIFS: fix bulk-read handling uptodate pages
UBIFS: improve garbage collection
UBIFS: allow for sync_fs when read-only
UBIFS: commit on sync_fs
UBIFS: correct comment for commit_on_unmount
UBIFS: update dbg_dump_inode
UBIFS: fix commentary
UBIFS: fix races in bit-fields
UBIFS: ensure data read beyond i_size is zeroed out correctly
UBIFS: correct key comparison
UBIFS: use bit-fields when possible
UBIFS: check data CRC when in error state
UBIFS: improve znode splitting rules
UBIFS: add no_chk_data_crc mount option
...
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r-- | fs/ubifs/lpt.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 9ff2463177e5..db8bd0e518b2 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -109,7 +109,8 @@ static void do_calc_lpt_geom(struct ubifs_info *c) | |||
109 | c->lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; | 109 | c->lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; |
110 | c->lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; | 110 | c->lpt_sz += (long long)c->nnode_cnt * c->nnode_sz; |
111 | c->lpt_sz += c->ltab_sz; | 111 | c->lpt_sz += c->ltab_sz; |
112 | c->lpt_sz += c->lsave_sz; | 112 | if (c->big_lpt) |
113 | c->lpt_sz += c->lsave_sz; | ||
113 | 114 | ||
114 | /* Add wastage */ | 115 | /* Add wastage */ |
115 | sz = c->lpt_sz; | 116 | sz = c->lpt_sz; |
@@ -287,25 +288,56 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) | |||
287 | const int k = 32 - nrbits; | 288 | const int k = 32 - nrbits; |
288 | uint8_t *p = *addr; | 289 | uint8_t *p = *addr; |
289 | int b = *pos; | 290 | int b = *pos; |
290 | uint32_t val; | 291 | uint32_t uninitialized_var(val); |
292 | const int bytes = (nrbits + b + 7) >> 3; | ||
291 | 293 | ||
292 | ubifs_assert(nrbits > 0); | 294 | ubifs_assert(nrbits > 0); |
293 | ubifs_assert(nrbits <= 32); | 295 | ubifs_assert(nrbits <= 32); |
294 | ubifs_assert(*pos >= 0); | 296 | ubifs_assert(*pos >= 0); |
295 | ubifs_assert(*pos < 8); | 297 | ubifs_assert(*pos < 8); |
296 | if (b) { | 298 | if (b) { |
297 | val = p[1] | ((uint32_t)p[2] << 8) | ((uint32_t)p[3] << 16) | | 299 | switch (bytes) { |
298 | ((uint32_t)p[4] << 24); | 300 | case 2: |
301 | val = p[1]; | ||
302 | break; | ||
303 | case 3: | ||
304 | val = p[1] | ((uint32_t)p[2] << 8); | ||
305 | break; | ||
306 | case 4: | ||
307 | val = p[1] | ((uint32_t)p[2] << 8) | | ||
308 | ((uint32_t)p[3] << 16); | ||
309 | break; | ||
310 | case 5: | ||
311 | val = p[1] | ((uint32_t)p[2] << 8) | | ||
312 | ((uint32_t)p[3] << 16) | | ||
313 | ((uint32_t)p[4] << 24); | ||
314 | } | ||
299 | val <<= (8 - b); | 315 | val <<= (8 - b); |
300 | val |= *p >> b; | 316 | val |= *p >> b; |
301 | nrbits += b; | 317 | nrbits += b; |
302 | } else | 318 | } else { |
303 | val = p[0] | ((uint32_t)p[1] << 8) | ((uint32_t)p[2] << 16) | | 319 | switch (bytes) { |
304 | ((uint32_t)p[3] << 24); | 320 | case 1: |
321 | val = p[0]; | ||
322 | break; | ||
323 | case 2: | ||
324 | val = p[0] | ((uint32_t)p[1] << 8); | ||
325 | break; | ||
326 | case 3: | ||
327 | val = p[0] | ((uint32_t)p[1] << 8) | | ||
328 | ((uint32_t)p[2] << 16); | ||
329 | break; | ||
330 | case 4: | ||
331 | val = p[0] | ((uint32_t)p[1] << 8) | | ||
332 | ((uint32_t)p[2] << 16) | | ||
333 | ((uint32_t)p[3] << 24); | ||
334 | break; | ||
335 | } | ||
336 | } | ||
305 | val <<= k; | 337 | val <<= k; |
306 | val >>= k; | 338 | val >>= k; |
307 | b = nrbits & 7; | 339 | b = nrbits & 7; |
308 | p += nrbits / 8; | 340 | p += nrbits >> 3; |
309 | *addr = p; | 341 | *addr = p; |
310 | *pos = b; | 342 | *pos = b; |
311 | ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); | 343 | ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); |