summaryrefslogtreecommitdiff
path: root/volumes.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-08-24 16:45:02 +0800
committerDavid Sterba <dsterba@suse.com>2015-08-31 19:25:13 +0200
commitb0f760c91aa9de9a853545f36dc063f6ef5e9008 (patch)
tree9b9a64a5c17b8b0521d9b56dd629de428aee9a72 /volumes.c
parent004eabb1ad09171389b7e9260342758e7b331a07 (diff)
downloadbtrfs-progs-b0f760c91aa9de9a853545f36dc063f6ef5e9008.tar.gz
btrfs-progs: Introduce btrfs_close_all_devices helper
If there is more than one fs_devices in fs_uuids list (like mkfs.btrfs does), we need close them all before exit. Add a helper for that. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/volumes.c b/volumes.c
index f7462c5..ca50f1c 100644
--- a/volumes.c
+++ b/volumes.c
@@ -198,6 +198,17 @@ again:
return 0;
}
+void btrfs_close_all_devices(void)
+{
+ struct btrfs_fs_devices *fs_devices;
+
+ while (!list_empty(&fs_uuids)) {
+ fs_devices = list_entry(fs_uuids.next, struct btrfs_fs_devices,
+ list);
+ btrfs_close_devices(fs_devices);
+ }
+}
+
int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
{
int fd;