btrfs-progs: pass superblock flags to mount check helpers

Extend check_mounted_where so we can pass additional flags that would
allow us to open filesystem in some specific state. This will be used
for a filesystem that has a partially changed uuid.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2018-06-18 17:00:14 +02:00
parent 4694077298
commit e7e89d93c2
2 changed files with 6 additions and 6 deletions

10
utils.c
View File

@ -540,7 +540,7 @@ int get_btrfs_mount(const char *dev, char *mp, size_t mp_size)
goto out;
}
ret = check_mounted_where(fd, dev, mp, mp_size, NULL);
ret = check_mounted_where(fd, dev, mp, mp_size, NULL, SBREAD_DEFAULT);
if (!ret) {
ret = -EINVAL;
} else { /* mounted, all good */
@ -901,14 +901,14 @@ int check_mounted(const char* file)
return -errno;
}
ret = check_mounted_where(fd, file, NULL, 0, NULL);
ret = check_mounted_where(fd, file, NULL, 0, NULL, SBREAD_DEFAULT);
close(fd);
return ret;
}
int check_mounted_where(int fd, const char *file, char *where, int size,
struct btrfs_fs_devices **fs_dev_ret)
struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
{
int ret;
u64 total_devs = 1;
@ -919,7 +919,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
/* scan the initial device */
ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
&total_devs, BTRFS_SUPER_INFO_OFFSET, SBREAD_DEFAULT);
&total_devs, BTRFS_SUPER_INFO_OFFSET, sbflags);
is_btrfs = (ret >= 0);
/* scan other devices */
@ -1675,7 +1675,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
goto out;
}
ret = check_mounted_where(fd, path, mp, sizeof(mp),
&fs_devices_mnt);
&fs_devices_mnt, SBREAD_DEFAULT);
if (!ret) {
ret = -EINVAL;
goto out;

View File

@ -92,7 +92,7 @@ char *canonicalize_dm_name(const char *ptname);
char *canonicalize_path(const char *path);
int check_mounted(const char *devicename);
int check_mounted_where(int fd, const char *file, char *where, int size,
struct btrfs_fs_devices **fs_devices_mnt);
struct btrfs_fs_devices **fs_devices_mnt, unsigned sbflags);
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
int super_offset);