btrfs-progs: alias btrfs device delete to btrfs device remove
[platform/upstream/btrfs-progs.git] / mkfs.c
diff --git a/mkfs.c b/mkfs.c
index f622f2f..c5e1a6b 100644 (file)
--- a/mkfs.c
+++ b/mkfs.c
@@ -290,9 +290,7 @@ static int create_data_reloc_tree(struct btrfs_trans_handle *trans,
        return 0;
 }
 
-
-static void print_usage(void) __attribute__((noreturn));
-static void print_usage(void)
+static void print_usage(int ret)
 {
        fprintf(stderr, "usage: mkfs.btrfs [options] dev [ dev ... ]\n");
        fprintf(stderr, "options:\n");
@@ -313,7 +311,7 @@ static void print_usage(void)
        fprintf(stderr, "\t-q|--quiet              no messages except errors\n");
        fprintf(stderr, "\t-V|--version            print the mkfs.btrfs version and exit\n");
        fprintf(stderr, "%s\n", PACKAGE_STRING);
-       exit(1);
+       exit(ret);
 }
 
 static void print_version(void) __attribute__((noreturn));
@@ -341,7 +339,6 @@ static u64 parse_profile(char *s)
                return 0;
        } else {
                fprintf(stderr, "Unknown profile %s\n", s);
-               print_usage();
        }
        /* not reached */
        return 0;
@@ -1198,7 +1195,6 @@ int main(int ac, char **av)
        u64 source_dir_size = 0;
        int dev_cnt = 0;
        int saved_optind;
-       char estr[100];
        char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 };
        u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
        struct mkfs_allocation allocation = { 0 };
@@ -1222,6 +1218,7 @@ int main(int ac, char **av)
                        { "features", required_argument, NULL, 'O' },
                        { "uuid", required_argument, NULL, 'U' },
                        { "quiet", 0, NULL, 'q' },
+                       { "help", no_argument, NULL, GETOPT_VAL_HELP },
                        { NULL, 0, NULL, 0}
                };
 
@@ -1302,8 +1299,9 @@ int main(int ac, char **av)
                        case 'q':
                                verbose = 0;
                                break;
+                       case GETOPT_VAL_HELP:
                        default:
-                               print_usage();
+                               print_usage(c != GETOPT_VAL_HELP);
                }
        }
        sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
@@ -1312,7 +1310,7 @@ int main(int ac, char **av)
        saved_optind = optind;
        dev_cnt = ac - optind;
        if (dev_cnt == 0)
-               print_usage();
+               print_usage(1);
 
        if (source_dir_set && dev_cnt > 1) {
                fprintf(stderr,
@@ -1336,10 +1334,8 @@ int main(int ac, char **av)
        while (dev_cnt-- > 0) {
                file = av[optind++];
                if (is_block_device(file))
-                       if (test_dev_for_mkfs(file, force_overwrite, estr)) {
-                               fprintf(stderr, "Error: %s", estr);
+                       if (test_dev_for_mkfs(file, force_overwrite))
                                exit(1);
-                       }
        }
 
        optind = saved_optind;
@@ -1427,11 +1423,9 @@ int main(int ac, char **av)
                }
        }
        ret = test_num_disk_vs_raid(metadata_profile, data_profile,
-                       dev_cnt, mixed, estr);
-       if (ret) {
-               fprintf(stderr, "Error: %s\n", estr);
+                       dev_cnt, mixed);
+       if (ret)
                exit(1);
-       }
 
        /* if we are here that means all devs are good to btrfsify */
        if (verbose) {