util-linux/util-linux-opt-hotplug.diff

89 lines
2.8 KiB
Diff

mount/mount.8 | 7 +++++++
mount/mount.c | 15 +++++++++++++--
mount/mount_constants.h | 3 +++
3 files changed, 23 insertions(+), 2 deletions(-)
Index: util-linux-2.12r/mount/mount.8
===================================================================
--- util-linux-2.12r.orig/mount/mount.8
+++ util-linux-2.12r/mount/mount.8
@@ -572,6 +572,10 @@ This option implies the options
(unless overridden by subsequent options, as in the option line
.BR group,dev,suid ).
.TP
+.B hotplug
+Do not report errors for this device if it doesn't exist.
+.BR fcntl (2).
+.TP
.B mand
Allow mandatory locks on this filesystem. See
.BR fcntl (2).
@@ -599,6 +603,9 @@ Do not allow direct execution of any bin
(Until recently it was possible to run binaries anyway using a command like
/lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.)
.TP
+.B nohotplug
+Report an error if the device does not exist.
+.TP
.B nomand
Do not allow mandatory locks on this filesystem.
.TP
Index: util-linux-2.12r/mount/mount.c
===================================================================
--- util-linux-2.12r.orig/mount/mount.c
+++ util-linux-2.12r/mount/mount.c
@@ -162,9 +162,14 @@ static const struct opt_map opt_map[] =
{ "diratime", 0, 1, MS_NODIRATIME }, /* Update dir access times */
{ "nodiratime", 0, 0, MS_NODIRATIME },/* Do not update dir access times */
#endif
+#ifdef MS_HOTPLUG
+ { "hotplug", 0, 0, MS_HOTPLUG }, /* Don't fail if ENOENT on dev */
+#endif
{ NULL, 0, 0, 0 }
};
+static int option_hotplug; /* can not invent our own MS_FLAGS */
+
static const char *opt_loopdev, *opt_vfstype,
*opt_speed, *opt_comment;
@@ -265,6 +270,10 @@ parse_opt(const char *opt, int *mask, ch
for (om = opt_map; om->opt != NULL; om++)
if (streq (opt, om->opt)) {
+ if (om->mask & MS_HOTPLUG) {
+ option_hotplug = 1;
+ return;
+ }
if (om->inv)
*mask &= ~om->mask;
else
@@ -958,9 +967,11 @@ nosigblock:
else if (stat (node, &statbuf))
error (_("mount: mount point %s is a symbolic link to nowhere"),
node);
- else if (stat (spec, &statbuf))
+ else if (stat (spec, &statbuf)) {
+ if (option_hotplug)
+ goto out;
error (_("mount: special device %s does not exist"), spec);
- else {
+ } else {
errno = mnt_err;
perror("mount");
}
Index: util-linux-2.12r/mount/mount_constants.h
===================================================================
--- util-linux-2.12r.orig/mount/mount_constants.h
+++ util-linux-2.12r/mount/mount_constants.h
@@ -57,6 +57,9 @@ if we have a stack or plain mount - moun
#ifndef MS_VERBOSE
#define MS_VERBOSE 0x8000 /* 32768 */
#endif
+
+#define MS_HOTPLUG (1<<18) /* Don't fail if ENOENT on the dev, mount internal */
+
/*
* Magic mount flag number. Had to be or-ed to the flag values.
*/