diff options
author | Brian Foster <bfoster@redhat.com> | 2023-11-27 13:31:10 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-27 21:04:03 -0500 |
commit | 1cdb7812d177bfa8d88c23396434195f3a7ced47 (patch) | |
tree | 2bb3f9411fe190c7361a0dfc3ef55d41e1750f48 | |
parent | 843707ede687387c91d736c601d3ddee91e9f893 (diff) | |
download | bcachefs-tools-1cdb7812d177bfa8d88c23396434195f3a7ced47.tar.gz |
bcachefs-tools: don't skip stale superblock wipe in force mode
Even though the blkid wipe has been fixed to detect and wipe old
superblocks, we still incorrectly skip the wipe when in force mode.
Update the force logic in open_for_format() to bypass the user
request and otherwise proceed with the wipe.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | tools-util.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools-util.c b/tools-util.c index 7d4a3c1c..a1e67dd5 100644 --- a/tools-util.c +++ b/tools-util.c @@ -225,9 +225,6 @@ int open_for_format(struct dev_opts *dev, bool force) if (ret < 0) die("Error opening device to format %s: %s", dev->path, strerror(-ret)); - if (force) - return 0; - if (!(pr = blkid_new_probe())) die("blkid error 1"); if (blkid_probe_set_device(pr, dev->bdev->bd_buffered_fd, 0, 0)) @@ -250,9 +247,11 @@ int open_for_format(struct dev_opts *dev, bool force) else printf("%s contains a %s filesystem\n", dev->path, fs_type); - fputs("Proceed anyway?", stdout); - if (!ask_yn()) - exit(EXIT_FAILURE); + if (!force) { + fputs("Proceed anyway?", stdout); + if (!ask_yn()) + exit(EXIT_FAILURE); + } while (blkid_do_probe(pr) == 0) { if (blkid_do_wipe(pr, 0)) die("Failed to wipe preexisting metadata."); |