aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-device.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-08-24 16:45:03 +0800
committerDavid Sterba <dsterba@suse.com>2015-08-31 19:25:13 +0200
commitec1fc69d3945f67684a2c15969dfb309ed967168 (patch)
tree478a9c43eec1586aca8cf9c04ae86c9ec4a047c6 /cmds-device.c
parentb0f760c91aa9de9a853545f36dc063f6ef5e9008 (diff)
downloadbtrfs-progs-ec1fc69d3945f67684a2c15969dfb309ed967168.tar.gz
btrfs-progs-ec1fc69d3945f67684a2c15969dfb309ed967168.tar.xz
btrfs-progs-ec1fc69d3945f67684a2c15969dfb309ed967168.zip
btrfs-progs: close all fs_devices before exit in some commands
mkfs creates more than one fs_devices in fs_uuids. 1: one is for file system being created 2: others are created in test_dev_for_mkfs in order to check mount point test_dev_for_mkfs()-> ... -> btrfs_scan_one_device() Current code only closes 1, and this patch also closes in case 2. Similar problem exist in other tools, eg.:: cmd-check.c: the function is: cmd_check()->check_mounted()-> ... -> btrfs_scan_one_device() ... Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-device.c')
-rw-r--r--cmds-device.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmds-device.c b/cmds-device.c
index cbb6b61..8e69b88 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -28,6 +28,7 @@
#include "ctree.h"
#include "ioctl.h"
#include "utils.h"
+#include "volumes.h"
#include "cmds-fi-usage.h"
#include "commands.h"
@@ -140,6 +141,7 @@ static int cmd_device_add(int argc, char **argv)
error_out:
close_file_or_dir(fdmnt, dirstream);
+ btrfs_close_all_devices();
return !!ret;
}
@@ -290,6 +292,7 @@ static int cmd_device_scan(int argc, char **argv)
}
out:
+ btrfs_close_all_devices();
return !!ret;
}
@@ -467,6 +470,7 @@ static int cmd_device_stats(int argc, char **argv)
out:
free(di_args);
close_file_or_dir(fdmnt, dirstream);
+ btrfs_close_all_devices();
return err;
}