From ec1fc69d3945f67684a2c15969dfb309ed967168 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Mon, 24 Aug 2015 16:45:03 +0800 Subject: 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 Signed-off-by: David Sterba --- cmds-device.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmds-device.c') diff --git a/cmds-device.c b/cmds-device.c index cbb6b61d..8e69b885 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; } -- cgit v1.2.3