summaryrefslogtreecommitdiffstats
path: root/commands/mount.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-09-27 23:26:00 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-29 12:11:14 +0200
commit7a1c5027f998f20ee6b3a681903f64105a4e8014 (patch)
tree64b47a7f1f54b5d9146d722b42fcabd69ad706d5 /commands/mount.c
parentd915fcbc6d55a200bcc3ae65d6edd1ea234a00f3 (diff)
downloadbarebox-7a1c5027f998f20ee6b3a681903f64105a4e8014.tar.gz
barebox-7a1c5027f998f20ee6b3a681903f64105a4e8014.tar.xz
mount: implement -v option to print available filesystems
It's useful to know which filesystems a barebox binary supports. Add a -v option to the mount command to find it out. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/mount.c')
-rw-r--r--commands/mount.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/commands/mount.c b/commands/mount.c
index 595145a130..203c4de530 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -31,27 +31,40 @@
static int do_mount(int argc, char *argv[])
{
int opt;
- int ret = 0;
+ int ret = 0, verbose = 0;
struct fs_device_d *fsdev;
+ struct driver_d *drv;
const char *type = NULL;
const char *mountpoint, *dev;
- if (argc == 1) {
+ while ((opt = getopt(argc, argv, "t:v")) > 0) {
+ switch (opt) {
+ case 't':
+ type = optarg;
+ break;
+ case 'v':
+ verbose++;
+ break;
+ }
+ }
+
+ if (argc == optind) {
for_each_fs_device(fsdev) {
printf("%s on %s type %s\n",
fsdev->backingstore ? fsdev->backingstore : "none",
fsdev->path,
fsdev->dev.name);
}
- return 0;
- }
- while ((opt = getopt(argc, argv, "t:")) > 0) {
- switch (opt) {
- case 't':
- type = optarg;
- break;
+ if (verbose) {
+ printf("\nSupported filesystems:\n\n");
+ bus_for_each_driver(&fs_bus, drv) {
+ struct fs_driver_d * fsdrv = drv_to_fs_driver(drv);
+ printf("%s\n", fsdrv->drv.name);
+ }
}
+
+ return 0;
}
if (argc < optind + 2)
@@ -77,7 +90,9 @@ static int do_mount(int argc, char *argv[])
}
BAREBOX_CMD_HELP_START(mount)
-BAREBOX_CMD_HELP_USAGE("mount [[-t <fstype] <device> <mountpoint>]\n")
+BAREBOX_CMD_HELP_USAGE("mount [[OPTIONS] <device> <mountpoint>]\n")
+BAREBOX_CMD_HELP_OPT("-t <type>", "specify filesystem type\n")
+BAREBOX_CMD_HELP_OPT("-v", "be more verbose\n")
BAREBOX_CMD_HELP_SHORT("Mount a filesystem of a given type to a mountpoint.\n")
BAREBOX_CMD_HELP_SHORT("If no fstype is specified, try to detect it automatically.\n")
BAREBOX_CMD_HELP_SHORT("If no argument is given, list mounted filesystems.\n")