From: Theodore Ts'o Date: Wed, 18 Jun 2008 03:54:51 +0000 (-0400) Subject: Merge branch 'maint' X-Git-Tag: v1.41-WIP-0707~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71ff129e9f5c942ce4d2eb20e269100d15c1a6ae;p=thirdparty%2Fe2fsprogs.git Merge branch 'maint' Conflicts: README resize/online.c version.h --- 71ff129e9f5c942ce4d2eb20e269100d15c1a6ae diff --cc misc/mke2fs.c index ff442043f,10ac78206..7430d481f --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@@ -1694,106 -1562,10 +1694,106 @@@ static void PRS(int argc, char *argv[] /* * Calculate number of blocks to reserve */ - fs_param.s_r_blocks_count = e2p_percent(reserved_ratio, - fs_param.s_blocks_count); + fs_param.s_r_blocks_count = (unsigned int) (reserved_ratio * + fs_param.s_blocks_count / 100.0); } +static int should_do_undo(const char *name) +{ + errcode_t retval; + io_channel channel; + __u16 s_magic; + struct ext2_super_block super; + io_manager manager = unix_io_manager; + int csum_flag, force_undo; + + csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(&fs_param, + EXT4_FEATURE_RO_COMPAT_GDT_CSUM); + force_undo = get_int_from_profile(fs_types, "force_undo", 0); + if (!force_undo && (!csum_flag || !lazy_itable_init)) + return 0; + + retval = manager->open(name, IO_FLAG_EXCLUSIVE, &channel); + if (retval) { + /* + * We don't handle error cases instead we + * declare that the file system doesn't exist + * and let the rest of mke2fs take care of + * error + */ + retval = 0; + goto open_err_out; + } + + io_channel_set_blksize(channel, SUPERBLOCK_OFFSET); + retval = io_channel_read_blk(channel, 1, -SUPERBLOCK_SIZE, &super); + if (retval) { + retval = 0; + goto err_out; + } + +#if defined(WORDS_BIGENDIAN) + s_magic = ext2fs_swab16(super.s_magic); +#else + s_magic = super.s_magic; +#endif + + if (s_magic == EXT2_SUPER_MAGIC) + retval = 1; + +err_out: + io_channel_close(channel); + +open_err_out: + + return retval; +} + +static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr) +{ + errcode_t retval = 0; + char *tdb_dir, tdb_file[PATH_MAX]; + char *device_name, *tmp_name; + + /* + * Configuration via a conf file would be + * nice + */ + tdb_dir = getenv("E2FSPROGS_UNDO_DIR"); + if (!tdb_dir) + profile_get_string(profile, "defaults", + "undo_dir", 0, "/var/lib/e2fsprogs", + &tdb_dir); + + if (!strcmp(tdb_dir, "none") || (tdb_dir[0] == 0) || + access(tdb_dir, W_OK)) + return 0; + + tmp_name = strdup(name); + device_name = basename(tmp_name); + sprintf(tdb_file, "%s/mke2fs-%s.e2undo", tdb_dir, device_name); + + if (!access(tdb_file, F_OK)) { + if (unlink(tdb_file) < 0) { + retval = errno; + com_err(program_name, retval, + _("while trying to delete %s"), + tdb_file); + return retval; + } + } + + set_undo_io_backing_manager(*io_ptr); + *io_ptr = undo_io_manager; + set_undo_io_backup_file(tdb_file); + printf(_("Overwriting existing filesystem; this can be undone " + "using the command:\n" + " e2undo %s %s\n\n"), tdb_file, name); +err_out: + free(tmp_name); + return retval; +} + int main (int argc, char *argv[]) { errcode_t retval = 0; diff --cc resize/online.c index d7dc857ca,419d489bd..f96ac10f1 --- a/resize/online.c +++ b/resize/online.c @@@ -28,10 -27,10 +28,11 @@@ errcode_t online_resize_fs(ext2_filsys unsigned long new_desc_blocks; ext2_filsys new_fs; errcode_t retval; + double percent; dgrp_t i; blk_t size; - int fd, r_frac, overhead; + int fd, overhead; + int use_old_ioctl = 1; printf(_("Filesystem at %s is mounted on %s; " "on-line resizing required\n"), fs->device_name, mtpt); diff --cc resize/resize2fs.c index 027315c6d,c6cadb85b..05650a814 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@@ -188,8 -186,9 +188,9 @@@ errcode_t adjust_fs_info(ext2_filsys fs int adj, old_numblocks, numblocks, adjblocks; unsigned long i, j, old_desc_blocks, max_group; unsigned int meta_bg, meta_bg_size; - int has_super; + int has_super, csum_flag; unsigned long long new_inodes; /* u64 to check for overflow */ + double percent; fs->super->s_blocks_count = new_size;