mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 9/9] mount: use standard mountpath if path is ommitted
Date: Sun, 29 Sep 2013 12:05:00 +0200	[thread overview]
Message-ID: <1380449100-6295-10-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1380449100-6295-1-git-send-email-s.hauer@pengutronix.de>

With this a mount <devname> will mount the device to /mnt/<devname>. This
directory is created automatically if it doesn't exist already.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/mount.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/commands/mount.c b/commands/mount.c
index 96a4164..2e9d4be 100644
--- a/commands/mount.c
+++ b/commands/mount.c
@@ -27,6 +27,7 @@
 #include <fs.h>
 #include <errno.h>
 #include <getopt.h>
+#include <linux/err.h>
 
 static int do_mount(int argc, char *argv[])
 {
@@ -70,6 +71,28 @@ static int do_mount(int argc, char *argv[])
 		return 0;
 	}
 
+	if (argc == optind + 1) {
+		struct cdev *cdev;
+		const char *path, *devstr;
+
+		devstr = argv[optind];
+
+		if (!strncmp(devstr, "/dev/", 5))
+			devstr += 5;
+
+		cdev = cdev_by_name(devstr);
+		if (!cdev)
+			return -ENOENT;
+
+		path = cdev_mount_default(cdev);
+		if (IS_ERR(path))
+			return PTR_ERR(path);
+
+		printf("mounted /dev/%s on %s\n", devstr, path);
+
+		return 0;
+	}
+
 	if (argc < optind + 2)
 		return COMMAND_ERROR_USAGE;
 
@@ -93,7 +116,7 @@ static int do_mount(int argc, char *argv[])
 }
 
 BAREBOX_CMD_HELP_START(mount)
-BAREBOX_CMD_HELP_USAGE("mount [[OPTIONS] <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("-a", "Mount all blockdevices.\n")
 BAREBOX_CMD_HELP_OPT("-v", "be more verbose\n")
@@ -102,6 +125,8 @@ BAREBOX_CMD_HELP_SHORT("If no fstype is specified, try to detect it automaticall
 BAREBOX_CMD_HELP_SHORT("If no argument is given, list mounted filesystems.\n")
 BAREBOX_CMD_HELP_SHORT("With -a the mount command mounts all block devices whose filesystem\n")
 BAREBOX_CMD_HELP_SHORT("can be detected automatically to /mnt/<partname>\n")
+BAREBOX_CMD_HELP_SHORT("If mountpoint is not given a standard mountpoint of /mnt/devname>\n")
+BAREBOX_CMD_HELP_SHORT("is used. This directoy is created automatically if necessary.\n")
 BAREBOX_CMD_HELP_END
 
 /**
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2013-09-29 10:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-29 10:04 fs mounting patches Sascha Hauer
2013-09-29 10:04 ` [PATCH 1/9] copy_file: Add missing O_TRUNC Sascha Hauer
2013-09-29 10:04 ` [PATCH 2/9] fs: cleanup backingstore handling Sascha Hauer
2013-09-29 10:04 ` [PATCH 3/9] mount: print backingstore instead of dev_name Sascha Hauer
2013-09-29 10:04 ` [PATCH 4/9] fs: use bus_for_each_driver Sascha Hauer
2013-09-29 10:04 ` [PATCH 5/9] fs: remove unused field 'name' from struct fs_driver_d Sascha Hauer
2013-09-29 10:04 ` [PATCH 6/9] mount: implement -v option to print available filesystems Sascha Hauer
2013-09-29 10:04 ` [PATCH 7/9] fs: add cdev mount helpers Sascha Hauer
2013-09-29 10:04 ` [PATCH 8/9] mount: Allow to mount all available partitions Sascha Hauer
2013-09-29 10:05 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380449100-6295-10-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox