aboutsummaryrefslogtreecommitdiffstats
path: root/fs/minix/itree_common.c
diff options
context:
space:
mode:
authorAndries Brouwer <aeb@cwi.nl>2007-02-12 03:52:49 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:31 -0500
commit939b00df0306bc4b5cd25c3c3c78e89b91e72fc8 (patch)
treec251dca9f3ebbebfa1f40f39716423842b247742 /fs/minix/itree_common.c
parentb587b13a4f670ebae79ae6259cf44328455e4e69 (diff)
[PATCH] Minix V3 support
This morning I needed to read a Minix V3 filesystem, but unfortunately my 2.6.19 did not support that, and neither did the downloaded 2.6.20rc4. Fortunately, google told me that Daniel Aragones had already done the work, patch found at http://www.terra.es/personal2/danarag/ Unfortunaly, looking at the patch was painful to my eyes, so I polished it a bit before applying. The resulting kernel boots, and reads the filesystem it needed to read. Signed-off-by: Daniel Aragones <danarag@gmail.com> Signed-off-by: Andries Brouwer <aeb@cwi.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/minix/itree_common.c')
-rw-r--r--fs/minix/itree_common.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c
index 429baf8de105..a731cabf1540 100644
--- a/fs/minix/itree_common.c
+++ b/fs/minix/itree_common.c
@@ -23,7 +23,7 @@ static inline int verify_chain(Indirect *from, Indirect *to)
23 23
24static inline block_t *block_end(struct buffer_head *bh) 24static inline block_t *block_end(struct buffer_head *bh)
25{ 25{
26 return (block_t *)((char*)bh->b_data + BLOCK_SIZE); 26 return (block_t *)((char*)bh->b_data + bh->b_size);
27} 27}
28 28
29static inline Indirect *get_branch(struct inode *inode, 29static inline Indirect *get_branch(struct inode *inode,
@@ -85,7 +85,7 @@ static int alloc_branch(struct inode *inode,
85 branch[n].key = cpu_to_block(nr); 85 branch[n].key = cpu_to_block(nr);
86 bh = sb_getblk(inode->i_sb, parent); 86 bh = sb_getblk(inode->i_sb, parent);
87 lock_buffer(bh); 87 lock_buffer(bh);
88 memset(bh->b_data, 0, BLOCK_SIZE); 88 memset(bh->b_data, 0, bh->b_size);
89 branch[n].bh = bh; 89 branch[n].bh = bh;
90 branch[n].p = (block_t*) bh->b_data + offsets[n]; 90 branch[n].p = (block_t*) bh->b_data + offsets[n];
91 *branch[n].p = branch[n].key; 91 *branch[n].p = branch[n].key;
@@ -292,6 +292,7 @@ static void free_branches(struct inode *inode, block_t *p, block_t *q, int depth
292 292
293static inline void truncate (struct inode * inode) 293static inline void truncate (struct inode * inode)
294{ 294{
295 struct super_block *sb = inode->i_sb;
295 block_t *idata = i_data(inode); 296 block_t *idata = i_data(inode);
296 int offsets[DEPTH]; 297 int offsets[DEPTH];
297 Indirect chain[DEPTH]; 298 Indirect chain[DEPTH];
@@ -301,7 +302,7 @@ static inline void truncate (struct inode * inode)
301 int first_whole; 302 int first_whole;
302 long iblock; 303 long iblock;
303 304
304 iblock = (inode->i_size + BLOCK_SIZE-1) >> 10; 305 iblock = (inode->i_size + sb->s_blocksize -1) >> sb->s_blocksize_bits;
305 block_truncate_page(inode->i_mapping, inode->i_size, get_block); 306 block_truncate_page(inode->i_mapping, inode->i_size, get_block);
306 307
307 n = block_to_path(inode, iblock, offsets); 308 n = block_to_path(inode, iblock, offsets);
@@ -346,15 +347,16 @@ do_indirects:
346 mark_inode_dirty(inode); 347 mark_inode_dirty(inode);
347} 348}
348 349
349static inline unsigned nblocks(loff_t size) 350static inline unsigned nblocks(loff_t size, struct super_block *sb)
350{ 351{
352 int k = sb->s_blocksize_bits - 10;
351 unsigned blocks, res, direct = DIRECT, i = DEPTH; 353 unsigned blocks, res, direct = DIRECT, i = DEPTH;
352 blocks = (size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS; 354 blocks = (size + sb->s_blocksize - 1) >> (BLOCK_SIZE_BITS + k);
353 res = blocks; 355 res = blocks;
354 while (--i && blocks > direct) { 356 while (--i && blocks > direct) {
355 blocks -= direct; 357 blocks -= direct;
356 blocks += BLOCK_SIZE/sizeof(block_t) - 1; 358 blocks += sb->s_blocksize/sizeof(block_t) - 1;
357 blocks /= BLOCK_SIZE/sizeof(block_t); 359 blocks /= sb->s_blocksize/sizeof(block_t);
358 res += blocks; 360 res += blocks;
359 direct = 1; 361 direct = 1;
360 } 362 }