diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-03-09 09:13:45 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-03-09 09:26:56 -0900 |
commit | 07ddcf0bef7ea7dfe4885b29d1c727ae32a29dcf (patch) | |
tree | b5c85dc294e7b0f07bb7d6833b9cdd043f91dee2 /cmd_format.c | |
parent | ac1b32acb4ca8c59c0e4911a8d3b27fd72dc54af (diff) |
cmd_device_add improvements
Diffstat (limited to 'cmd_format.c')
-rw-r--r-- | cmd_format.c | 68 |
1 files changed, 3 insertions, 65 deletions
diff --git a/cmd_format.c b/cmd_format.c index 73342596..3ef862f7 100644 --- a/cmd_format.c +++ b/cmd_format.c @@ -17,7 +17,6 @@ #include <sys/types.h> #include <unistd.h> -#include <blkid.h> #include <uuid/uuid.h> #include "ccan/darray/darray.h" @@ -28,46 +27,6 @@ #include "opts.h" #include "util.h" -/* Open a block device, do magic blkid stuff: */ -static int open_for_format(const char *dev, bool force) -{ - blkid_probe pr; - const char *fs_type = NULL, *fs_label = NULL; - size_t fs_type_len, fs_label_len; - - int fd = xopen(dev, O_RDWR|O_EXCL); - - if (force) - return fd; - - if (!(pr = blkid_new_probe())) - die("blkid error 1"); - if (blkid_probe_set_device(pr, fd, 0, 0)) - die("blkid error 2"); - if (blkid_probe_enable_partitions(pr, true)) - die("blkid error 3"); - if (blkid_do_fullprobe(pr) < 0) - die("blkid error 4"); - - blkid_probe_lookup_value(pr, "TYPE", &fs_type, &fs_type_len); - blkid_probe_lookup_value(pr, "LABEL", &fs_label, &fs_label_len); - - if (fs_type) { - if (fs_label) - printf("%s contains a %s filesystem labelled '%s'\n", - dev, fs_type, fs_label); - else - printf("%s contains a %s filesystem\n", - dev, fs_type); - fputs("Proceed anyway?", stdout); - if (!ask_yn()) - exit(EXIT_FAILURE); - } - - blkid_free_probe(pr); - return fd; -} - #define OPTS \ t("bcache format - create a new bcache filesystem on one or more devices") \ t("Usage: bcache format [OPTION]... <devices>") \ @@ -127,11 +86,11 @@ static void usage(void) "\n" "Device specific options:\n" " --fs_size=size Size of filesystem on device\n" - " --bucket=size bucket size\n" + " --bucket=size Bucket size\n" " --discard Enable discards\n" - " -t, --tier=# tier of subsequent devices\n" + " -t, --tier=# Higher tier (e.g. 1) indicates slower devices\n" "\n" - " -h, --help display this help and exit\n" + " -h, --help Display this help and exit\n" "\n" "Device specific options must come before corresponding devices, e.g.\n" " bcache format --tier 0 /dev/sdb --tier 1 /dev/sdc\n" @@ -162,27 +121,6 @@ static const struct option format_opts[] = { { NULL } }; -static unsigned hatoi_validate(const char *s, const char *msg) -{ - u64 v; - - if (bch_strtoull_h(s, &v)) - die("bad %s %s", msg, s); - - if (v & (v - 1)) - die("%s must be a power of two", msg); - - v /= 512; - - if (v > USHRT_MAX) - die("%s too large\n", msg); - - if (!v) - die("%s too small\n", msg); - - return v; -} - int cmd_format(int argc, char *argv[]) { darray(struct dev_opts) devices; |