X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=misc%2Fmke2fs.c;h=0e4d493e8c5b25cbbe4b0ded3d17679da10eaf6c;hb=refs%2Fchanges%2F61%2F15761%2F21;hp=c9f5810aa51c184cb1639087c4de5851c7782f9a;hpb=ceec1709f7b3f2dbdbff6cc6559a3f77f19b9f3e;p=tools%2Fe2fsprogs.git diff --git a/misc/mke2fs.c b/misc/mke2fs.c index c9f5810..0e4d493 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -25,10 +25,6 @@ #include #include #include -#ifdef __linux__ -#include -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif #ifdef HAVE_GETOPT_H #include #else @@ -99,7 +95,8 @@ static int lazy_itable_init; static int packed_meta_blocks; static char *bad_blocks_filename = NULL; static __u32 fs_stride; -static int quotatype = -1; /* Initialize both user and group quotas by default */ +/* Initialize usr/grp quotas by default */ +static unsigned int quotatype_bits = (QUOTA_USR_BIT | QUOTA_GRP_BIT); static __u64 offset; static blk64_t journal_location = ~0LL; static int proceed_delay = -1; @@ -155,54 +152,6 @@ int int_log10(unsigned long long arg) return l; } -#ifdef __linux__ -static int parse_version_number(const char *s) -{ - int major, minor, rev; - char *endptr; - const char *cp = s; - - if (!s) - return 0; - major = strtol(cp, &endptr, 10); - if (cp == endptr || *endptr != '.') - return 0; - cp = endptr + 1; - minor = strtol(cp, &endptr, 10); - if (cp == endptr || *endptr != '.') - return 0; - cp = endptr + 1; - rev = strtol(cp, &endptr, 10); - if (cp == endptr) - return 0; - return KERNEL_VERSION(major, minor, rev); -} - -static int is_before_linux_ver(unsigned int major, unsigned int minor, - unsigned int rev) -{ - struct utsname ut; - static int linux_version_code = -1; - - if (uname(&ut)) { - perror("uname"); - exit(1); - } - if (linux_version_code < 0) - linux_version_code = parse_version_number(ut.release); - if (linux_version_code == 0) - return 0; - - return linux_version_code < KERNEL_VERSION(major, minor, rev); -} -#else -static int is_before_linux_ver(unsigned int major, unsigned int minor, - unsigned int rev) -{ - return 0; -} -#endif - /* * Helper function for read_bb_file and test_disk */ @@ -729,12 +678,28 @@ static int set_os(struct ext2_super_block *sb, char *os) #define PATH_SET "PATH=/sbin" +static int option_handle_function(char *token, void *data) +{ + if (!strncmp(token, "usr", 3)) { + quotatype_bits |= QUOTA_USR_BIT; + } else if (!strncmp(token, "grp", 3)) { + quotatype_bits |= QUOTA_GRP_BIT; + } else { + fprintf(stderr, _("Invalid quotatype parameter: %s\n"), + token); + return 1; + } + return 0; + +} + static void parse_extended_opts(struct ext2_super_block *param, const char *opts) { char *buf, *token, *next, *p, *arg, *badopt = 0; int len; int r_usage = 0; + int ret; len = strlen(opts); buf = malloc(len+1); @@ -969,14 +934,9 @@ static void parse_extended_opts(struct ext2_super_block *param, badopt = token; continue; } - if (!strncmp(arg, "usr", 3)) { - quotatype = 0; - } else if (!strncmp(arg, "grp", 3)) { - quotatype = 1; - } else { - fprintf(stderr, - _("Invalid quotatype parameter: %s\n"), - arg); + ret = parse_quota_opts(arg, option_handle_function, + NULL); + if (ret) { r_usage++; continue; } @@ -1032,7 +992,9 @@ static __u32 ok_features[3] = { EXT3_FEATURE_INCOMPAT_JOURNAL_DEV| EXT2_FEATURE_INCOMPAT_META_BG| EXT4_FEATURE_INCOMPAT_FLEX_BG| + EXT4_FEATURE_INCOMPAT_EA_INODE| EXT4_FEATURE_INCOMPAT_MMP | + EXT4_FEATURE_INCOMPAT_DIRDATA| EXT4_FEATURE_INCOMPAT_64BIT, /* R/O compat */ EXT2_FEATURE_RO_COMPAT_LARGE_FILE| @@ -1499,7 +1461,7 @@ profile_error: memset(&fs_param, 0, sizeof(struct ext2_super_block)); fs_param.s_rev_level = 1; /* Create revision 1 filesystems now */ - if (is_before_linux_ver(2, 2, 0)) + if (ext2fs_is_before_linux_ver(2, 2, 0)) fs_param.s_rev_level = 0; if (argc && *argv) { @@ -1873,7 +1835,7 @@ profile_error: tmp = NULL; if (fs_param.s_rev_level != EXT2_GOOD_OLD_REV) { tmp = get_string_from_profile(fs_types, "base_features", - "sparse_super,filetype,resize_inode,dir_index"); + "sparse_super,large_file,filetype,resize_inode,dir_index"); edit_feature(tmp, &fs_param.s_feature_compat); free(tmp); @@ -1931,7 +1893,8 @@ profile_error: if (use_bsize == -1) { use_bsize = sys_page_size; - if (is_before_linux_ver(2, 6, 0) && use_bsize > 4096) + if (ext2fs_is_before_linux_ver(2, 6, 0) && + use_bsize > 4096) use_bsize = 4096; } if (lsector_size && use_bsize < lsector_size) @@ -2130,7 +2093,7 @@ profile_error: * On newer kernels we do have lazy_itable_init support. So pick the * right default in case ext4 module is not loaded. */ - if (is_before_linux_ver(2, 6, 37)) + if (ext2fs_is_before_linux_ver(2, 6, 37)) lazy_itable_init = 0; else lazy_itable_init = 1; @@ -2526,9 +2489,9 @@ static int create_quota_inodes(ext2_filsys fs) { quota_ctx_t qctx; - quota_init_context(&qctx, fs, -1); + quota_init_context(&qctx, fs, QUOTA_ALL_BIT); quota_compute_usage(qctx); - quota_write_inode(qctx, quotatype); + quota_write_inode(qctx, quotatype_bits); quota_release_context(&qctx); return 0;