#include <fcntl.h>
#include <ctype.h>
#include <time.h>
-#ifdef __linux__
-#include <sys/utsname.h>
-#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
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;
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
*/
#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);
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;
}
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|
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) {
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);
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)
* 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;
{
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;