summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/Android.bp81
-rw-r--r--misc/badblocks.c39
-rw-r--r--misc/e4defrag.c13
-rw-r--r--misc/fuse2fs.c7
4 files changed, 93 insertions, 47 deletions
diff --git a/misc/Android.bp b/misc/Android.bp
index 2b1620ac..0656bf48 100644
--- a/misc/Android.bp
+++ b/misc/Android.bp
@@ -22,16 +22,13 @@ cc_library {
target: {
windows: {
- include_dirs: [ "external/e2fsprogs/include/mingw" ],
enabled: true,
- cflags: ["-Wno-unused-variable"],
},
},
srcs: [
"create_inode.c",
],
- cflags: ["-Wno-error=format-extra-args"],
shared_libs: [
"libext2fs",
"libext2_com_err",
@@ -43,9 +40,8 @@ cc_library {
//########################################################################
// Build mke2fs
-cc_binary {
- name: "mke2fs",
- host_supported: true,
+cc_defaults {
+ name: "mke2fs_defaults",
recovery_available: true,
defaults: ["e2fsprogs-defaults"],
@@ -55,11 +51,14 @@ cc_binary {
"mk_hugefiles.c",
"default_profile.c",
],
- cflags: [
- "-Wno-error=format",
- "-Wno-error=type-limits",
- "-Wno-format-extra-args",
- ],
+ stl: "libc++_static",
+ include_dirs: ["external/e2fsprogs/e2fsck"],
+}
+
+cc_binary {
+ name: "mke2fs",
+ host_supported: true,
+ defaults: ["mke2fs_defaults"],
target: {
host: {
static_libs: [
@@ -81,15 +80,8 @@ cc_binary {
],
},
windows: {
- include_dirs: [ "external/e2fsprogs/include/mingw" ],
- cflags: [
- // mke2fs.c has a warning from gcc which cannot be suppressed:
- // passing argument 3 of 'ext2fs_get_device_size' from
- // incompatible pointer type
- "-Wno-error"
- ],
ldflags: ["-static"],
- enabled: true
+ enabled: true,
},
android: {
required: [
@@ -104,11 +96,39 @@ cc_binary {
"libext2_com_err",
"libext2_e2p",
],
- symlinks: ["mkfs.ext2", "mkfs.ext3", "mkfs.ext4"],
+ symlinks: [
+ "mkfs.ext2",
+ "mkfs.ext3",
+ "mkfs.ext4",
+ ],
},
},
- stl: "libc++_static",
- include_dirs: ["external/e2fsprogs/e2fsck"],
+}
+
+cc_binary {
+ name: "mke2fs.microdroid",
+ defaults: ["mke2fs_defaults"],
+ bootstrap: true,
+ target: {
+ android: {
+ required: [
+ "mke2fs.conf",
+ ],
+ shared_libs: [
+ "libext2fs",
+ "libext2_blkid",
+ "libext2_misc",
+ "libext2_uuid",
+ "libext2_quota",
+ "libext2_com_err",
+ "libext2_e2p",
+ ],
+ symlinks: ["mkfs.ext4.microdroid"],
+ },
+ },
+ installable: false,
+ stem: "mke2fs",
+ visibility: ["//packages/modules/Virtualization/microdroid"],
}
//##########################################################################
@@ -236,6 +256,7 @@ cc_binary {
cc_binary {
name: "blkid",
+ host_supported: true,
defaults: ["e2fsprogs-defaults"],
srcs: ["blkid.c"],
@@ -247,6 +268,22 @@ cc_binary {
],
}
+cc_binary {
+ name: "blkid_static",
+ host_supported: true,
+ static_executable: true,
+ defaults: ["e2fsprogs-defaults"],
+
+ srcs: ["blkid.c"],
+ static_libs: [
+ "libext2fs",
+ "libext2_blkid",
+ "libext2_com_err",
+ "libext2_e2p",
+ "libext2_uuid",
+ ],
+}
+
//########################################################################
// Build e4crypt
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 3dedf763..2b5ff6d8 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -389,7 +389,7 @@ static int do_read (int dev, unsigned char * buffer, int try, int block_size,
/* Try the read */
if (d_flag)
gettimeofday(&tv1, NULL);
- got = read (dev, buffer, try * block_size);
+ got = read (dev, buffer, (size_t) try * block_size);
if (d_flag)
gettimeofday(&tv2, NULL);
if (got < 0)
@@ -460,7 +460,7 @@ static int do_write(int dev, unsigned char * buffer, int try, int block_size,
com_err (program_name, errno, "%s", _("during seek"));
/* Try the write */
- got = write (dev, buffer, try * block_size);
+ got = write (dev, buffer, (size_t) try * block_size);
if (got < 0)
got = 0;
if (got & 511)
@@ -510,9 +510,9 @@ static unsigned int test_ro (int dev, blk_t last_block,
} while (next_bad && next_bad < first_block);
if (t_flag) {
- blkbuf = allocate_buffer((blocks_at_once + 1) * block_size);
+ blkbuf = allocate_buffer(((size_t) blocks_at_once + 1) * block_size);
} else {
- blkbuf = allocate_buffer(blocks_at_once * block_size);
+ blkbuf = allocate_buffer((size_t) blocks_at_once * block_size);
}
if (!blkbuf)
{
@@ -612,7 +612,7 @@ static unsigned int test_rw (int dev, blk_t last_block,
/* set up abend handler */
capture_terminate(NULL);
- buffer = allocate_buffer(2 * blocks_at_once * block_size);
+ buffer = allocate_buffer((size_t) 2 * blocks_at_once * block_size);
read_buffer = buffer + blocks_at_once * block_size;
if (!buffer) {
@@ -771,7 +771,7 @@ static unsigned int test_nd (int dev, blk_t last_block,
ext2fs_badblocks_list_iterate (bb_iter, &next_bad);
} while (next_bad && next_bad < first_block);
- blkbuf = allocate_buffer(3 * blocks_at_once * block_size);
+ blkbuf = allocate_buffer((size_t) 3 * blocks_at_once * block_size);
test_record = malloc(blocks_at_once * sizeof(struct saved_blk_record));
if (!blkbuf || !test_record) {
com_err(program_name, ENOMEM, "%s",
@@ -1036,10 +1036,13 @@ static unsigned int parse_uint(const char *str, const char *descr)
errno = 0;
ret = strtoul(str, &tmp, 0);
- if (*tmp || errno || (ret > UINT_MAX) ||
- (ret == ULONG_MAX && errno == ERANGE)) {
+ if (*tmp || errno) {
com_err (program_name, 0, _("invalid %s - %s"), descr, str);
exit (1);
+ } else if ((ret > UINT_MAX) ||
+ (ret == ULONG_MAX && errno == ERANGE)) {
+ com_err (program_name, 0, _("%s too large - %lu"), descr, ret);
+ exit (1);
}
return ret;
}
@@ -1052,7 +1055,7 @@ int main (int argc, char ** argv)
char * input_file = NULL;
char * output_file = NULL;
FILE * in = NULL;
- int block_size = 1024;
+ unsigned int block_size = 1024;
unsigned int blocks_at_once = 64;
blk64_t last_block, first_block;
int num_passes = 0;
@@ -1202,17 +1205,21 @@ int main (int argc, char ** argv)
exit(1);
}
}
- if ((block_size <= 0) || (block_size > (1 << 24)) ||
+ if ((block_size == 0) || (block_size > (1 << 24)) ||
(block_size & (block_size - 1))) {
- com_err(program_name, 0, _("Invalid block size: %d\n"),
+ com_err(program_name, 0, _("Invalid block size: %u\n"),
block_size);
exit(1);
}
- if ((blocks_at_once <= 0) ||
- (((unsigned long long) block_size * blocks_at_once) > 0xFFFFFFFF)) {
- com_err(program_name, 0, _("Invalid blocks_at_once: %d\n"),
+ if (blocks_at_once == 0) {
+ com_err(program_name, 0, _("Invalid number of blocks: %d\n"),
blocks_at_once);
exit(1);
+ } else if (((size_t) block_size * blocks_at_once) > SIZE_MAX / 3) {
+ /* maximum usage is in test_nd() */
+ com_err(program_name, 0, _("For block size %d, number of blocks too large: %d\n"),
+ block_size, blocks_at_once);
+ exit(1);
}
if (optind > argc - 1)
@@ -1220,7 +1227,7 @@ int main (int argc, char ** argv)
device_name = argv[optind++];
if (optind > argc - 1) {
errcode = ext2fs_get_device_size2(device_name,
- block_size,
+ (int) block_size,
&last_block);
if (errcode == EXT2_ET_UNIMPLEMENTED) {
com_err(program_name, 0, "%s",
@@ -1350,7 +1357,7 @@ int main (int argc, char ** argv)
do {
unsigned int bb_count;
- bb_count = test_func(dev, last_block, block_size,
+ bb_count = test_func(dev, last_block, (int) block_size,
first_block, blocks_at_once);
if (bb_count)
passes_clean = 0;
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 33bd05d2..e3011d7c 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -195,10 +195,6 @@ static struct frag_statistic_ino frag_rank[SHOW_FRAG_FILES];
#error posix_fadvise not available!
#endif
-#ifndef HAVE_FALLOCATE64
-#error fallocate64 not available!
-#endif /* ! HAVE_FALLOCATE64 */
-
/*
* get_mount_point() - Get device's mount point.
*
@@ -1041,7 +1037,7 @@ static int file_statistic(const char *file, const struct stat64 *buf,
__u64 size_per_ext = 0;
float ratio = 0.0;
ext4_fsblk_t blk_count = 0;
- char msg_buffer[PATH_MAX + 24];
+ char msg_buffer[PATH_MAX + 48];
struct fiemap_extent_list *physical_list_head = NULL;
struct fiemap_extent_list *logical_list_head = NULL;
@@ -1210,8 +1206,9 @@ static int file_statistic(const char *file, const struct stat64 *buf,
if (mode_flag & DETAIL) {
/* Print statistic info */
- sprintf(msg_buffer, "[%u/%u]%s",
- defraged_file_count, total_count, file);
+ sprintf(msg_buffer, "[%u/%u]%.*s",
+ defraged_file_count, total_count,
+ PATH_MAX, file);
if (current_uid == ROOT_UID) {
if (strlen(msg_buffer) > 40)
printf("\033[79;0H\033[K%s\n"
@@ -1558,7 +1555,7 @@ static int file_defrag(const char *file, const struct stat64 *buf,
/* Allocate space for donor inode */
orig_group_tmp = orig_group_head;
do {
- ret = fallocate64(donor_fd, 0,
+ ret = fallocate(donor_fd, 0,
(ext2_loff_t)orig_group_tmp->start->data.logical * block_size,
(ext2_loff_t)orig_group_tmp->len * block_size);
if (ret < 0) {
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 6d4bcf4f..0dc77ead 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -325,6 +325,7 @@ struct fuse2fs {
int fakeroot;
int alloc_all_blocks;
int norecovery;
+ unsigned long offset;
FILE *err_fp;
unsigned int next_generation;
};
@@ -3660,6 +3661,7 @@ static struct fuse_opt fuse2fs_opts[] = {
FUSE2FS_OPT("fuse2fs_debug", debug, 1),
FUSE2FS_OPT("no_default_opts", no_default_opts, 1),
FUSE2FS_OPT("norecovery", norecovery, 1),
+ FUSE2FS_OPT("offset=%lu", offset, 0),
FUSE_OPT_KEY("-V", FUSE2FS_VERSION),
FUSE_OPT_KEY("--version", FUSE2FS_VERSION),
@@ -3698,6 +3700,7 @@ static int fuse2fs_opt_proc(void *data, const char *arg,
" -o minixdf minix-style df\n"
" -o fakeroot pretend to be root for permission checks\n"
" -o no_default_opts do not include default fuse options\n"
+ " -o offset=<bytes> similar to mount -o offset=<bytes>, mount the partition starting at <bytes>\n"
" -o norecovery don't replay the journal (implies ro)\n"
" -o fuse2fs_debug enable fuse2fs debugging\n"
"\n",
@@ -3777,7 +3780,9 @@ int main(int argc, char *argv[])
ret = 2;
if (!fctx.ro)
flags |= EXT2_FLAG_RW;
- err = ext2fs_open2(fctx.device, NULL, flags, 0, 0, unix_io_manager,
+ char options[50];
+ sprintf(options, "offset=%lu", fctx.offset);
+ err = ext2fs_open2(fctx.device, options, flags, 0, 0, unix_io_manager,
&global_fs);
if (err) {
printf(_("%s: %s.\n"), fctx.device, error_message(err));