mount/mount.8 | 7 +++++++ mount/mount.c | 15 +++++++++++++-- mount/mount_constants.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) Index: util-linux-ng-2.12r+git20070330/mount/mount.8 =================================================================== --- util-linux-ng-2.12r+git20070330.orig/mount/mount.8 +++ util-linux-ng-2.12r+git20070330/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). @@ -602,6 +606,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-ng-2.12r+git20070330/mount/mount.c =================================================================== --- util-linux-ng-2.12r+git20070330.orig/mount/mount.c +++ util-linux-ng-2.12r+git20070330/mount/mount.c @@ -174,9 +174,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_offset, *opt_encryption, *opt_speed, *opt_comment; @@ -269,6 +274,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 @@ -985,9 +994,11 @@ retry_nfs: 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-ng-2.12r+git20070330/mount/mount_constants.h =================================================================== --- util-linux-ng-2.12r+git20070330.orig/mount/mount_constants.h +++ util-linux-ng-2.12r+git20070330/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. */