mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] fs: Create automount entries for the default mount pathes
Date: Wed, 10 May 2017 08:14:22 +0200	[thread overview]
Message-ID: <20170510061422.17036-1-s.hauer@pengutronix.de> (raw)

In barebox the default mount path for a cdev is /mnt/<cdevname>
which can be mounted with "mount <cdevname>" without specifying
a target path explicitly. Simplify this further by creating automount
entries for the default mount pathes which makes a manual mount
completely unnecessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/block.c   |  2 ++
 fs/devfs-core.c  |  2 ++
 fs/fs.c          | 14 ++++++++++++++
 include/driver.h |  8 ++++++++
 4 files changed, 26 insertions(+)

diff --git a/common/block.c b/common/block.c
index 0edc8619ef..e2ba9d4296 100644
--- a/common/block.c
+++ b/common/block.c
@@ -374,6 +374,8 @@ int blockdevice_register(struct block_device *blk)
 
 	list_add_tail(&blk->list, &block_device_list);
 
+	cdev_create_default_automount(&blk->cdev);
+
 	return 0;
 }
 
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 382606f1cf..26fffbb6c2 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -332,6 +332,8 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev,
 
 	devfs_create(new);
 
+	cdev_create_default_automount(new);
+
 	return new;
 }
 
diff --git a/fs/fs.c b/fs/fs.c
index 1901c94ad1..9a5887f580 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -328,6 +328,20 @@ int automount_add(const char *path, const char *cmd)
 }
 EXPORT_SYMBOL(automount_add);
 
+void cdev_create_default_automount(struct cdev *cdev)
+{
+	char *path, *cmd;
+
+	path = basprintf("/mnt/%s", cdev->name);
+	cmd = basprintf("mount %s", cdev->name);
+
+	make_directory(path);
+	automount_add(path, cmd);
+
+	free(cmd);
+	free(path);
+}
+
 void automount_print(void)
 {
 	struct automount *am;
diff --git a/include/driver.h b/include/driver.h
index 52e06f7d62..b743ed8b77 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -490,6 +490,14 @@ struct cdev *devfs_add_partition(const char *devname, loff_t offset,
 		loff_t size, unsigned int flags, const char *name);
 int devfs_del_partition(const char *name);
 
+#ifdef CONFIG_FS_AUTOMOUNT
+void cdev_create_default_automount(struct cdev *cdev);
+#else
+static inline void cdev_create_default_automount(struct cdev *cdev)
+{
+}
+#endif
+
 #define DEVFS_PARTITION_APPEND		0
 
 /**
-- 
2.11.0


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

                 reply	other threads:[~2017-05-10  6:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170510061422.17036-1-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