* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
ext2_filsys fs;
ext2_ino_t ino;
struct ext2_inode *inode;
+ struct ext2_inode inodebuf;
int type;
int level;
int max_depth;
if (!handle)
return;
- if (handle->inode)
- ext2fs_free_mem(&handle->inode);
if (handle->path) {
for (i=1; i <= handle->max_depth; i++) {
if (handle->path[i].buf)
return retval;
memset(handle, 0, sizeof(struct ext2_extent_handle));
- retval = ext2fs_get_mem(sizeof(struct ext2_inode), &handle->inode);
- if (retval)
- goto errout;
-
handle->ino = ino;
handle->fs = fs;
if (inode) {
- memcpy(handle->inode, inode, sizeof(struct ext2_inode));
- }
- else {
+ handle->inode = inode;
+ } else {
+ handle->inode = &handle->inodebuf;
retval = ext2fs_read_inode(fs, ino, handle->inode);
if (retval)
goto errout;
handle->path[0].max_entries = ext2fs_le16_to_cpu(eh->eh_max);
handle->path[0].curr = 0;
handle->path[0].end_blk =
- ((((__u64) handle->inode->i_size_high << 32) +
- handle->inode->i_size + (fs->blocksize - 1))
- >> EXT2_BLOCK_SIZE_BITS(fs->super));
+ (EXT2_I_SIZE(handle->inode) + fs->blocksize - 1) >>
+ EXT2_BLOCK_SIZE_BITS(fs->super);
handle->path[0].visit_num = 1;
handle->level = 0;
handle->magic = EXT2_ET_MAGIC_EXTENT_HANDLE;
case EXT2_EXTENT_ROOT:
handle->level = 0;
path = handle->path + handle->level;
+ /* fallthrough */
case EXT2_EXTENT_FIRST_SIB:
path->left = path->entries;
path->curr = 0;
+ /* fallthrough */
case EXT2_EXTENT_NEXT_SIB:
if (path->left <= 0)
return EXT2_ET_EXTENT_NO_NEXT;
struct ext2fs_extent extent;
errcode_t retval;
int op = EXT2_EXTENT_NEXT_LEAF;
- blk_t blk;
- int level = 0;
+ blk64_t blk;
+ int level = 0, err;
if (common_extent_args_process(argc, argv, 2, 3, "goto_block",
"block [level]", 0))
if (strtoblk(argv[0], argv[1], &blk))
return;
- if (argc == 3)
- if (strtoblk(argv[0], argv[2], &level))
+ if (argc == 3) {
+ level = parse_ulong(argv[2], argv[0], "level", &err);
+ if (err)
return;
+ }
retval = extent_goto(current_handle, level, (blk64_t) blk);
if (retval) {
com_err(argv[0], retval,
- "while trying to go to block %u, level %d",
- blk, level);
+ "while trying to go to block %llu, level %d",
+ (unsigned long long) blk, level);
return;
}