diff options
author | Igor Ostapenko <igoreisberg@gmail.com> | 2022-01-31 21:33:07 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-31 21:33:07 +0000 |
commit | 480ad2a56bd9780e697ce68160aeaf1f43f7de79 (patch) | |
tree | da636215248c0288595c5ae1219aad272bb7c783 | |
parent | 5c21c0de406b789928c3ad17cc80e75b17b79c7b (diff) | |
parent | 2b72c832d08093289cc13a11585625c048ef4785 (diff) | |
download | erofs-utils-480ad2a56bd9780e697ce68160aeaf1f43f7de79.tar.gz |
UPSTREAM: erofs-utils: add missing errors and normalize errors to lower-case am: 352793d3ba am: e14e0e9576 am: 1cd9c991c8 am: 2b72c832d0
Original change: https://android-review.googlesource.com/c/platform/external/erofs-utils/+/1966847
Change-Id: Id70384e0aa20d05d25429c0f7f25d4c152c7a714
-rw-r--r-- | dump/main.c | 4 | ||||
-rw-r--r-- | fsck/main.c | 37 | ||||
-rw-r--r-- | mkfs/main.c | 30 |
3 files changed, 42 insertions, 29 deletions
diff --git a/dump/main.c b/dump/main.c index 71b44b4..bb1bd7f 100644 --- a/dump/main.c +++ b/dump/main.c @@ -161,8 +161,10 @@ static int erofsdump_parse_options_cfg(int argc, char **argv) } } - if (optind >= argc) + if (optind >= argc) { + erofs_err("missing argument: IMAGE"); return -EINVAL; + } cfg.c_img_path = strdup(argv[optind++]); if (!cfg.c_img_path) diff --git a/fsck/main.c b/fsck/main.c index 5b75ee3..e669b44 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -122,8 +122,10 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv) if (optarg) { size_t len = strlen(optarg); - if (len == 0) + if (len == 0) { + erofs_err("empty value given for --extract=X"); return -EINVAL; + } /* remove trailing slashes except root */ while (len > 1 && optarg[len - 1] == '/') @@ -201,8 +203,10 @@ static int erofsfsck_parse_options_cfg(int argc, char **argv) } } - if (optind >= argc) + if (optind >= argc) { + erofs_err("missing argument: IMAGE"); return -EINVAL; + } cfg.c_img_path = strdup(argv[optind++]); if (!cfg.c_img_path) @@ -513,7 +517,7 @@ static inline int erofs_extract_dir(struct erofs_inode *inode) struct stat st; if (errno != EEXIST) { - erofs_err("failed to create directory %s: %s", + erofs_err("failed to create directory: %s (%s)", fsckcfg.extract_path, strerror(errno)); return -errno; } @@ -529,8 +533,11 @@ static inline int erofs_extract_dir(struct erofs_inode *inode) * Try to change permissions of existing directory so * that we can write to it */ - if (chmod(fsckcfg.extract_path, 0700) < 0) + if (chmod(fsckcfg.extract_path, 0700) < 0) { + erofs_err("failed to set permissions: %s (%s)", + fsckcfg.extract_path, strerror(errno)); return -errno; + } } return 0; } @@ -552,18 +559,20 @@ again: erofs_warn("try to forcely remove directory %s", fsckcfg.extract_path); if (rmdir(fsckcfg.extract_path) < 0) { - erofs_err("failed to remove: %s", - fsckcfg.extract_path); + erofs_err("failed to remove: %s (%s)", + fsckcfg.extract_path, strerror(errno)); return -EISDIR; } } else if (errno == EACCES && chmod(fsckcfg.extract_path, 0700) < 0) { + erofs_err("failed to set permissions: %s (%s)", + fsckcfg.extract_path, strerror(errno)); return -errno; } tryagain = false; goto again; } - erofs_err("failed to open %s: %s", fsckcfg.extract_path, + erofs_err("failed to open: %s (%s)", fsckcfg.extract_path, strerror(errno)); return -errno; } @@ -728,15 +737,15 @@ int main(int argc, char **argv) erofs_init_configure(); - fsckcfg.superuser = geteuid() == 0; + fsckcfg.physical_blocks = 0; + fsckcfg.logical_blocks = 0; + fsckcfg.extract_path = NULL; + fsckcfg.extract_pos = 0; fsckcfg.umask = umask(0); + fsckcfg.superuser = geteuid() == 0; fsckcfg.corrupted = false; - fsckcfg.logical_blocks = 0; - fsckcfg.physical_blocks = 0; fsckcfg.print_comp_ratio = false; fsckcfg.check_decomp = false; - fsckcfg.extract_path = NULL; - fsckcfg.extract_pos = 0; fsckcfg.force = false; fsckcfg.overwrite = false; fsckcfg.preserve_owner = fsckcfg.superuser; @@ -775,9 +784,9 @@ int main(int argc, char **argv) err = -EFSCORRUPTED; } else if (!err) { if (!fsckcfg.extract_path) - erofs_info("No error found"); + erofs_info("No errors found"); else - erofs_info("Extract data successfully"); + erofs_info("Extracted filesystem successfully"); if (fsckcfg.print_comp_ratio) { double comp_ratio = diff --git a/mkfs/main.c b/mkfs/main.c index 1787b2c..3f34450 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -375,9 +375,6 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) } } - if (optind >= argc) - return -EINVAL; - if (cfg.c_blobdev_path && cfg.c_chunkbits < LOG_BLOCK_SIZE) { erofs_err("--blobdev must be used together with --chunksize"); return -EINVAL; @@ -390,24 +387,29 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) return -EINVAL; } + if (optind >= argc) { + erofs_err("missing argument: FILE"); + return -EINVAL; + } + cfg.c_img_path = strdup(argv[optind++]); if (!cfg.c_img_path) return -ENOMEM; if (optind >= argc) { - erofs_err("Source directory is missing"); + erofs_err("missing argument: DIRECTORY"); return -EINVAL; } cfg.c_src_path = realpath(argv[optind++], NULL); if (!cfg.c_src_path) { - erofs_err("Failed to parse source directory: %s", + erofs_err("failed to parse source directory: %s", erofs_strerror(-errno)); return -ENOENT; } if (optind < argc) { - erofs_err("Unexpected argument: %s\n", argv[optind]); + erofs_err("unexpected argument: %s\n", argv[optind]); return -EINVAL; } if (quiet) @@ -450,7 +452,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, buf = calloc(sb_blksize, 1); if (!buf) { - erofs_err("Failed to allocate memory for sb: %s", + erofs_err("failed to allocate memory for sb: %s", erofs_strerror(-errno)); return -ENOMEM; } @@ -532,7 +534,7 @@ int parse_source_date_epoch(void) epoch = strtoull(source_date_epoch, &endptr, 10); if (epoch == -1ULL || *endptr != '\0') { - erofs_err("Environment variable $SOURCE_DATE_EPOCH %s is invalid", + erofs_err("environment variable $SOURCE_DATE_EPOCH %s is invalid", source_date_epoch); return -EINVAL; } @@ -633,34 +635,34 @@ int main(int argc, char **argv) sb_bh = erofs_buffer_init(); if (IS_ERR(sb_bh)) { err = PTR_ERR(sb_bh); - erofs_err("Failed to initialize buffers: %s", + erofs_err("failed to initialize buffers: %s", erofs_strerror(err)); goto exit; } err = erofs_bh_balloon(sb_bh, EROFS_SUPER_END); if (err < 0) { - erofs_err("Failed to balloon erofs_super_block: %s", + erofs_err("failed to balloon erofs_super_block: %s", erofs_strerror(err)); goto exit; } err = erofs_load_compress_hints(); if (err) { - erofs_err("Failed to load compress hints %s", + erofs_err("failed to load compress hints %s", cfg.c_compress_hints_file); goto exit; } err = z_erofs_compress_init(sb_bh); if (err) { - erofs_err("Failed to initialize compressor: %s", + erofs_err("failed to initialize compressor: %s", erofs_strerror(err)); goto exit; } err = erofs_generate_devtable(); if (err) { - erofs_err("Failed to generate device table: %s", + erofs_err("failed to generate device table: %s", erofs_strerror(err)); goto exit; } @@ -673,7 +675,7 @@ int main(int argc, char **argv) err = erofs_build_shared_xattrs_from_path(cfg.c_src_path); if (err) { - erofs_err("Failed to build shared xattrs: %s", + erofs_err("failed to build shared xattrs: %s", erofs_strerror(err)); goto exit; } |