#define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */
#define _BSD_SOURCE /* for makedev() and major() */
+#define _DEFAULT_SOURCE /* since glibc 2.20 _BSD_SOURCE is deprecated */
#include "config.h"
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif
#include <libgen.h>
#include <limits.h>
#include <blkid/blkid.h>
#include "e2p/e2p.h"
#include "ext2fs/ext2fs.h"
#include "util.h"
-#include "profile.h"
-#include "prof_err.h"
-#include "nls-enable.h"
+#include "support/profile.h"
+#include "support/prof_err.h"
+#include "support/nls-enable.h"
#include "mke2fs.h"
static int uid;
static char *fn_numbuf;
int zero_hugefile = 1;
-#define SYSFS_PATH_LEN 256
+#define SYSFS_PATH_LEN 300
typedef char sysfs_path_t[SYSFS_PATH_LEN];
#ifndef HAVE_SNPRINTF
if (retval)
return retval;
+ /*
+ * We don't use ext2fs_fallocate() here because hugefiles are
+ * designed to be physically contiguous (if the block group
+ * descriptors are configured to be in a single block at the
+ * beginning of the file system, by using the
+ * packed_meta_blocks layout), with the extent tree blocks
+ * allocated near the beginning of the file system.
+ */
lblk = 0;
left = num ? num : 1;
while (left) {
if (retval)
com_err(program_name, retval,
_("while zeroing block %llu "
- "for hugefile"), ret_blk);
+ "for hugefile"),
+ (unsigned long long) ret_blk);
}
while (n) {
e_blocks2 = (e_blocks + extents_per_block - 1) / extents_per_block;
e_blocks3 = (e_blocks2 + extents_per_block - 1) / extents_per_block;
e_blocks4 = (e_blocks3 + extents_per_block - 1) / extents_per_block;
- return e_blocks + e_blocks2 + e_blocks3 + e_blocks4;
+ return (e_blocks + e_blocks2 + e_blocks3 + e_blocks4) *
+ EXT2FS_CLUSTER_RATIO(fs);
}
/*
if (!get_bool_from_profile(fs_types, "make_hugefiles", 0))
return 0;
- if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
- EXT3_FEATURE_INCOMPAT_EXTENTS))
+ if (!ext2fs_has_feature_extents(fs->super))
return EXT2_ET_EXTENT_NOT_SUPPORTED;
uid = get_int_from_profile(fs_types, "hugefiles_uid", 0);
fprintf(stderr,
_("Partition offset of %llu (%uk) blocks "
"not compatible with cluster size %u.\n"),
- part_offset, fs->blocksize,
+ (unsigned long long) part_offset, fs->blocksize,
EXT2_CLUSTER_SIZE(fs->super));
exit(1);
}
num_blocks = fs_blocks / num_files;
}
- num_slack += calc_overhead(fs, num_blocks) * num_files;
+ num_slack += (calc_overhead(fs, num_blocks ? num_blocks : fs_blocks) *
+ num_files);
num_slack += (num_files / 16) + 1; /* space for dir entries */
goal = get_start_block(fs, num_slack);
goal = round_up_align(goal, align, part_offset);
if ((num_blocks ? num_blocks : fs_blocks) >
(0x80000000UL / fs->blocksize))
- fs->super->s_feature_ro_compat |=
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
+ ext2fs_set_feature_large_file(fs->super);
if (!quiet) {
if (zero_hugefile && verbose)
printf("%s", _("Huge files will be zero'ed\n"));
printf(_("Creating %lu huge file(s) "), num_files);
if (num_blocks)
- printf(_("with %llu blocks each"), num_blocks);
+ printf(_("with %llu blocks each"),
+ (unsigned long long) num_blocks);
fputs(": ", stdout);
}
for (i=0; i < num_files; i++) {