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>
free_root_recs_tree(&root_cache);
close_out:
close_ctree(root);
+ btrfs_close_all_devices();
err_out:
return ret;
}
#include "ctree.h"
#include "ioctl.h"
#include "utils.h"
+#include "volumes.h"
#include "cmds-fi-usage.h"
#include "commands.h"
error_out:
close_file_or_dir(fdmnt, dirstream);
+ btrfs_close_all_devices();
return !!ret;
}
}
out:
+ btrfs_close_all_devices();
return !!ret;
}
out:
free(di_args);
close_file_or_dir(fdmnt, dirstream);
+ btrfs_close_all_devices();
return err;
}
}
}
close_file_or_dir(fdmnt, dirstream);
+ btrfs_close_all_devices();
return 0;
leave_with_error:
close(fdmnt);
if (fddstdev != -1)
close(fddstdev);
+ btrfs_close_all_devices();
return 1;
}
out:
ret = close_ctree(root);
BUG_ON(ret);
+ btrfs_close_all_devices();
free(label);
return 0;
}