allow setting of alternate flags (from FreeBSD
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 30 Mar 1995 12:24:37 +0000 (04:24 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 30 Mar 1995 12:24:37 +0000 (04:24 -0800)
SCCS-vsn: sbin/mount/getmntopts.c 8.3
SCCS-vsn: sbin/mount/mntopts.h 8.7

usr/src/sbin/mount/getmntopts.c
usr/src/sbin/mount/mntopts.h

index c7b30fe..d2e8ee9 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)getmntopts.c       8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)getmntopts.c       8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -20,15 +20,19 @@ static char sccsid[] = "@(#)getmntopts.c    8.2 (Berkeley) %G%";
 
 #include "mntopts.h"
 
 
 #include "mntopts.h"
 
+int getmnt_silent = 0;
+
 void
 void
-getmntopts(options, m0, flagp)
+getmntopts(options, m0, flagp, altflagp)
        const char *options;
        const struct mntopt *m0;
        int *flagp;
        const char *options;
        const struct mntopt *m0;
        int *flagp;
+       int *altflagp;
 {
        const struct mntopt *m;
        int negative;
        char *opt, *optbuf, *p;
 {
        const struct mntopt *m;
        int negative;
        char *opt, *optbuf, *p;
+       int *thisflagp;
 
        /* Copy option string, since it is about to be torn asunder... */
        if ((optbuf = strdup(options)) == NULL)
 
        /* Copy option string, since it is about to be torn asunder... */
        if ((optbuf = strdup(options)) == NULL)
@@ -57,12 +61,14 @@ getmntopts(options, m0, flagp)
 
                /* Save flag, or fail if option is not recognised. */
                if (m->m_option) {
 
                /* Save flag, or fail if option is not recognised. */
                if (m->m_option) {
+                       thisflagp = m->m_altloc ? altflagp : flagp;
                        if (negative == m->m_inverse)
                        if (negative == m->m_inverse)
-                               *flagp |= m->m_flag;
+                               *thisflagp |= m->m_flag;
                        else
                        else
-                               *flagp &= ~m->m_flag;
-               } else
+                               *thisflagp &= ~m->m_flag;
+               } else if (!getmnt_silent) {
                        errx(1, "-o %s: option not supported", opt);
                        errx(1, "-o %s: option not supported", opt);
+               }
        }
 
        free(optbuf);
        }
 
        free(optbuf);
index 8618077..40ac1fe 100644 (file)
@@ -4,34 +4,35 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)mntopts.h   8.6 (Berkeley) %G%
+ *     @(#)mntopts.h   8.7 (Berkeley) %G%
  */
 
 struct mntopt {
        const char *m_option;   /* option name */
        int m_inverse;          /* if a negative option, eg "dev" */
        int m_flag;             /* bit to set, eg. MNT_RDONLY */
  */
 
 struct mntopt {
        const char *m_option;   /* option name */
        int m_inverse;          /* if a negative option, eg "dev" */
        int m_flag;             /* bit to set, eg. MNT_RDONLY */
+       int m_altloc;           /* 1 => set bit in altflags */
 };
 
 /* User-visible MNT_ flags. */
 };
 
 /* User-visible MNT_ flags. */
-#define MOPT_ASYNC             { "async",      0, MNT_ASYNC }
-#define MOPT_NODEV             { "dev",        1, MNT_NODEV }
-#define MOPT_NOEXEC            { "exec",       1, MNT_NOEXEC }
-#define MOPT_NOSUID            { "suid",       1, MNT_NOSUID }
-#define MOPT_RDONLY            { "rdonly",     0, MNT_RDONLY }
-#define MOPT_SYNC              { "sync",       0, MNT_SYNCHRONOUS }
-#define MOPT_UNION             { "union",      0, MNT_UNION }
-#define MOPT_USERQUOTA         { "userquota",  0, 0 }
-#define MOPT_GROUPQUOTA                { "groupquota", 0, 0 }
+#define MOPT_ASYNC             { "async",      0, MNT_ASYNC, 0 }
+#define MOPT_NODEV             { "dev",        1, MNT_NODEV, 0 }
+#define MOPT_NOEXEC            { "exec",       1, MNT_NOEXEC, 0 }
+#define MOPT_NOSUID            { "suid",       1, MNT_NOSUID, 0 }
+#define MOPT_RDONLY            { "rdonly",     0, MNT_RDONLY, 0 }
+#define MOPT_SYNC              { "sync",       0, MNT_SYNCHRONOUS, 0 }
+#define MOPT_UNION             { "union",      0, MNT_UNION, 0 }
+#define MOPT_USERQUOTA         { "userquota",  0, 0, 0 }
+#define MOPT_GROUPQUOTA                { "groupquota", 0, 0, 0 }
 
 /* Control flags. */
 
 /* Control flags. */
-#define MOPT_FORCE             { "force",      0, MNT_FORCE }
-#define MOPT_UPDATE            { "update",     0, MNT_UPDATE }
-#define MOPT_RO                        { "ro",         0, MNT_RDONLY }
-#define MOPT_RW                        { "rw",         1, MNT_RDONLY }
+#define MOPT_FORCE             { "force",      0, MNT_FORCE, 0 }
+#define MOPT_UPDATE            { "update",     0, MNT_UPDATE, 0 }
+#define MOPT_RO                        { "ro",         0, MNT_RDONLY, 0 }
+#define MOPT_RW                        { "rw",         1, MNT_RDONLY, 0 }
 
 /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
 
 /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
-#define MOPT_AUTO              { "auto",       0, 0 }
+#define MOPT_AUTO              { "auto",       0, 0, 0 }
 
 #define MOPT_FSTAB_COMPAT                                              \
        MOPT_RO,                                                        \
 
 #define MOPT_FSTAB_COMPAT                                              \
        MOPT_RO,                                                        \
@@ -49,4 +50,5 @@ struct mntopt {
        MOPT_RDONLY,                                                    \
        MOPT_UNION
 
        MOPT_RDONLY,                                                    \
        MOPT_UNION
 
-void getmntopts __P((const char *, const struct mntopt *, int *));
+void getmntopts __P((const char *, const struct mntopt *, int *, int *));
+extern int getmnt_silent;