summaryrefslogtreecommitdiffstats
path: root/commands/mount.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-08-12 19:37:32 +0800
committerSascha Hauer <s.hauer@pengutronix.de>2012-09-04 09:08:39 +0200
commit94fd74dda7d905b37b61310ebd7281891d718241 (patch)
tree5778ff84f65f5ef24d0074fc01785f388f4d28f0 /commands/mount.c
parent173fa8fe4c86d7589ca1e1e2ab0d314bfe611d30 (diff)
downloadbarebox-94fd74dda7d905b37b61310ebd7281891d718241.tar.gz
barebox-94fd74dda7d905b37b61310ebd7281891d718241.tar.xz
command/mount: add autodetection support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'commands/mount.c')
-rw-r--r--commands/mount.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/commands/mount.c b/commands/mount.c
index b32faef709..5b12ad4d96 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -29,11 +29,14 @@
#include <command.h>
#include <fs.h>
#include <errno.h>
+#include <getopt.h>
static int do_mount(int argc, char *argv[])
{
+ int opt;
int ret = 0;
struct fs_device_d *fsdev;
+ char *type = NULL;
if (argc == 1) {
for_each_fs_device(fsdev) {
@@ -45,10 +48,18 @@ static int do_mount(int argc, char *argv[])
return 0;
}
- if (argc != 4)
+ while ((opt = getopt(argc, argv, "t:")) > 0) {
+ switch (opt) {
+ case 't':
+ type = optarg;
+ break;
+ }
+ }
+
+ if (argc < optind + 2)
return COMMAND_ERROR_USAGE;
- if ((ret = mount(argv[1], argv[2], argv[3]))) {
+ if ((ret = mount(argv[optind], type, argv[optind + 1]))) {
perror("mount");
return 1;
}
@@ -56,8 +67,9 @@ static int do_mount(int argc, char *argv[])
}
BAREBOX_CMD_HELP_START(mount)
-BAREBOX_CMD_HELP_USAGE("mount [<device> <fstype> <mountpoint>]\n")
+BAREBOX_CMD_HELP_USAGE("mount [[-t <fstype] <device> <mountpoint>]\n")
BAREBOX_CMD_HELP_SHORT("Mount a filesystem of a given type to a mountpoint.\n")
+BAREBOX_CMD_HELP_SHORT("If no fstpye is specified detected it.\n")
BAREBOX_CMD_HELP_SHORT("If no argument is given, list mounted filesystems.\n")
BAREBOX_CMD_HELP_END