Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
debugfs: add filefrag command
[tools/e2fsprogs.git]
/
lib
/
ext2fs
/
extent.c
diff --git
a/lib/ext2fs/extent.c
b/lib/ext2fs/extent.c
index
030d73a
..
eb096d6
100644
(file)
--- a/
lib/ext2fs/extent.c
+++ b/
lib/ext2fs/extent.c
@@
-9,6
+9,7
@@
* %End-Header%
*/
* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
@@
-53,6
+54,7
@@
struct ext2_extent_handle {
ext2_filsys fs;
ext2_ino_t ino;
struct ext2_inode *inode;
ext2_filsys fs;
ext2_ino_t ino;
struct ext2_inode *inode;
+ struct ext2_inode inodebuf;
int type;
int level;
int max_depth;
int type;
int level;
int max_depth;
@@
-165,8
+167,6
@@
extern void ext2fs_extent_free(ext2_extent_handle_t handle)
if (!handle)
return;
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)
if (handle->path) {
for (i=1; i <= handle->max_depth; i++) {
if (handle->path[i].buf)
@@
-203,17
+203,13
@@
extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
return retval;
memset(handle, 0, sizeof(struct ext2_extent_handle));
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) {
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;
retval = ext2fs_read_inode(fs, ino, handle->inode);
if (retval)
goto errout;
@@
-258,9
+254,8
@@
extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
handle->path[0].max_entries = ext2fs_le16_to_cpu(eh->eh_max);
handle->path[0].curr = 0;
handle->path[0].end_blk =
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;
handle->path[0].visit_num = 1;
handle->level = 0;
handle->magic = EXT2_ET_MAGIC_EXTENT_HANDLE;
@@
-379,9
+374,11
@@
retry:
case EXT2_EXTENT_ROOT:
handle->level = 0;
path = handle->path + handle->level;
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;
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;
case EXT2_EXTENT_NEXT_SIB:
if (path->left <= 0)
return EXT2_ET_EXTENT_NO_NEXT;
@@
-1981,8
+1978,8
@@
void do_goto_block(int argc, char **argv)
struct ext2fs_extent extent;
errcode_t retval;
int op = EXT2_EXTENT_NEXT_LEAF;
struct ext2fs_extent extent;
errcode_t retval;
int op = EXT2_EXTENT_NEXT_LEAF;
- blk
_t
blk;
- int level = 0;
+ blk
64_t
blk;
+ int level = 0
, err
;
if (common_extent_args_process(argc, argv, 2, 3, "goto_block",
"block [level]", 0))
if (common_extent_args_process(argc, argv, 2, 3, "goto_block",
"block [level]", 0))
@@
-1991,16
+1988,18
@@
void do_goto_block(int argc, char **argv)
if (strtoblk(argv[0], argv[1], &blk))
return;
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;
return;
+ }
retval = extent_goto(current_handle, level, (blk64_t) blk);
if (retval) {
com_err(argv[0], retval,
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 %
ll
u, level %d",
+
(unsigned long long)
blk, level);
return;
}
return;
}