const char *src_root_dir; /* Copy files from the specified directory */
static char *undo_file;
+static int android_sparse_file; /* -E android_sparse */
+static char *android_sparse_params;
+
static profile_t profile;
static int sys_page_size = 4096;
int retval;
unsigned int *magic;
- buf = malloc(512*nsect);
+ buf = calloc(512, nsect);
if (!buf) {
printf(_("Out of memory erasing sectors %d-%d\n"),
sect, sect + nsect - 1);
badopt = token;
continue;
}
+ } else if (!strcmp(token, "android_sparse")) {
+ android_sparse_file = 1;
} else {
r_usage++;
badopt = token;
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_64BIT|
EXT4_FEATURE_INCOMPAT_INLINE_DATA|
ext2fs_clear_feature_filetype(&fs_param);
ext2fs_clear_feature_huge_file(&fs_param);
ext2fs_clear_feature_metadata_csum(&fs_param);
+ ext2fs_clear_feature_ea_inode(&fs_param);
}
edit_feature(fs_features ? fs_features : tmp,
&fs_param.s_feature_compat);
"metadata_csum feature.\n"));
exit(1);
}
+ if (ext2fs_has_feature_ea_inode(&fs_param)) {
+ fprintf(stderr, "%s", _("The HURD does not support the "
+ "ea_inode feature.\n"));
+ exit(1);
+ }
}
/* Get the hardware sector sizes, if available */
(unsigned long long) fs_blocks_count);
}
+ if (quotatype_bits & QUOTA_PRJ_BIT)
+ ext2fs_set_feature_project(&fs_param);
+
+ if (ext2fs_has_feature_project(&fs_param)) {
+ quotatype_bits |= QUOTA_PRJ_BIT;
+ if (inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ com_err(program_name, 0,
+ _("%d byte inodes are too small for "
+ "project quota"),
+ inode_size);
+ exit(1);
+ }
+ if (inode_size == 0) {
+ inode_size = get_int_from_profile(fs_types,
+ "inode_size", 0);
+ if (inode_size <= EXT2_GOOD_OLD_INODE_SIZE*2)
+ inode_size = EXT2_GOOD_OLD_INODE_SIZE*2;
+ }
+ }
+
/* Don't allow user to set both metadata_csum and uninit_bg bits. */
if (ext2fs_has_feature_metadata_csum(&fs_param) &&
ext2fs_has_feature_gdt_csum(&fs_param))
exit(1);
}
- /*
- * If inode size is 128 and project quota is enabled, we need
- * to notify users that project ID will never be useful.
- */
- if (ext2fs_has_feature_project(&fs_param) &&
- fs_param.s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
- com_err(program_name, 0,
- _("%d byte inodes are too small for project quota; "
- "specify larger size"),
- fs_param.s_inode_size);
- exit(1);
- }
-
/* Make sure number of inodes specified will fit in 32 bits */
if (num_inodes == 0) {
unsigned long long n;
*/
if (!quiet)
flags |= EXT2_FLAG_PRINT_PROGRESS;
- retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
+ if (android_sparse_file) {
+ android_sparse_params = malloc(PATH_MAX + 32);
+ if (!android_sparse_params) {
+ com_err(program_name, ENOMEM, "%s",
+ _("in malloc for android_sparse_params"));
+ exit(1);
+ }
+ snprintf(android_sparse_params, PATH_MAX + 32, "%s:%u:%u",
+ device_name, fs_param.s_blocks_count,
+ 1024 << fs_param.s_log_block_size);
+ retval = ext2fs_initialize(android_sparse_params, flags,
+ &fs_param, sparse_io_manager, &fs);
+ } else
+ retval = ext2fs_initialize(device_name, flags, &fs_param,
+ io_ptr, &fs);
if (retval) {
com_err(device_name, retval, "%s",
_("while setting up superblock"));
* Parse or generate a UUID for the filesystem
*/
if (fs_uuid) {
- if (uuid_parse(fs_uuid, fs->super->s_uuid) !=0) {
+ if ((strcasecmp(fs_uuid, "null") == 0) ||
+ (strcasecmp(fs_uuid, "clear") == 0)) {
+ uuid_clear(fs->super->s_uuid);
+ } else if (strcasecmp(fs_uuid, "time") == 0) {
+ uuid_generate_time(fs->super->s_uuid);
+ } else if (strcasecmp(fs_uuid, "random") == 0) {
+ uuid_generate(fs->super->s_uuid);
+ } else if (uuid_parse(fs_uuid, fs->super->s_uuid) != 0) {
com_err(device_name, 0, "could not parse UUID: %s\n",
fs_uuid);
exit(1);
if (ext2fs_has_feature_bigalloc(&fs_param))
fix_cluster_bg_counts(fs);
- if (ext2fs_has_feature_project(&fs_param))
- quotatype_bits |= QUOTA_PRJ_BIT;
if (ext2fs_has_feature_quota(&fs_param))
create_quota_inodes(fs);