mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-12 08:49:33 +00:00
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:
parent
4694077298
commit
e7e89d93c2
10
utils.c
10
utils.c
@ -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;
|
||||
|
2
utils.h
2
utils.h
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user