diff options
author | David Sterba <dsterba@suse.com> | 2018-06-18 17:56:22 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-08-06 14:59:25 +0200 |
commit | f8c6759f29db7b78ed3bc042ced53aa6bcdcb4aa (patch) | |
tree | e37ac8e9143b99af865be89cf2b222f094d9054c | |
parent | 47cbb3c9b26aa60bcffc1809c98268a11f1bf2b5 (diff) |
btrfs-progs: btrfstune: prepare for enhanced mount check
We'll want to pass non-default superblock flags so let's use the other
helper that allows that. We can reuse the filesystem handle so it needs
to open it read-write, unlike what the plain check_mounted does.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | btrfstune.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/btrfstune.c b/btrfstune.c index eccedf79..889b931c 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -394,6 +394,7 @@ int main(int argc, char *argv[]) char *new_fsid_str = NULL; int ret; u64 super_flags = 0; + int fd = -1; while(1) { static const struct option long_options[] = { @@ -467,17 +468,25 @@ int main(int argc, char *argv[]) } } - ret = check_mounted(device); + fd = open(device, O_RDWR); + if (fd < 0) { + error("mount check: cannot open %s: %m", device); + return 1; + } + + ret = check_mounted_where(fd, device, NULL, 0, NULL, SBREAD_DEFAULT); if (ret < 0) { error("could not check mount status of %s: %s", device, strerror(-ret)); + close(fd); return 1; } else if (ret) { error("%s is mounted", device); + close(fd); return 1; } - root = open_ctree(device, 0, ctree_flags); + root = open_ctree_fd(fd, device, 0, ctree_flags); if (!root) { error("open ctree failed"); |