Whamcloud - gitweb
e2fsck: clean up xattr checking code
[tools/e2fsprogs.git] / debugfs / filefrag.c
index 0adea40..31c1440 100644 (file)
@@ -85,14 +85,17 @@ static void report_filefrag(struct filefrag_struct *fs)
                        fprintf(fs->f, "%4d %*lu %*llu %*llu %*lu\n", fs->ext,
                                fs->logical_width,
                                (unsigned long) fs->logical_start,
-                               fs->physical_width, fs->physical_start,
-                               fs->physical_width, fs->expected,
+                               fs->physical_width,
+                               (unsigned long long) fs->physical_start,
+                               fs->physical_width,
+                               (unsigned long long) fs->expected,
                                fs->logical_width, (unsigned long) fs->num);
                else
                        fprintf(fs->f, "%4d %*lu %*llu %*s %*lu\n", fs->ext,
                                fs->logical_width,
                                (unsigned long) fs->logical_start,
-                               fs->physical_width, fs->physical_start,
+                               fs->physical_width,
+                               (unsigned long long) fs->physical_start,
                                fs->physical_width, "",
                                fs->logical_width, (unsigned long) fs->num);
        }
@@ -145,20 +148,22 @@ static void filefrag(ext2_ino_t ino, struct ext2_inode *inode,
        if (fs->options & VERBOSE_OPT) {
                blk64_t num_blocks = ext2fs_inode_i_blocks(current_fs, inode);
 
-               if (!(current_fs->super->s_feature_ro_compat &
-                    EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
+               if (!ext2fs_has_feature_huge_file(current_fs->super) ||
                    !(inode->i_flags & EXT4_HUGE_FILE_FL))
                        num_blocks /= current_fs->blocksize / 512;
 
                fprintf(fs->f, "\n%s has %llu block(s), i_size is %llu\n",
-                       fs->name, num_blocks, EXT2_I_SIZE(inode));
+                       fs->name, (unsigned long long) num_blocks,
+                       (unsigned long long) EXT2_I_SIZE(inode));
        }
        print_header(fs);
-       retval = ext2fs_block_iterate3(current_fs, ino,
-                                      BLOCK_FLAG_READ_ONLY, NULL,
-                                      filefrag_blocks_proc, fs);
-       if (retval)
-               com_err("ext2fs_block_iterate3", retval, 0);
+       if (ext2fs_inode_has_valid_blocks2(current_fs, inode)) {
+               retval = ext2fs_block_iterate3(current_fs, ino,
+                                              BLOCK_FLAG_READ_ONLY, NULL,
+                                              filefrag_blocks_proc, fs);
+               if (retval)
+                       com_err("ext2fs_block_iterate3", retval, 0);
+       }
 
        report_filefrag(fs);
        fprintf(fs->f, "%s: %d contiguous extents%s\n", fs->name, fs->ext,
@@ -183,7 +188,7 @@ static int filefrag_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
        if (entry == DIRENT_DELETED_FILE)
                return 0;
 
-       thislen = dirent->name_len & 0xFF;
+       thislen = ext2fs_dirent_name_len(dirent);
        strncpy(name, dirent->name, thislen);
        name[thislen] = '\0';
        ino = dirent->inode;
@@ -259,7 +264,8 @@ static void dir_iterate(ext2_ino_t ino, struct filefrag_struct *fs)
        }
 }
 
-void do_filefrag(int argc, char *argv[])
+void do_filefrag(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
+                void *infop EXT2FS_ATTR((unused)))
 {
        struct filefrag_struct fs;
        struct ext2_inode inode;