@@ -120,6 +120,8 @@ available.
-u|--forget::::
Unregister a given device or all stale devices if no path is given, the device
must be unmounted otherwise it's an error.
+-v|--verbose::::
+List the devices scanned in the current scan and be verbose where needed
*stats* [options] <path>|<device>::
Read and print the device IO error statistics for all devices of the given
@@ -303,6 +303,8 @@ static const char * const cmd_device_scan_usage[] = {
" -d|--all-devices enumerate and register all devices, use as a fallback",
" if blkid is not available",
" -u|--forget [<device>...] unregister a given device or all stale devices if no path ",
+ " -v|--verbose [<device>...] stdout the devices that are scanned in the current scan",
+
NULL
};
@@ -313,6 +315,7 @@ static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv)
int all = 0;
int ret = 0;
int forget = 0;
+ bool verbose = false;
optind = 0;
while (1) {
@@ -320,10 +323,11 @@ static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv)
static const struct option long_options[] = {
{ "all-devices", no_argument, NULL, 'd'},
{ "forget", no_argument, NULL, 'u'},
+ { "verbose", no_argument, NULL, 'v'},
{ NULL, 0, NULL, 0}
};
- c = getopt_long(argc, argv, "du", long_options, NULL);
+ c = getopt_long(argc, argv, "duv", long_options, NULL);
if (c < 0)
break;
switch (c) {
@@ -333,6 +337,9 @@ static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv)
case 'u':
forget = 1;
break;
+ case 'v':
+ verbose = true;
+ break;
default:
usage_unknown_option(cmd, argv);
}
@@ -354,7 +361,7 @@ static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv)
}
} else {
printf("Scanning for Btrfs filesystems\n");
- ret = btrfs_scan_devices();
+ ret = btrfs_scan_devices(verbose);
error_on(ret, "error %d while scanning", ret);
ret = btrfs_register_all_devices();
error_on(ret,
@@ -746,7 +746,7 @@ devs_only:
else
ret = 1;
} else {
- ret = btrfs_scan_devices();
+ ret = btrfs_scan_devices(false);
}
if (ret) {
@@ -360,7 +360,7 @@ void free_seen_fsid(struct seen_fsid *seen_fsid_hash[])
}
}
-int btrfs_scan_devices(void)
+int btrfs_scan_devices(bool verbose)
{
int fd = -1;
int ret;
@@ -389,6 +389,8 @@ int btrfs_scan_devices(void)
continue;
/* if we are here its definitely a btrfs disk*/
strncpy_null(path, blkid_dev_devname(dev));
+ if (verbose)
+ printf("blkid: btrfs device: %s\n", path);
fd = open(path, O_RDONLY);
if (fd < 0) {
@@ -1,6 +1,7 @@
#ifndef __DEVICE_SCAN_H__
#define __DEVICE_SCAN_H__
+#include <stdbool.h>
#include "kerncompat.h"
#include "ioctl.h"
@@ -29,7 +30,7 @@ struct seen_fsid {
int fd;
};
-int btrfs_scan_devices(void);
+int btrfs_scan_devices(bool verbose);
int btrfs_register_one_device(const char *fname);
int btrfs_register_all_devices(void);
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
@@ -277,7 +277,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size,
/* scan other devices */
if (is_btrfs && total_devs > 1) {
- ret = btrfs_scan_devices();
+ ret = btrfs_scan_devices(false);
if (ret)
return ret;
}
@@ -1096,7 +1096,7 @@ int btrfs_scan_fs_devices(int fd, const char *path,
}
if (!skip_devices && total_devs != 1) {
- ret = btrfs_scan_devices();
+ ret = btrfs_scan_devices(false);
if (ret)
return ret;
}