From 41e3198c7ccf02232ad4de7af102bd33c9d616f1 Mon Sep 17 00:00:00 2001 From: claudio Date: Sun, 13 Jul 2014 12:01:30 +0000 Subject: [PATCH] Introduce a -N option to mount and a 'net' mount option. File systems marked with net will not be mounted by default. mount -a -N will mount all those file systems instead. This will be used to mark file systems needing network to work -- in other words which depend on iscsid. "Get it in" deraadt@ --- sbin/mount/mntopts.h | 6 ++++-- sbin/mount/mount.8 | 18 ++++++++++++++++-- sbin/mount/mount.c | 18 ++++++++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h index 5474a0134f7..da0ea3f6f10 100644 --- a/sbin/mount/mntopts.h +++ b/sbin/mount/mntopts.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mntopts.h,v 1.15 2005/05/26 01:37:49 pedro Exp $ */ +/* $OpenBSD: mntopts.h,v 1.16 2014/07/13 12:01:30 claudio Exp $ */ /* $NetBSD: mntopts.h,v 1.3 1995/03/18 14:56:59 cgd Exp $ */ /*- @@ -75,12 +75,14 @@ union mntval { #define MOPT_RO { "ro", MNT_RDONLY, MFLAG_SET } #define MOPT_RW { "rw", MNT_RDONLY, MFLAG_INVERSE | MFLAG_SET } -/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ +/* These are parsed by mount(8), but are ignored by specific mount_*(8)s. */ #define MOPT_AUTO { "auto", 0, MFLAG_SET } +#define MOPT_NET { "net", 0, MFLAG_SET } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ + MOPT_NET, \ MOPT_AUTO /* Standard options which all mounts can understand. */ diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8 index 1a1c0e5fadb..4226f019d8a 100644 --- a/sbin/mount/mount.8 +++ b/sbin/mount/mount.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mount.8,v 1.74 2014/06/24 02:32:43 daniel Exp $ +.\" $OpenBSD: mount.8,v 1.75 2014/07/13 12:01:30 claudio Exp $ .\" $NetBSD: mount.8,v 1.11 1995/07/12 06:23:21 cgd Exp $ .\" .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)mount.8 8.7 (Berkeley) 3/27/94 .\" -.Dd $Mdocdate: June 24 2014 $ +.Dd $Mdocdate: July 13 2014 $ .Dt MOUNT 8 .Os .Sh NAME @@ -118,6 +118,8 @@ to try to mount all of the file systems listed in the .Xr fstab 5 table except those for which the .Dq noauto +or +.Dq net option is specified. .It Fl a Similar to the @@ -145,6 +147,18 @@ command is trying to do. Either force mounting of dirty file systems or, in the case of a downgrade from read-write to read-only operation, the revocation of opened files with write access. +.It Fl N +If used with either +.Fl A +or +.Fl a , +.Xm +will only look at file systems which have the +.Dq net +option specified. +By default file systems with the +.Dq net +option are ignored. .It Fl o Ar options Options can be given with (or without) a .Sq no diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index f0c2a84c008..4bd52989b89 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.55 2014/06/24 02:32:43 daniel Exp $ */ +/* $OpenBSD: mount.c,v 1.56 2014/07/13 12:01:30 claudio Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -54,6 +54,7 @@ int debug, verbose, skip; char **typelist = NULL; +enum { NONET_FILTER, NET_FILTER } filter = NONET_FILTER; int selected(const char *); char *catopt(char *, const char *); @@ -109,7 +110,7 @@ main(int argc, char * const argv[]) all = forceall = 0; options = NULL; vfstype = "ffs"; - while ((ch = getopt(argc, argv, "Aadfo:rswt:uv")) != -1) + while ((ch = getopt(argc, argv, "AadfNo:rswt:uv")) != -1) switch (ch) { case 'A': all = forceall = 1; @@ -124,6 +125,9 @@ main(int argc, char * const argv[]) if (!hasopt(options, "force")) options = catopt(options, "force"); break; + case 'N': + filter = NET_FILTER; + break; case 'o': if (*optarg) options = catopt(options, optarg); @@ -172,6 +176,16 @@ main(int argc, char * const argv[]) while ((fs = getfsent()) != NULL) { if (BADTYPE(fs->fs_type)) continue; + switch (filter) { + case NET_FILTER: + if (!hasopt(fs->fs_mntops, "net")) + continue; + break; + case NONET_FILTER: + if (hasopt(fs->fs_mntops, "net")) + continue; + break; + } if (!selected(fs->fs_vfstype)) continue; if (hasopt(fs->fs_mntops, "noauto")) -- 2.20.1