offset += pagesize;
continue;
}
- if (posix_fadvise(fd, offset, pagesize, fadvise_flag) < 0) {
+ if ((errno = posix_fadvise(fd, offset,
+ pagesize, fadvise_flag)) != 0) {
if ((mode_flag & DETAIL) && flag) {
perror("\tFailed to fadvise");
flag = 0;
int ret;
unsigned int flex_bg_num;
- /* Calcuate best extents count */
+ if (blocks_per_group == 0)
+ return 1;
+
if (feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) {
flex_bg_num = 1 << log_groups_per_flex;
ret = ((block_count - 1) /
struct fiemap_extent_list *logical_list_head = NULL;
defraged_file_count++;
+ if (defraged_file_count > total_count)
+ total_count = defraged_file_count;
if (mode_flag & DETAIL) {
if (total_count == 1 && regular_count == 1)
struct fiemap_extent_group *orig_group_tmp = NULL;
defraged_file_count++;
+ if (defraged_file_count > total_count)
+ total_count = defraged_file_count;
if (mode_flag & DETAIL) {
printf("[%u/%u]", defraged_file_count, total_count);
goto out;
}
- if (current_uid == ROOT_UID)
- best = get_best_count(blk_count);
- else
- best = 1;
+ best = get_best_count(blk_count);
if (file_frags_start <= best)
goto check_improvement;
goto out;
}
- /* Calcuate donor inode's continuous physical region */
+ /* Calculate donor inode's continuous physical region */
donor_physical_cnt = get_physical_count(donor_list_physical);
/* Change donor extent list from physical to logical */
block_size, unix_io_manager, &fs);
if (ret) {
if (mode_flag & DETAIL)
- com_err(argv[1], ret,
- "while trying to open file system: %s",
- dev_name);
- continue;
+ fprintf(stderr,
+ "Warning: couldn't get file "
+ "system details for %s: %s\n",
+ dev_name, error_message(ret));
+ } else {
+ blocks_per_group = fs->super->s_blocks_per_group;
+ feature_incompat = fs->super->s_feature_incompat;
+ log_groups_per_flex = fs->super->s_log_groups_per_flex;
+ ext2fs_close_free(&fs);
}
-
- blocks_per_group = fs->super->s_blocks_per_group;
- feature_incompat = fs->super->s_feature_incompat;
- log_groups_per_flex = fs->super->s_log_groups_per_flex;
-
- ext2fs_close_free(&fs);
}
switch (arg_type) {
/* "e4defrag mount_point_dir/else_dir" */
memset(lost_found_dir, 0, PATH_MAX + 1);
}
+ /* fall through */
case DEVNAME:
if (arg_type == DEVNAME) {
strncpy(lost_found_dir, dir_name,