diff options
-rw-r--r-- | ext2fs/getblk.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/ext2fs/getblk.c b/ext2fs/getblk.c index b016874c..0742b405 100644 --- a/ext2fs/getblk.c +++ b/ext2fs/getblk.c @@ -77,7 +77,7 @@ ext2_alloc_block (struct node *node, unsigned long goal) ext2_debug ("preallocation hit (%lu/%lu).\n", ++alloc_hits, ++alloc_attempts); - bh = bptr(result); + bh = bptr (result); memset (bh, 0, block_size); } else @@ -101,7 +101,8 @@ ext2_alloc_block (struct node *node, unsigned long goal) } static error_t -inode_getblk (struct node *node, int nr, int create, int new_block, char **buf) +inode_getblk (struct node *node, int nr, int create, int new_block, + u32 *disk_block) { u32 block; int goal = 0, i; @@ -110,7 +111,7 @@ inode_getblk (struct node *node, int nr, int create, int new_block, char **buf) block = node->dn->info.i_data[nr]; if (block) { - *buf = bptr(block); + *disk_block = block; return 0; } @@ -144,7 +145,7 @@ inode_getblk (struct node *node, int nr, int create, int new_block, char **buf) if (!block) return EIO; - *buf = bptr(block); + *disk_block = block; node->dn->info.i_data[nr] = block; node->dn->info.i_next_alloc_block = new_block; @@ -163,7 +164,7 @@ error_t block_getblk (struct node *node, char *bh, int nr, int create, int blocksize, - int new_block, char **buf) + int new_block, u32 *disk_block) { int i, goal = 0; u32 block; @@ -172,7 +173,7 @@ block_getblk (struct node *node, block = ((u32 *)bh)[nr]; if (block) { - *buf = bptr (block); + *disk_block = block; return 0; } @@ -192,14 +193,14 @@ block_getblk (struct node *node, } } if (!goal) - goal = addrb(bh); + goal = bptr_block (bh); } block = ext2_alloc_block (node, goal); if (!block) return EIO; /* XXX? */ - *buf = bptr (block); + *disk_block = block; ((u32 *)bh)[nr] = block; if (diskfs_synchronous || node->dn->info.i_osync) @@ -214,8 +215,11 @@ block_getblk (struct node *node, return 0; } +/* Returns the disk block index of the file block BLOCK in NODE in + DISK_BLOCK. If there is no such block yet, but CREATE is true, then it is + created, otherwise EINVAL is returned. */ error_t -ext2_getblk (struct node *node, long block, int create, char **buf) +ext2_getblk (struct node *node, long block, int create, char **disk_block) { error_t err; char *bh; @@ -253,14 +257,14 @@ ext2_getblk (struct node *node, long block, int create, char **buf) b = block; if (block < EXT2_NDIR_BLOCKS) - return inode_getblk (node, block, create, b, buf); + return inode_getblk (node, block, create, b, disk_block); block -= EXT2_NDIR_BLOCKS; if (block < addr_per_block) { err = inode_getblk (node, EXT2_IND_BLOCK, create, b, &bh); if (!err) - err = block_getblk (node, bh, block, create, block_size, b, buf); + err= block_getblk (node, bh, block, create, block_size, b, disk_block); return err; } @@ -273,7 +277,7 @@ ext2_getblk (struct node *node, long block, int create, char **buf) block_size, b, &bh); if (!err) err = block_getblk (node, bh, block & (addr_per_block - 1), - create, block_size, b, buf); + create, block_size, b, disk_block); return err; } @@ -288,7 +292,7 @@ ext2_getblk (struct node *node, long block, int create, char **buf) create, block_size, b, &bh); if (!err) err = block_getblk (node, bh, block & (addr_per_block - 1), create, - block_size, b, buf); + block_size, b, disk_block); return err; } |