diff options
author | Eric Sandeen <sandeen@redhat.com> | 2013-03-11 23:17:40 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-03-12 17:07:40 +0100 |
commit | 7a355379ea93856cd90d01216dde8610a225b8aa (patch) | |
tree | 6e811da01801db856d10c9644de41ad9f3d0ece3 /utils.h | |
parent | 120fdfafa325777c2326229d6a8393ba5ed1914f (diff) |
btrfs-progs: rework get_fs_info to remove side effects
get_fs_info() has been silently switching from a device to a mounted
path as needed; the caller's filehandle was unexpectedly closed &
reopened outside the caller's scope. Not so great.
The callers do want "fdmnt" to be the filehandle for the mount point
in all cases, though - the various ioctls act on this (not on an fd
for the device). But switching it in the local scope of get_fs_info
is incorrect; it just so happens that *usually* the fd number is
unchanged.
So - use the new helpers to detect when an argument is a block
device, and open the the mounted path more obviously / explicitly
for ioctl use, storing the filehandle in fdmnt.
Then, in get_fs_info, ignore the fd completely, and use the path on
the argument to determine if the caller wanted to act on just that
device, or on all devices for the filesystem.
Affects those commands which are documented to accept either
a block device or a path:
* btrfs device stats
* btrfs replace start
* btrfs scrub start
* btrfs scrub status
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -50,7 +50,7 @@ u64 parse_size(char *s); int open_file_or_dir(const char *fname); int get_device_info(int fd, u64 devid, struct btrfs_ioctl_dev_info_args *di_args); -int get_fs_info(int fd, char *path, struct btrfs_ioctl_fs_info_args *fi_args, +int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args, struct btrfs_ioctl_dev_info_args **di_ret); int get_label(const char *btrfs_dev); int set_label(const char *btrfs_dev, const char *label); |