forked from Mirrors/btrfs-progs
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>master
parent
47cbb3c9b2
commit
f8c6759f29
25
btrfstune.c
25
btrfstune.c
|
@ -394,6 +394,7 @@ int main(int argc, char *argv[])
|
||||||
char *new_fsid_str = NULL;
|
char *new_fsid_str = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
u64 super_flags = 0;
|
u64 super_flags = 0;
|
||||||
|
int fd = -1;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
static const struct option long_options[] = {
|
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 (ret < 0) {
|
if (fd < 0) {
|
||||||
error("could not check mount status of %s: %s", device,
|
error("mount check: cannot open %s: %m", device);
|
||||||
strerror(-ret));
|
|
||||||
return 1;
|
|
||||||
} else if (ret) {
|
|
||||||
error("%s is mounted", device);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
root = open_ctree(device, 0, ctree_flags);
|
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_fd(fd, device, 0, ctree_flags);
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
error("open ctree failed");
|
error("open ctree failed");
|
||||||
|
|
Loading…
Reference in New Issue