summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-04-06 17:45:19 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2019-04-06 17:45:19 -0400
commit3a59ff72a0b9bf3ee4cea7a886616edf5ab4f331 (patch)
tree47a3815e6638457a3f03647354a5d9712af6e2da
parentd13bbb2955f899f10be4ab315ad229d2951fdcda (diff)
initialize filesystem when formatting
makes it possible to mount ro for the first mount, helps with some xfstests tests
-rw-r--r--cmd_format.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd_format.c b/cmd_format.c
index cffb8dc1..ae83a977 100644
--- a/cmd_format.c
+++ b/cmd_format.c
@@ -109,6 +109,7 @@ u64 read_flag_list_or_die(char *opt, const char * const list[],
int cmd_format(int argc, char *argv[])
{
darray(struct dev_opts) devices;
+ darray(char *) device_paths;
struct format_opts opts = format_opts_default();
struct dev_opts dev_opts = dev_opts_default(), *dev;
bool force = false, no_passphrase = false, quiet = false;
@@ -116,6 +117,7 @@ int cmd_format(int argc, char *argv[])
int opt;
darray_init(devices);
+ darray_init(device_paths);
struct bch_opt_strs fs_opt_strs =
bch2_cmdline_opts_get(&argc, argv, OPT_FORMAT);
@@ -182,6 +184,7 @@ int cmd_format(int argc, char *argv[])
die("invalid durability");
break;
case O_no_opt:
+ darray_append(device_paths, optarg);
dev_opts.path = optarg;
darray_append(devices, dev_opts);
dev_opts.size = 0;
@@ -226,6 +229,21 @@ int cmd_format(int argc, char *argv[])
darray_free(devices);
+ if (!opts.passphrase) {
+ /*
+ * Start the filesystem once, to allocate the journal and create
+ * the root directory:
+ */
+ struct bch_fs *c = bch2_fs_open(device_paths.item,
+ darray_size(device_paths),
+ bch2_opts_empty());
+ if (IS_ERR(c))
+ die("error opening %s: %s", device_paths.item,
+ strerror(-PTR_ERR(c)));
+
+ bch2_fs_stop(c);
+ }
+
return 0;
}