summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2014-10-31 12:11:19 +0800
committerDavid Sterba <dsterba@suse.cz>2014-11-03 19:17:08 +0100
commit53cb7fbe8da8253ea3ac1ecc6a71c7ffd1d63f76 (patch)
treec1f1e342646090fad60d3e2bfa4db09716cf6125 /utils.c
parentdcf11c371cbcdca78f297fe042095912634a8323 (diff)
downloadbtrfs-progs-53cb7fbe8da8253ea3ac1ecc6a71c7ffd1d63f76.tar.gz
btrfs-progs: introduce btrfs_register_all_device()
This function is to register all devices found after scanning the system. Before we had this functionality with in the btrfs_scan_lblkid(), however scanning and registering are two different distinct operation its better keep them separate. Also we want to optimize btrfs_scan_lblkid and avoid multiple system scans unless needed. As of now device scan uses this function. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 9ad1e17..5a12517 100644
--- a/utils.c
+++ b/utils.c
@@ -1266,6 +1266,33 @@ int btrfs_register_one_device(const char *fname)
return ret;
}
+/*
+ * Register all devices in the fs_uuid list created in the user
+ * space. Ensure btrfs_scan_lblkid() is called before this func.
+ */
+int btrfs_register_all_devices(void)
+{
+ int err;
+ struct btrfs_fs_devices *fs_devices;
+ struct btrfs_device *device;
+ struct list_head *all_uuids;
+
+ all_uuids = btrfs_scanned_uuids();
+
+ list_for_each_entry(fs_devices, all_uuids, list) {
+ list_for_each_entry(device, &fs_devices->devices, dev_list) {
+ if (strlen(device->name) != 0) {
+ err = btrfs_register_one_device(device->name);
+ if (err < 0)
+ return err;
+ if (err > 0)
+ return -err;
+ }
+ }
+ }
+ return 0;
+}
+
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
int super_offset)
{