mirror of https://github.com/vitalif/e2fsprogs
commit
c9bc7484cc
|
@ -29,6 +29,7 @@ man5dir = $(mandir)/man5
|
|||
man8dir = $(mandir)/man8
|
||||
infodir = @infodir@
|
||||
datadir = @datadir@
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
|
|
@ -118,8 +118,10 @@ if ./asm_types
|
|||
then
|
||||
true
|
||||
else
|
||||
echo "Problem detected with asm_types.h"
|
||||
echo "" > asm_types.h
|
||||
if [ "${CROSS_COMPILE}" != "1" ]; then
|
||||
echo "Problem detected with asm_types.h"
|
||||
echo "" > asm_types.h
|
||||
fi
|
||||
fi
|
||||
rm asm_types.c asm_types
|
||||
|
||||
|
|
|
@ -10987,7 +10987,11 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
|
|||
presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
|
||||
esac
|
||||
|
||||
BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
if test $cross_compiling = no; then
|
||||
BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
else
|
||||
CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
fi
|
||||
ASM_TYPES_HEADER=./asm_types.h
|
||||
|
||||
echo "/* These defines are needed for the public ext2fs.h header file */" \
|
||||
|
@ -11155,7 +11159,7 @@ if test "$ac_res" != no; then :
|
|||
fi
|
||||
|
||||
fi
|
||||
for ac_func in __secure_getenv backtrace blkid_probe_get_topology chflags fadvise64 fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 futimes getcwd getdtablesize getmntinfo getpwuid_r getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mempcpy mmap msync nanosleep open64 pathconf posix_fadvise posix_fadvise64 posix_memalign prctl secure_getenv setmntent setresgid setresuid srandom stpcpy strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc
|
||||
for ac_func in __secure_getenv backtrace blkid_probe_get_topology blkid_probe_enable_partitions chflags fadvise64 fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 futimes getcwd getdtablesize getmntinfo getpwuid_r getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mempcpy mmap msync nanosleep open64 pathconf posix_fadvise posix_fadvise64 posix_memalign prctl secure_getenv setmntent setresgid setresuid srandom stpcpy strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
|
|
|
@ -1033,7 +1033,11 @@ AC_SUBST(SIZEOF_LONG)
|
|||
AC_SUBST(SIZEOF_LONG_LONG)
|
||||
AC_SUBST(SIZEOF_OFF_T)
|
||||
AC_C_BIGENDIAN
|
||||
BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
if test $cross_compiling = no; then
|
||||
BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
else
|
||||
CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
|
||||
fi
|
||||
ASM_TYPES_HEADER=./asm_types.h
|
||||
AC_SUBST_FILE(ASM_TYPES_HEADER)
|
||||
dnl
|
||||
|
@ -1104,6 +1108,7 @@ AC_CHECK_FUNCS(m4_flatten([
|
|||
__secure_getenv
|
||||
backtrace
|
||||
blkid_probe_get_topology
|
||||
blkid_probe_enable_partitions
|
||||
chflags
|
||||
fadvise64
|
||||
fallocate
|
||||
|
|
|
@ -189,8 +189,9 @@ struct resource_track {
|
|||
#define E2F_FLAG_GOT_DEVSIZE 0x0800 /* Device size has been fetched */
|
||||
#define E2F_FLAG_EXITING 0x1000 /* E2fsck exiting due to errors */
|
||||
#define E2F_FLAG_TIME_INSANE 0x2000 /* Time is insane */
|
||||
#define E2F_FLAG_PROBLEMS_FIXED 0x4000 /* At least one problem was fixed */
|
||||
|
||||
#define E2F_RESET_FLAGS (E2F_FLAG_TIME_INSANE)
|
||||
#define E2F_RESET_FLAGS (E2F_FLAG_TIME_INSANE | E2F_FLAG_PROBLEMS_FIXED)
|
||||
|
||||
/*
|
||||
* Defines for indicating the e2fsck pass number
|
||||
|
|
|
@ -608,7 +608,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
|||
const char *old_op;
|
||||
unsigned int save_type;
|
||||
int imagic_fs, extent_fs, inlinedata_fs;
|
||||
int busted_fs_time = 0;
|
||||
int low_dtime_check = 1;
|
||||
int inode_size;
|
||||
int failed_csum = 0;
|
||||
|
||||
|
@ -761,8 +761,10 @@ void e2fsck_pass1(e2fsck_t ctx)
|
|||
ctx->fs->group_desc_count)))
|
||||
goto endit;
|
||||
if ((fs->super->s_wtime < fs->super->s_inodes_count) ||
|
||||
(fs->super->s_mtime < fs->super->s_inodes_count))
|
||||
busted_fs_time = 1;
|
||||
(fs->super->s_mtime < fs->super->s_inodes_count) ||
|
||||
(fs->super->s_mkfs_time &&
|
||||
fs->super->s_mkfs_time < fs->super->s_inodes_count))
|
||||
low_dtime_check = 0;
|
||||
|
||||
if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) &&
|
||||
fs->super->s_mmp_block > fs->super->s_first_data_block &&
|
||||
|
@ -1071,7 +1073,7 @@ void e2fsck_pass1(e2fsck_t ctx)
|
|||
* than nothing. The right answer is that there
|
||||
* shouldn't be any bugs in the orphan list handling. :-)
|
||||
*/
|
||||
if (inode->i_dtime && !busted_fs_time &&
|
||||
if (inode->i_dtime && low_dtime_check &&
|
||||
inode->i_dtime < ctx->fs->super->s_inodes_count) {
|
||||
if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) {
|
||||
inode->i_dtime = inode->i_links_count ?
|
||||
|
|
|
@ -2080,6 +2080,9 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
|
|||
if (ptr->flags & PR_AFTER_CODE)
|
||||
answer = fix_problem(ctx, ptr->second_code, pctx);
|
||||
|
||||
if (answer && (ptr->prompt != PROMPT_NONE))
|
||||
ctx->flags |= E2F_FLAG_PROBLEMS_FIXED;
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,6 +337,9 @@ static void check_if_skip(e2fsck_t ctx)
|
|||
int broken_system_clock;
|
||||
time_t lastcheck;
|
||||
|
||||
if (ctx->flags & E2F_FLAG_PROBLEMS_FIXED)
|
||||
return;
|
||||
|
||||
profile_get_boolean(ctx->profile, "options", "broken_system_clock",
|
||||
0, 0, &broken_system_clock);
|
||||
if (ctx->flags & E2F_FLAG_TIME_INSANE)
|
||||
|
|
|
@ -149,7 +149,7 @@ blkid.pc: $(srcdir)/blkid.pc.in $(top_builddir)/config.status
|
|||
installdirs::
|
||||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/blkid"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/blkid $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(includedir)/blkid $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: all installdirs
|
||||
$(E) " INSTALL_DATA $(libdir)/libblkid.a"
|
||||
|
@ -164,12 +164,12 @@ install:: all installdirs
|
|||
echo " INSTALL_DATA $(man3dir)/$$i"; \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(man3dir)/$$i; \
|
||||
done
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/blkid.pc"
|
||||
$(Q) $(INSTALL_DATA) blkid.pc $(DESTDIR)$(libdir)/pkgconfig/blkid.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/blkid.pc"
|
||||
$(Q) $(INSTALL_DATA) blkid.pc $(DESTDIR)$(pkgconfigdir)/blkid.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libblkid.a \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/blkid.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/blkid.pc
|
||||
$(RM) -rf $(DESTDIR)$(includedir)/blkid
|
||||
for i in $(SMANPAGES); do \
|
||||
$(RM) -f $(DESTDIR)$(man3dir)/$$i; \
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
/* Define to 1 if you have the `backtrace' function. */
|
||||
#undef HAVE_BACKTRACE
|
||||
|
||||
/* Define to 1 if you have the `blkid_probe_enable_partitions' function. */
|
||||
#undef HAVE_BLKID_PROBE_ENABLE_PARTITIONS
|
||||
|
||||
/* Define to 1 if you have the `blkid_probe_get_topology' function. */
|
||||
#undef HAVE_BLKID_PROBE_GET_TOPOLOGY
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ check:: tst_ostype tst_feature
|
|||
installdirs::
|
||||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/e2p"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/e2p $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(includedir)/e2p $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: all installdirs
|
||||
$(E) " INSTALL_DATA $(libdir)/libe2p.a"
|
||||
|
@ -94,12 +94,12 @@ install:: all installdirs
|
|||
echo " INSTALL_DATA $(includedir)/e2p/$$i"; \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/e2p/$$i; \
|
||||
done
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/e2p.pc"
|
||||
$(Q) $(INSTALL_DATA) e2p.pc $(DESTDIR)$(libdir)/pkgconfig/e2p.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/e2p.pc"
|
||||
$(Q) $(INSTALL_DATA) e2p.pc $(DESTDIR)$(pkgconfigdir)/e2p.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libe2p.a \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/e2p.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/e2p.pc
|
||||
$(RM) -rf $(DESTDIR)$(includedir)/e2p
|
||||
|
||||
clean::
|
||||
|
|
|
@ -106,7 +106,7 @@ installdirs::
|
|||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et \
|
||||
$(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) \
|
||||
$(DESTDIR)$(man3dir) $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(man3dir) $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: compile_et libcom_err.a $(HFILES) installdirs com_err.pc
|
||||
$(E) " INSTALL_DATA $(libdir)/libcom_err.a"
|
||||
|
@ -130,13 +130,13 @@ install:: compile_et libcom_err.a $(HFILES) installdirs com_err.pc
|
|||
$(E) " INSTALL_DATA $(man1dir)/compile_et.1"
|
||||
$(Q) $(INSTALL_DATA) $(srcdir)/compile_et.1 \
|
||||
$(DESTDIR)$(man1dir)/compile_et.1
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/com_err.pc"
|
||||
$(Q) $(INSTALL_DATA) com_err.pc $(DESTDIR)$(libdir)/pkgconfig/com_err.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/com_err.pc"
|
||||
$(Q) $(INSTALL_DATA) com_err.pc $(DESTDIR)$(pkgconfigdir)/com_err.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libcom_err.a \
|
||||
$(DESTDIR)$(bindir)/compile_et \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/com_err.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/com_err.pc
|
||||
$(RM) -rf $(DESTDIR)$(includedir)/et $(DESTDIR)$(datadir)/et
|
||||
|
||||
check:: compile_et
|
||||
|
|
|
@ -450,7 +450,7 @@ check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount \
|
|||
installdirs::
|
||||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/ext2fs"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/ext2fs $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(includedir)/ext2fs $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: all $(HFILES) $(HFILES_IN) installdirs ext2fs.pc
|
||||
$(E) " INSTALL_DATA $(libdir)/libext2fs.a"
|
||||
|
@ -465,12 +465,12 @@ install:: all $(HFILES) $(HFILES_IN) installdirs ext2fs.pc
|
|||
echo " INSTALL_DATA $(includedir)/ext2fs/$$i"; \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(includedir)/ext2fs/$$i; \
|
||||
done
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/ext2fs.pc"
|
||||
$(Q) $(INSTALL_DATA) ext2fs.pc $(DESTDIR)$(libdir)/pkgconfig/ext2fs.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/ext2fs.pc"
|
||||
$(Q) $(INSTALL_DATA) ext2fs.pc $(DESTDIR)$(pkgconfigdir)/ext2fs.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libext2fs.a \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/ext2fs.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/ext2fs.pc
|
||||
$(RM) -rf $(DESTDIR)$(includedir)/ext2fs
|
||||
|
||||
clean::
|
||||
|
|
|
@ -54,8 +54,8 @@ static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk,
|
|||
* Don't do a long search if the previous block
|
||||
* search is still valid.
|
||||
*/
|
||||
if (start_blk && ext2fs_test_block_bitmap_range2(bmap, start_blk,
|
||||
elem_size))
|
||||
if (start_blk && start_blk < ext2fs_blocks_count(fs->super) &&
|
||||
ext2fs_test_block_bitmap_range2(bmap, start_blk, elem_size))
|
||||
return start_blk;
|
||||
|
||||
start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg);
|
||||
|
|
|
@ -64,5 +64,7 @@ struct fiemap {
|
|||
#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
|
||||
* support extents. Result
|
||||
* merged for efficiency. */
|
||||
#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
|
||||
* files. */
|
||||
|
||||
#endif /* _LINUX_FIEMAP_H */
|
||||
|
|
|
@ -76,7 +76,7 @@ installdirs::
|
|||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/quota $(man3dir)"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/quota $(DESTDIR)$(man3dir) \
|
||||
$(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: all installdirs
|
||||
$(E) " INSTALL_DATA $(libdir)/libquota.a"
|
||||
|
@ -90,12 +90,12 @@ install:: all installdirs
|
|||
echo " INSTALL_DATA $(man3dir)/$$i"; \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(man3dir)/$$i; \
|
||||
done
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/quota.pc"
|
||||
$(Q) $(INSTALL_DATA) quota.pc $(DESTDIR)$(libdir)/pkgconfig/quota.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/quota.pc"
|
||||
$(Q) $(INSTALL_DATA) quota.pc $(DESTDIR)$(pkgconfigdir)/quota.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libquota.a \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/quota.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/quota.pc
|
||||
for i in $(SMANPAGES); do \
|
||||
$(RM) -f $(DESTDIR)$(man3dir)/$$i; \
|
||||
done
|
||||
|
|
|
@ -207,7 +207,12 @@ static int dict_uint_cmp(const void *a, const void *b)
|
|||
c = VOIDPTR_TO_UINT(a);
|
||||
d = VOIDPTR_TO_UINT(b);
|
||||
|
||||
return c - d;
|
||||
if (c == d)
|
||||
return 0;
|
||||
else if (c > d)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline qid_t get_qid(struct ext2_inode *inode, int qtype)
|
||||
|
|
|
@ -129,7 +129,7 @@ installdirs::
|
|||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/ss $(datadir)/ss $(bindir)"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss \
|
||||
$(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: libss.a $(INSTALL_HFILES) installdirs ss_err.h mk_cmds ss.pc
|
||||
$(E) " INSTALL_DATA $(DESTDIR)$(libdir)/libss.a"
|
||||
|
@ -151,12 +151,12 @@ install:: libss.a $(INSTALL_HFILES) installdirs ss_err.h mk_cmds ss.pc
|
|||
$(Q) $(INSTALL) mk_cmds $(DESTDIR)$(bindir)/mk_cmds
|
||||
$(E) " INSTALL_DATA $(man1dir)/mk_cmds.1"
|
||||
$(Q) $(INSTALL_DATA) $(srcdir)/mk_cmds.1 $(DESTDIR)$(man1dir)/mk_cmds.1
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/ss.pc"
|
||||
$(Q) $(INSTALL_DATA) ss.pc $(DESTDIR)$(libdir)/pkgconfig/ss.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/ss.pc"
|
||||
$(Q) $(INSTALL_DATA) ss.pc $(DESTDIR)$(pkgconfigdir)/ss.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libss.a $(DESTDIR)$(bindir)/mk_cmds \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/ss.pc \
|
||||
$(DESTDIR)$(pkgconfigdir)/ss.pc \
|
||||
$(DESTDIR)$(man1dir)/mk_cmds.1
|
||||
$(RM) -rf $(DESTDIR)$(includedir)/ss $(DESTDIR)$(datadir)/ss
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ installdirs::
|
|||
$(E) " MKINSTALLDIRS $(libdir) $(includedir)/uuid $(man3dir)"
|
||||
$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(includedir)/uuid $(DESTDIR)$(man3dir) \
|
||||
$(DESTDIR)$(libdir)/pkgconfig
|
||||
$(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install:: all installdirs
|
||||
$(E) " INSTALL_DATA $(libdir)/libuuid.a"
|
||||
|
@ -157,12 +157,12 @@ install:: all installdirs
|
|||
$(E) " LINK $(man3dir)/uuid_generate_time.3"
|
||||
$(Q) (cd $(DESTDIR)$(man3dir); \
|
||||
$(LN) $(LINK_INSTALL_FLAGS) uuid_generate.3 uuid_generate_time.3)
|
||||
$(E) " INSTALL_DATA $(libdir)/pkgconfig/uuid.pc"
|
||||
$(Q) $(INSTALL_DATA) uuid.pc $(DESTDIR)$(libdir)/pkgconfig/uuid.pc
|
||||
$(E) " INSTALL_DATA $(pkgconfigdir)/uuid.pc"
|
||||
$(Q) $(INSTALL_DATA) uuid.pc $(DESTDIR)$(pkgconfigdir)/uuid.pc
|
||||
|
||||
uninstall::
|
||||
$(RM) -f $(DESTDIR)$(libdir)/libuuid.a \
|
||||
$(DESTDIR)$(libdir)/pkgconfig/uuid.pc
|
||||
$(DESTDIR)$(pkgconfigdir)/uuid.pc
|
||||
for i in $(SMANPAGES); do \
|
||||
$(RM) -f $(DESTDIR)$(man3dir)/$$i; \
|
||||
done
|
||||
|
|
|
@ -165,6 +165,8 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
|
|||
strcat(flags, "unwritten,");
|
||||
if (fm_extent->fe_flags & FIEMAP_EXTENT_MERGED)
|
||||
strcat(flags, "merged,");
|
||||
if (fm_extent->fe_flags & FIEMAP_EXTENT_SHARED)
|
||||
strcat(flags, "shared,");
|
||||
|
||||
if (fm_extent->fe_logical + fm_extent->fe_length >= (__u64) st->st_size)
|
||||
strcat(flags, "eof,");
|
||||
|
|
|
@ -96,6 +96,8 @@ static __u32 fs_stride;
|
|||
static int quotatype = -1; /* Initialize both user and group quotas by default */
|
||||
static __u64 offset;
|
||||
static blk64_t journal_location = ~0LL;
|
||||
static int proceed_delay = -1;
|
||||
static blk64_t dev_size;
|
||||
|
||||
static struct ext2_super_block fs_param;
|
||||
static char *fs_uuid = NULL;
|
||||
|
@ -640,6 +642,14 @@ static void show_stats(ext2_filsys fs)
|
|||
dgrp_t i;
|
||||
int need, col_left;
|
||||
|
||||
if (!verbose) {
|
||||
printf(_("Creating filesystem with %llu %dk blocks and "
|
||||
"%u inodes\n"),
|
||||
ext2fs_blocks_count(s), fs->blocksize >> 10,
|
||||
s->s_inodes_count);
|
||||
goto skip_details;
|
||||
}
|
||||
|
||||
if (ext2fs_blocks_count(&fs_param) != ext2fs_blocks_count(s))
|
||||
fprintf(stderr, _("warning: %llu blocks unused.\n\n"),
|
||||
ext2fs_blocks_count(&fs_param) - ext2fs_blocks_count(s));
|
||||
|
@ -688,11 +698,14 @@ static void show_stats(ext2_filsys fs)
|
|||
s->s_blocks_per_group, s->s_clusters_per_group);
|
||||
printf(_("%u inodes per group\n"), s->s_inodes_per_group);
|
||||
|
||||
skip_details:
|
||||
if (fs->group_desc_count == 1) {
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e2p_is_null_uuid(s->s_uuid))
|
||||
printf(_("Filesystem UUID: %s\n"), e2p_uuid2str(s->s_uuid));
|
||||
printf("%s", _("Superblock backups stored on blocks: "));
|
||||
group_block = s->s_first_data_block;
|
||||
col_left = 0;
|
||||
|
@ -1411,7 +1424,7 @@ out:
|
|||
|
||||
static void PRS(int argc, char *argv[])
|
||||
{
|
||||
int b, c;
|
||||
int b, c, flags;
|
||||
int cluster_size = 0;
|
||||
char *tmp, **cpp;
|
||||
int blocksize = 0;
|
||||
|
@ -1420,14 +1433,13 @@ static void PRS(int argc, char *argv[])
|
|||
unsigned long flex_bg_size = 0;
|
||||
double reserved_ratio = -1.0;
|
||||
int lsector_size = 0, psector_size = 0;
|
||||
int show_version_only = 0;
|
||||
int show_version_only = 0, is_device = 0;
|
||||
unsigned long long num_inodes = 0; /* unsigned long long to catch too-large input */
|
||||
errcode_t retval;
|
||||
char * oldpath = getenv("PATH");
|
||||
char * extended_opts = 0;
|
||||
char * fs_type = 0;
|
||||
char * usage_types = 0;
|
||||
blk64_t dev_size;
|
||||
/*
|
||||
* NOTE: A few words about fs_blocks_count and blocksize:
|
||||
*
|
||||
|
@ -1789,8 +1801,18 @@ profile_error:
|
|||
if (optind < argc)
|
||||
usage();
|
||||
|
||||
if (!force)
|
||||
check_plausibility(device_name);
|
||||
profile_get_integer(profile, "options", "proceed_delay", 0, 0,
|
||||
&proceed_delay);
|
||||
|
||||
/* The isatty() test is so we don't break existing scripts */
|
||||
flags = CREATE_FILE;
|
||||
if (isatty(0) && isatty(1))
|
||||
flags |= CHECK_FS_EXIST;
|
||||
if (!quiet)
|
||||
flags |= VERBOSE_CREATE;
|
||||
if (!check_plausibility(device_name, flags, &is_device) && !force)
|
||||
proceed_question(proceed_delay);
|
||||
|
||||
check_mount(device_name, force, _("filesystem"));
|
||||
|
||||
/* Determine the size of the device (if possible) */
|
||||
|
@ -1832,10 +1854,10 @@ profile_error:
|
|||
fs_blocks_count &= ~((blk64_t) ((sys_page_size /
|
||||
EXT2_BLOCK_SIZE(&fs_param))-1));
|
||||
}
|
||||
} else if (!force && (fs_blocks_count > dev_size)) {
|
||||
} else if (!force && is_device && (fs_blocks_count > dev_size)) {
|
||||
com_err(program_name, 0, "%s",
|
||||
_("Filesystem larger than apparent device size."));
|
||||
proceed_question();
|
||||
proceed_question(proceed_delay);
|
||||
}
|
||||
|
||||
if (!fs_type)
|
||||
|
@ -2139,7 +2161,7 @@ profile_error:
|
|||
com_err(program_name, 0,
|
||||
_("%d-byte blocks too big for system (max %d)"),
|
||||
blocksize, sys_page_size);
|
||||
proceed_question();
|
||||
proceed_question(proceed_delay);
|
||||
}
|
||||
fprintf(stderr, _("Warning: %d-byte blocks too big for system "
|
||||
"(max %d), forced to continue\n"),
|
||||
|
@ -2664,7 +2686,7 @@ int main (int argc, char *argv[])
|
|||
journal_blocks = figure_journal_size(journal_size, fs);
|
||||
|
||||
/* Can't undo discard ... */
|
||||
if (!noaction && discard && (io_ptr != undo_io_manager)) {
|
||||
if (!noaction && discard && dev_size && (io_ptr != undo_io_manager)) {
|
||||
retval = mke2fs_discard_device(fs);
|
||||
if (!retval && io_channel_discard_zeroes_data(fs->io)) {
|
||||
if (verbose)
|
||||
|
@ -2897,8 +2919,9 @@ int main (int argc, char *argv[])
|
|||
if (journal_device) {
|
||||
ext2_filsys jfs;
|
||||
|
||||
if (!force)
|
||||
check_plausibility(journal_device);
|
||||
if (!check_plausibility(journal_device, CHECK_BLOCK_DEV,
|
||||
NULL) && !force)
|
||||
proceed_question(proceed_delay);
|
||||
check_mount(journal_device, force, _("journal"));
|
||||
|
||||
retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
|
||||
|
|
|
@ -68,7 +68,10 @@ The following stanzas are used in the
|
|||
.I mke2fs.conf
|
||||
file. They will be described in more detail in future sections of this
|
||||
document.
|
||||
.TP
|
||||
.TP
|
||||
.I [options]
|
||||
Contains relations which influence how mke2fs behaves.
|
||||
.TP
|
||||
.I [defaults]
|
||||
Contains relations which define the default parameters
|
||||
used by
|
||||
|
@ -84,6 +87,18 @@ the
|
|||
.B -T
|
||||
option to
|
||||
.BR mke2fs (8).
|
||||
.SH THE [options] STANZA
|
||||
The following relations are defined in the
|
||||
.I [options]
|
||||
stanza.
|
||||
.TP
|
||||
.I proceed_delay
|
||||
If this relation is set to a positive integer, then if mke2fs will
|
||||
proceed after waiting
|
||||
.I proceed_delay
|
||||
seconds, after asking the user for permission to proceed, even if the
|
||||
user has not answered the question. Defaults to 0, which means to wait
|
||||
until the user answers the question one way or another.
|
||||
.SH THE [defaults] STANZA
|
||||
The following relations are defined in the
|
||||
.I [defaults]
|
||||
|
|
|
@ -1184,7 +1184,9 @@ static int add_journal(ext2_filsys fs)
|
|||
goto err;
|
||||
}
|
||||
if (journal_device) {
|
||||
check_plausibility(journal_device);
|
||||
if (!check_plausibility(journal_device, CHECK_BLOCK_DEV,
|
||||
NULL))
|
||||
proceed_question(-1);
|
||||
check_mount(journal_device, 0, _("journal"));
|
||||
#ifdef CONFIG_TESTIO_DEBUG
|
||||
if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
|
||||
|
|
191
misc/util.c
191
misc/util.c
|
@ -13,6 +13,9 @@
|
|||
#define _LARGEFILE64_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
#include <fcntl.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_ERRNO_H
|
||||
|
@ -21,6 +24,7 @@
|
|||
#ifdef HAVE_LINUX_MAJOR_H
|
||||
#include <linux/major.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
@ -66,47 +70,201 @@ char *get_progname(char *argv_zero)
|
|||
return cp+1;
|
||||
}
|
||||
|
||||
void proceed_question(void)
|
||||
static jmp_buf alarm_env;
|
||||
|
||||
static void alarm_signal(int signal)
|
||||
{
|
||||
longjmp(alarm_env, 1);
|
||||
}
|
||||
|
||||
void proceed_question(int delay)
|
||||
{
|
||||
char buf[256];
|
||||
const char *short_yes = _("yY");
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fputs(_("Proceed anyway? (y,n) "), stdout);
|
||||
if (delay > 0) {
|
||||
if (setjmp(alarm_env)) {
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
printf(_("<proceeding>\n"));
|
||||
return;
|
||||
}
|
||||
signal(SIGALRM, alarm_signal);
|
||||
printf(_("Proceed anyway (or wait %d seconds) ? (y,n) "),
|
||||
delay);
|
||||
alarm(delay);
|
||||
} else
|
||||
fputs(_("Proceed anyway? (y,n) "), stdout);
|
||||
buf[0] = 0;
|
||||
if (!fgets(buf, sizeof(buf), stdin) ||
|
||||
strchr(short_yes, buf[0]) == 0)
|
||||
strchr(short_yes, buf[0]) == 0) {
|
||||
putc('\n', stdout);
|
||||
exit(1);
|
||||
}
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
}
|
||||
|
||||
void check_plausibility(const char *device)
|
||||
static void print_ext2_info(const char *device)
|
||||
|
||||
{
|
||||
int val;
|
||||
struct ext2_super_block *sb;
|
||||
ext2_filsys fs;
|
||||
errcode_t retval;
|
||||
time_t tm;
|
||||
char buf[80];
|
||||
|
||||
retval = ext2fs_open2(device, 0, EXT2_FLAG_64BITS, 0, 0,
|
||||
unix_io_manager, &fs);
|
||||
if (retval)
|
||||
return;
|
||||
sb = fs->super;
|
||||
|
||||
if (sb->s_mtime) {
|
||||
tm = sb->s_mtime;
|
||||
if (sb->s_last_mounted[0]) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
strncpy(buf, sb->s_last_mounted,
|
||||
sizeof(sb->s_last_mounted));
|
||||
printf(_("\tlast mounted on %s on %s"), buf,
|
||||
ctime(&tm));
|
||||
} else
|
||||
printf(_("\tlast mounted on %s"), ctime(&tm));
|
||||
} else if (sb->s_mkfs_time) {
|
||||
tm = sb->s_mkfs_time;
|
||||
printf(_("\tcreated on %s"), ctime(&tm));
|
||||
} else if (sb->s_wtime) {
|
||||
tm = sb->s_wtime;
|
||||
printf(_("\tlast modified on %s"), ctime(&tm));
|
||||
}
|
||||
ext2fs_close(fs);
|
||||
}
|
||||
|
||||
/*
|
||||
* return 1 if there is no partition table, 0 if a partition table is
|
||||
* detected, and -1 on an error.
|
||||
*/
|
||||
static int check_partition_table(const char *device)
|
||||
{
|
||||
#ifdef HAVE_BLKID_PROBE_ENABLE_PARTITIONS
|
||||
blkid_probe pr;
|
||||
const char *value;
|
||||
int ret;
|
||||
|
||||
pr = blkid_new_probe_from_filename(device);
|
||||
if (!pr)
|
||||
return -1;
|
||||
|
||||
ret = blkid_probe_enable_partitions(pr, 1);
|
||||
if (ret < 0)
|
||||
goto errout;
|
||||
|
||||
ret = blkid_probe_enable_superblocks(pr, 0);
|
||||
if (ret < 0)
|
||||
goto errout;
|
||||
|
||||
ret = blkid_do_fullprobe(pr);
|
||||
if (ret < 0)
|
||||
goto errout;
|
||||
|
||||
ret = blkid_probe_lookup_value(pr, "PTTYPE", &value, NULL);
|
||||
if (ret == 0)
|
||||
fprintf(stderr, _("Found a %s partition table in %s\n"),
|
||||
value, device);
|
||||
else
|
||||
ret = 1;
|
||||
|
||||
errout:
|
||||
blkid_free_probe(pr);
|
||||
return ret;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* return 1 if the device looks plausible, creating the file if necessary
|
||||
*/
|
||||
int check_plausibility(const char *device, int flags, int *ret_is_dev)
|
||||
{
|
||||
int fd, ret, is_dev = 0;
|
||||
ext2fs_struct_stat s;
|
||||
int fl = O_RDONLY;
|
||||
blkid_cache cache = NULL;
|
||||
char *fs_type = NULL;
|
||||
char *fs_label = NULL;
|
||||
|
||||
val = ext2fs_stat(device, &s);
|
||||
|
||||
if(val == -1) {
|
||||
fprintf(stderr, _("Could not stat %s --- %s\n"),
|
||||
fd = open(device, fl, 0666);
|
||||
if ((fd < 0) && (errno == ENOENT) && (flags & CREATE_FILE)) {
|
||||
fl |= O_CREAT;
|
||||
fd = open(device, fl, 0666);
|
||||
if (fd >= 0 && (flags & VERBOSE_CREATE))
|
||||
printf(_("Creating regular file %s\n"), device);
|
||||
}
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, _("Could not open %s: %s\n"),
|
||||
device, error_message(errno));
|
||||
if (errno == ENOENT)
|
||||
fputs(_("\nThe device apparently does not exist; "
|
||||
"did you specify it correctly?\n"), stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ext2fs_fstat(fd, &s) < 0) {
|
||||
perror("stat");
|
||||
exit(1);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
if (S_ISBLK(s.st_mode))
|
||||
is_dev = 1;
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
/* On FreeBSD, all disk devices are character specials */
|
||||
if (!S_ISBLK(s.st_mode) && !S_ISCHR(s.st_mode))
|
||||
#else
|
||||
if (!S_ISBLK(s.st_mode))
|
||||
if (S_ISCHR(s.st_mode))
|
||||
is_dev = 1;
|
||||
#endif
|
||||
{
|
||||
if (ret_is_dev)
|
||||
*ret_is_dev = is_dev;
|
||||
|
||||
if ((flags & CHECK_BLOCK_DEV) && !is_dev) {
|
||||
printf(_("%s is not a block special device.\n"), device);
|
||||
proceed_question();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: we use the older-style blkid API's here because we
|
||||
* want as much functionality to be available when using the
|
||||
* internal blkid library, when e2fsprogs is compiled for
|
||||
* non-Linux systems that will probably not have the libraries
|
||||
* from util-linux available. We only use the newer
|
||||
* blkid-probe interfaces to access functionality not
|
||||
* available in the original blkid library.
|
||||
*/
|
||||
if ((flags & CHECK_FS_EXIST) && blkid_get_cache(&cache, NULL) >= 0) {
|
||||
fs_type = blkid_get_tag_value(cache, "TYPE", device);
|
||||
if (fs_type)
|
||||
fs_label = blkid_get_tag_value(cache, "LABEL", device);
|
||||
blkid_put_cache(cache);
|
||||
}
|
||||
|
||||
if (fs_type) {
|
||||
if (fs_label)
|
||||
printf(_("%s contains a %s file system "
|
||||
"labelled '%s'\n"), device, fs_type, fs_label);
|
||||
else
|
||||
printf(_("%s contains a %s file system\n"), device,
|
||||
fs_type);
|
||||
if (strncmp(fs_type, "ext", 3) == 0)
|
||||
print_ext2_info(device);
|
||||
free(fs_type);
|
||||
free(fs_label);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = check_partition_table(device);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
|
||||
#ifdef HAVE_LINUX_MAJOR_H
|
||||
#ifndef MAJOR
|
||||
#define MAJOR(dev) ((dev)>>8)
|
||||
|
@ -133,9 +291,10 @@ void check_plausibility(const char *device)
|
|||
MINOR(s.st_rdev)%16 == 0))) {
|
||||
printf(_("%s is entire device, not just one partition!\n"),
|
||||
device);
|
||||
proceed_question();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
void check_mount(const char *device, int force, const char *type)
|
||||
|
|
13
misc/util.h
13
misc/util.h
|
@ -15,12 +15,21 @@ extern int journal_flags;
|
|||
extern char *journal_device;
|
||||
extern char *journal_location_string;
|
||||
|
||||
/*
|
||||
* Flags for check_plausibility()
|
||||
*/
|
||||
#define CHECK_BLOCK_DEV 0x0001
|
||||
#define CREATE_FILE 0x0002
|
||||
#define CHECK_FS_EXIST 0x0004
|
||||
#define VERBOSE_CREATE 0x0008
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
extern int strcasecmp (char *s1, char *s2);
|
||||
#endif
|
||||
extern char *get_progname(char *argv_zero);
|
||||
extern void proceed_question(void);
|
||||
extern void check_plausibility(const char *device);
|
||||
extern void proceed_question(int delay);
|
||||
extern int check_plausibility(const char *device, int flags,
|
||||
int *ret_is_dev);
|
||||
extern void parse_journal_opts(const char *opts);
|
||||
extern void check_mount(const char *device, int force, const char *type);
|
||||
extern unsigned int figure_journal_size(int size, ext2_filsys fs);
|
||||
|
|
|
@ -1945,6 +1945,8 @@ static errcode_t move_itables(ext2_resize_t rfs)
|
|||
|
||||
if (!diff)
|
||||
continue;
|
||||
if (diff < 0)
|
||||
diff = 0;
|
||||
|
||||
retval = io_channel_read_blk64(fs->io, old_blk,
|
||||
fs->inode_blocks_per_group,
|
||||
|
@ -2377,12 +2379,11 @@ static int calc_group_overhead(ext2_filsys fs, blk64_t grp,
|
|||
blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
||||
{
|
||||
ext2_ino_t inode_count;
|
||||
dgrp_t groups;
|
||||
dgrp_t groups, flex_groups;
|
||||
blk64_t blks_needed, data_blocks;
|
||||
blk64_t grp, data_needed, last_start;
|
||||
blk64_t overhead = 0;
|
||||
int old_desc_blocks;
|
||||
int extra_groups = 0;
|
||||
int flexbg_size = 1 << fs->super->s_log_groups_per_flex;
|
||||
|
||||
/*
|
||||
|
@ -2427,10 +2428,13 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* inode tables of slack space so the resize operation can be
|
||||
* guaranteed to finish.
|
||||
*/
|
||||
flex_groups = groups;
|
||||
if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) {
|
||||
extra_groups = flexbg_size - (groups & (flexbg_size - 1));
|
||||
data_needed += fs->inode_blocks_per_group * extra_groups;
|
||||
extra_groups = groups % flexbg_size;
|
||||
dgrp_t remainder = groups & (flexbg_size - 1);
|
||||
|
||||
flex_groups += flexbg_size - remainder;
|
||||
if (flex_groups > fs->group_desc_count)
|
||||
flex_groups = fs->group_desc_count;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2439,7 +2443,7 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
*/
|
||||
data_blocks = groups * EXT2_BLOCKS_PER_GROUP(fs->super);
|
||||
last_start = 0;
|
||||
for (grp = 0; grp < groups; grp++) {
|
||||
for (grp = 0; grp < flex_groups; grp++) {
|
||||
overhead = calc_group_overhead(fs, grp, old_desc_blocks);
|
||||
|
||||
/*
|
||||
|
@ -2447,11 +2451,14 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* the groups leading up to the last group so we can determine
|
||||
* how big the last group needs to be
|
||||
*/
|
||||
if (grp != (groups - 1))
|
||||
if (grp < (groups - 1))
|
||||
last_start += EXT2_BLOCKS_PER_GROUP(fs->super) -
|
||||
overhead;
|
||||
|
||||
data_blocks -= overhead;
|
||||
if (data_blocks > overhead)
|
||||
data_blocks -= overhead;
|
||||
else
|
||||
data_blocks = 0;
|
||||
}
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||
|
@ -2463,8 +2470,9 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* if we need more group descriptors in order to accomodate our data
|
||||
* then we need to add them here
|
||||
*/
|
||||
while (data_needed > data_blocks) {
|
||||
blk64_t remainder = data_needed - data_blocks;
|
||||
blks_needed = data_needed;
|
||||
while (blks_needed > data_blocks) {
|
||||
blk64_t remainder = blks_needed - data_blocks;
|
||||
dgrp_t extra_grps;
|
||||
|
||||
/* figure out how many more groups we need for the data */
|
||||
|
@ -2477,7 +2485,20 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
|
||||
last_start += EXT2_BLOCKS_PER_GROUP(fs->super) - overhead;
|
||||
|
||||
for (grp = groups; grp < groups+extra_grps; grp++) {
|
||||
grp = flex_groups;
|
||||
groups += extra_grps;
|
||||
if (!(fs->super->s_feature_incompat &
|
||||
EXT4_FEATURE_INCOMPAT_FLEX_BG))
|
||||
flex_groups = groups;
|
||||
else if (groups > flex_groups) {
|
||||
dgrp_t r = groups & (flexbg_size - 1);
|
||||
|
||||
flex_groups = groups + flexbg_size - r;
|
||||
if (flex_groups > fs->group_desc_count)
|
||||
flex_groups = fs->group_desc_count;
|
||||
}
|
||||
|
||||
for (; grp < flex_groups; grp++) {
|
||||
overhead = calc_group_overhead(fs, grp,
|
||||
old_desc_blocks);
|
||||
|
||||
|
@ -2485,41 +2506,31 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* again, we need to see how much data we cram into
|
||||
* all of the groups leading up to the last group
|
||||
*/
|
||||
if (grp != (groups + extra_grps - 1))
|
||||
if (grp < groups - 1)
|
||||
last_start += EXT2_BLOCKS_PER_GROUP(fs->super)
|
||||
- overhead;
|
||||
|
||||
data_blocks -= overhead;
|
||||
}
|
||||
|
||||
groups += extra_grps;
|
||||
extra_groups += extra_grps;
|
||||
if (fs->super->s_feature_incompat
|
||||
& EXT4_FEATURE_INCOMPAT_FLEX_BG
|
||||
&& extra_groups > flexbg_size) {
|
||||
/*
|
||||
* For ext4 we need to allow for up to a flex_bg worth
|
||||
* of inode tables of slack space so the resize
|
||||
* operation can be guaranteed to finish.
|
||||
*/
|
||||
extra_groups = flexbg_size -
|
||||
(groups & (flexbg_size - 1));
|
||||
data_needed += (fs->inode_blocks_per_group *
|
||||
extra_groups);
|
||||
extra_groups = groups % flexbg_size;
|
||||
}
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||
printf("Added %d extra group(s), "
|
||||
"data_needed %llu, data_blocks %llu, "
|
||||
"last_start %llu\n",
|
||||
extra_grps, data_needed, data_blocks,
|
||||
last_start);
|
||||
"blks_needed %llu, data_blocks %llu, "
|
||||
"last_start %llu\n", extra_grps, blks_needed,
|
||||
data_blocks, last_start);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* now for the fun voodoo */
|
||||
overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
|
||||
grp = groups - 1;
|
||||
if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
|
||||
(grp & ~(flexbg_size - 1)) == 0)
|
||||
grp = grp & ~(flexbg_size - 1);
|
||||
overhead = 0;
|
||||
for (; grp < flex_groups; grp++)
|
||||
overhead += calc_group_overhead(fs, grp, old_desc_blocks);
|
||||
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||
printf("Last group's overhead is %llu\n", overhead);
|
||||
|
@ -2529,8 +2540,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* if this is the case then the last group is going to have data in it
|
||||
* so we need to adjust the size of the last group accordingly
|
||||
*/
|
||||
if (last_start < data_needed) {
|
||||
blk64_t remainder = data_needed - last_start;
|
||||
if (last_start < blks_needed) {
|
||||
blk64_t remainder = blks_needed - last_start;
|
||||
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||
|
@ -2556,10 +2567,15 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
printf("Final size of last group is %lld\n", overhead);
|
||||
#endif
|
||||
|
||||
/* Add extra slack for bigalloc file systems */
|
||||
if (EXT2FS_CLUSTER_RATIO(fs) > 1)
|
||||
overhead += EXT2FS_CLUSTER_RATIO(fs) * 2;
|
||||
|
||||
/*
|
||||
* since our last group doesn't have to be BLOCKS_PER_GROUP large, we
|
||||
* only do groups-1, and then add the number of blocks needed to
|
||||
* handle the group descriptor metadata+data that we need
|
||||
* since our last group doesn't have to be BLOCKS_PER_GROUP
|
||||
* large, we only do groups-1, and then add the number of
|
||||
* blocks needed to handle the group descriptor metadata+data
|
||||
* that we need
|
||||
*/
|
||||
blks_needed = (groups-1) * EXT2_BLOCKS_PER_GROUP(fs->super);
|
||||
blks_needed += overhead;
|
||||
|
@ -2588,10 +2604,26 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
|||
* We need to reserve a few extra blocks if extents are
|
||||
* enabled, in case we need to grow the extent tree. The more
|
||||
* we shrink the file system, the more space we need.
|
||||
*
|
||||
* The absolute worst case is every single data block is in
|
||||
* the part of the file system that needs to be evacuated,
|
||||
* with each data block needs to be in its own extent, and
|
||||
* with each inode needing at least one extent block.
|
||||
*/
|
||||
if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) {
|
||||
blk64_t safe_margin = (ext2fs_blocks_count(fs->super) -
|
||||
blks_needed)/500;
|
||||
unsigned int exts_per_blk = (fs->blocksize /
|
||||
sizeof(struct ext3_extent)) - 1;
|
||||
blk64_t worst_case = ((data_needed + exts_per_blk - 1) /
|
||||
exts_per_blk);
|
||||
|
||||
if (worst_case < inode_count)
|
||||
worst_case = inode_count;
|
||||
|
||||
if (safe_margin > worst_case)
|
||||
safe_margin = worst_case;
|
||||
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||
printf("Extents safety margin: %llu\n", safe_margin);
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
mke2fs -F -O resize_inode -o Linux -b 1024 -g 1024 test.img 16384
|
||||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
4096 inodes, 16384 blocks
|
||||
819 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=8421376
|
||||
16 block groups
|
||||
1024 blocks per group, 1024 fragments per group
|
||||
256 inodes per group
|
||||
Creating filesystem with 16384 1k blocks and 4096 inodes
|
||||
Superblock backups stored on blocks:
|
||||
1025, 3073, 5121, 7169, 9217
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=2048 (log=1)
|
||||
Fragment size=2048 (log=1)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
16384 inodes, 32768 blocks
|
||||
1638 blocks (5.00%) reserved for the super user
|
||||
First data block=0
|
||||
Maximum filesystem blocks=33554432
|
||||
2 block groups
|
||||
16384 blocks per group, 16384 fragments per group
|
||||
8192 inodes per group
|
||||
Creating filesystem with 32768 2k blocks and 16384 inodes
|
||||
Superblock backups stored on blocks:
|
||||
16384
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
8192 inodes, 131072 blocks
|
||||
6553 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=2228224
|
||||
128 block groups
|
||||
1024 blocks per group, 1024 fragments per group
|
||||
64 inodes per group
|
||||
Creating filesystem with 131072 1k blocks and 8192 inodes
|
||||
Superblock backups stored on blocks:
|
||||
1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
16384 inodes, 65536 blocks
|
||||
3276 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=67108864
|
||||
8 block groups
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
2048 inodes per group
|
||||
Creating filesystem with 65536 1k blocks and 16384 inodes
|
||||
Superblock backups stored on blocks:
|
||||
8193, 24577, 40961, 57345
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=4096 (log=2)
|
||||
Fragment size=4096 (log=2)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
64 inodes, 16384 blocks
|
||||
819 blocks (5.00%) reserved for the super user
|
||||
First data block=0
|
||||
Maximum filesystem blocks=16777216
|
||||
1 block group
|
||||
32768 blocks per group, 32768 fragments per group
|
||||
64 inodes per group
|
||||
Creating filesystem with 16384 4k blocks and 64 inodes
|
||||
|
||||
Allocating group tables: done
|
||||
Writing inode tables: done
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
32768 inodes, 131072 blocks
|
||||
6553 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
128 block groups
|
||||
1024 blocks per group, 1024 fragments per group
|
||||
256 inodes per group
|
||||
Creating filesystem with 131072 1k blocks and 32768 inodes
|
||||
Superblock backups stored on blocks:
|
||||
1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=4096 (log=2)
|
||||
Fragment size=4096 (log=2)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
65536 inodes, 65536 blocks
|
||||
3276 blocks (5.00%) reserved for the super user
|
||||
First data block=0
|
||||
Maximum filesystem blocks=67108864
|
||||
2 block groups
|
||||
32768 blocks per group, 32768 fragments per group
|
||||
32768 inodes per group
|
||||
Creating filesystem with 65536 4k blocks and 65536 inodes
|
||||
Superblock backups stored on blocks:
|
||||
32768
|
||||
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
16384 inodes, 65536 blocks
|
||||
3276 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
8 block groups
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
2048 inodes per group
|
||||
Creating filesystem with 65536 1k blocks and 16384 inodes
|
||||
Superblock backups stored on blocks:
|
||||
8193, 16385, 24577, 32769, 40961, 49153, 57345
|
||||
|
||||
|
|
|
@ -2,18 +2,7 @@
|
|||
Warning: the quota feature is still under development
|
||||
See https://ext4.wiki.kernel.org/index.php/Quota for more information
|
||||
|
||||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
32768 inodes, 131072 blocks
|
||||
6553 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=67371008
|
||||
16 block groups
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
2048 inodes per group
|
||||
Creating filesystem with 131072 1k blocks and 32768 inodes
|
||||
Superblock backups stored on blocks:
|
||||
8193, 24577, 40961, 57345, 73729
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=13 blocks, Stripe width=0 blocks
|
||||
32768 inodes, 131072 blocks
|
||||
6553 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=8519680
|
||||
128 block groups
|
||||
1024 blocks per group, 1024 fragments per group
|
||||
256 inodes per group
|
||||
Creating filesystem with 131072 1k blocks and 32768 inodes
|
||||
Superblock backups stored on blocks:
|
||||
1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
|
||||
|
||||
|
|
|
@ -1,16 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
128 inodes, 1024 blocks
|
||||
51 blocks (4.98%) reserved for the super user
|
||||
First data block=1
|
||||
Root directory owner=1234:1234
|
||||
Maximum filesystem blocks=1048576
|
||||
1 block group
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
128 inodes per group
|
||||
Creating filesystem with 1024 1k blocks and 128 inodes
|
||||
|
||||
Allocating group tables: done
|
||||
Writing inode tables: done
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
16384 inodes, 65536 blocks
|
||||
3276 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=67108864
|
||||
8 block groups
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
2048 inodes per group
|
||||
Creating filesystem with 65536 1k blocks and 16384 inodes
|
||||
Superblock backups stored on blocks:
|
||||
8193, 24577, 40961, 57345
|
||||
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
Filesystem label=
|
||||
OS type: Linux
|
||||
Block size=1024 (log=0)
|
||||
Fragment size=1024 (log=0)
|
||||
Stride=0 blocks, Stripe width=0 blocks
|
||||
32768 inodes, 131072 blocks
|
||||
6553 blocks (5.00%) reserved for the super user
|
||||
First data block=1
|
||||
Maximum filesystem blocks=67371008
|
||||
16 block groups
|
||||
8192 blocks per group, 8192 fragments per group
|
||||
2048 inodes per group
|
||||
Creating filesystem with 131072 1k blocks and 32768 inodes
|
||||
Superblock backups stored on blocks:
|
||||
8193, 24577, 40961, 57345, 73729
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ truncate()
|
|||
}
|
||||
|
||||
resize_test () {
|
||||
DBG_FLAGS=63
|
||||
|
||||
echo $test_description starting > $LOG
|
||||
rm -f $TMPFILE
|
||||
|
@ -57,8 +58,8 @@ rm -f $OUT_TMP
|
|||
echo $FSCK -fy $TMPFILE >> $LOG 2>&1
|
||||
$FSCK -fy $TMPFILE >> $LOG 2>&1
|
||||
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
@ -82,8 +83,13 @@ then
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
# Uncomment to grab extra debugging image
|
||||
#
|
||||
#mv $TMPFILE /tmp/foo.img
|
||||
#return 0
|
||||
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
@ -107,8 +113,8 @@ then
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
@ -132,8 +138,8 @@ then
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue