Index: head/sbin/mount/getmntopts.3 =================================================================== --- head/sbin/mount/getmntopts.3 (revision 37424) +++ head/sbin/mount/getmntopts.3 (revision 37425) @@ -1,179 +1,179 @@ .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95 .\" .Dd March 30, 1995 .Dt GETMNTOPTS 3 .Os BSD 4.4 .Sh NAME .Nm getmntopts .Nd scan mount options .Sh SYNOPSIS .Fd #include .Ft void .Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp" .Sh DESCRIPTION The .Nm getmntopts function takes a comma separated option list and a list of valid option names, and computes the bitmask corresponding to the requested set of options. .Pp The string .Dv options is broken down into a sequence of comma separated tokens. Each token is looked up in the table described by .Dv mopts and the bits in the word referenced by either .Dv flagp or .Dv altflagp (depending on the .Dv m_altloc field of the option's table entry) are updated. The flag words are not initialized by .Nm getmntopt . The table, .Dv mopts , has the following format: .Bd -literal struct mntopt { char *m_option; /* option name */ - int m_inverse; /* is this a negative option, eg "dev" */ - int m_flag; /* bit to set, eg MNT_RDONLY */ + int m_inverse; /* is this a negative option, e.g. "dev" */ + int m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* non-zero to use altflagp rather than flagp */ }; .Ed .Pp The members of this structure are: .Bl -tag -width m_inverse .It Fa m_option the option name, for example .Dq suid . .It Fa m_inverse tells .Nm getmntopts that the name has the inverse meaning of the bit. For example, .Dq suid is the string, whereas the mount flag is .Dv MNT_NOSUID . In this case, the sense of the string and the flag are inverted, so the .Dv m_inverse flag should be set. .It Fa m_flag the value of the bit to be set or cleared in the flag word when the option is recognized. The bit is set when the option is discovered, but cleared if the option name was preceded by the letters .Dq no . The .Dv m_inverse flag causes these two operations to be reversed. .It Fa m_altloc the bit should be set or cleared in .Dv altflagp rather than .Dv flagp . .El .Pp Each of the user visible .Dv MNT_ flags has a corresponding .Dv MOPT_ macro which defines an appropriate .Li "struct mntopt" entry. To simplify the program interface and ensure consistency across all programs, a general purpose macro, .Dv MOPT_STDOPTS , is defined which contains an entry for all the generic VFS options. In addition, the macros .Dv MOPT_FORCE and .Dv MOPT_UPDATE exist to enable the .Dv MNT_FORCE and .Dv MNT_UPDATE flags to be set. Finally, the table must be terminated by an entry with a NULL first element. .Sh EXAMPLES Most commands will use the standard option set. Local filesystems which support the .Dv MNT_UPDATE flag, would also have an .Dv MOPT_UPDATE entry. This can be declared and used as follows: .Bd -literal #include "mntopts.h" struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_UPDATE, { NULL } }; ... mntflags = mntaltflags = 0; ... getmntopts(options, mopts, &mntflags, &mntaltflags); ... .Ed .Sh DIAGNOSTICS If the external integer variable .Dv getmnt_silent is non-zero then the .Nm getmntopts function displays an error message and exits if an unrecognized option is encountered. By default .Dv getmnt_silent is zero. .Sh SEE ALSO .Xr err 3 , .Xr mount 8 .Sh HISTORY The .Fn getmntopts function appeared in .Bx 4.4 . Index: head/sbin/mount/getmntopts.c =================================================================== --- head/sbin/mount/getmntopts.c (revision 37424) +++ head/sbin/mount/getmntopts.c (revision 37425) @@ -1,112 +1,108 @@ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint #if 0 static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95"; #else static const char rcsid[] = - "$Id$"; + "$Id: getmntopts.c,v 1.6 1997/08/24 21:02:47 steve Exp $"; #endif #endif /* not lint */ #include -#include #include -#include -#include #include #include -#include "extern.h" #include "mntopts.h" int getmnt_silent = 0; void getmntopts(options, m0, flagp, altflagp) const char *options; const struct mntopt *m0; int *flagp; int *altflagp; { const struct mntopt *m; int negative, len; char *opt, *optbuf, *p; int *thisflagp; /* Copy option string, since it is about to be torn asunder... */ if ((optbuf = strdup(options)) == NULL) err(1, NULL); for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { /* Check for "no" prefix. */ if (opt[0] == 'n' && opt[1] == 'o') { negative = 1; opt += 2; } else negative = 0; /* * for options with assignments in them (ie. quotas) * ignore the assignment as it's handled elsewhere */ p = strchr(opt, '='); if (p) *++p = '\0'; /* Scan option table. */ for (m = m0; m->m_option != NULL; ++m) { len = strlen(m->m_option); if (strncasecmp(opt, m->m_option, len) == 0) if ( m->m_option[len] == '\0' || m->m_option[len] == '=' ) break; } - /* Save flag, or fail if option is not recognised. */ + /* Save flag, or fail if option is not recognized. */ if (m->m_option) { thisflagp = m->m_altloc ? altflagp : flagp; if (negative == m->m_inverse) *thisflagp |= m->m_flag; else *thisflagp &= ~m->m_flag; } else if (!getmnt_silent) { errx(1, "-o %s: option not supported", opt); } } free(optbuf); } Index: head/sbin/mount/mntopts.h =================================================================== --- head/sbin/mount/mntopts.h (revision 37424) +++ head/sbin/mount/mntopts.h (revision 37425) @@ -1,91 +1,91 @@ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mntopts.h 8.7 (Berkeley) 3/29/95 - * $Id: mntopts.h,v 1.12 1997/11/13 00:28:48 julian Exp $ + * $Id: mntopts.h,v 1.13 1998/04/08 18:31:17 wosch Exp $ */ 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_inverse; /* if a negative option, e.g. "dev" */ + int m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* 1 => set bit in altflags */ }; /* User-visible MNT_ flags. */ #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 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_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 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 } #define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } #define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } #define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } /* Control flags. */ #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. */ #define MOPT_AUTO { "auto", 0, 0, 0 } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ MOPT_AUTO /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_USERQUOTA, \ MOPT_GROUPQUOTA, \ MOPT_FSTAB_COMPAT, \ MOPT_NOATIME, \ MOPT_NODEV, \ MOPT_NOEXEC, \ MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ MOPT_NOSUID, \ MOPT_NOSYMFOLLOW, \ MOPT_RDONLY, \ MOPT_UNION, \ MOPT_NOCLUSTERR, \ MOPT_NOCLUSTERW void getmntopts __P((const char *, const struct mntopt *, int *, int *)); extern int getmnt_silent; Index: head/sbin/mount/mount.c =================================================================== --- head/sbin/mount/mount.c (revision 37424) +++ head/sbin/mount/mount.c (revision 37425) @@ -1,623 +1,618 @@ /*- * Copyright (c) 1980, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1980, 1989, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; -#else -static const char rcsid[] = - "$Id: mount.c,v 1.26 1998/05/17 21:57:17 dt Exp $"; #endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "extern.h" #include "pathnames.h" int debug, fstab_style, verbose; char *catopt __P((char *, const char *)); struct statfs *getmntpt __P((const char *)); int hasopt __P((const char *, const char *)); int ismounted __P((struct fstab *, struct statfs *, int)); int isremountable __P((const char *)); void mangle __P((char *, int *, const char **)); int mountfs __P((const char *, const char *, const char *, int, const char *, const char *)); void prmount __P((struct statfs *)); void putfsent __P((const struct statfs *)); void usage __P((void)); -/* Map from mount otions to printable formats. */ +/* Map from mount options to printable formats. */ static struct opt { int o_opt; const char *o_name; } optnames[] = { { MNT_ASYNC, "asynchronous" }, { MNT_EXPORTED, "NFS exported" }, { MNT_LOCAL, "local" }, { MNT_NOATIME, "noatime" }, { MNT_NODEV, "nodev" }, { MNT_NOEXEC, "noexec" }, { MNT_NOSUID, "nosuid" }, { MNT_NOSYMFOLLOW, "nosymfollow" }, { MNT_QUOTA, "with quotas" }, { MNT_RDONLY, "read-only" }, { MNT_SYNCHRONOUS, "synchronous" }, { MNT_UNION, "union" }, { MNT_NOCLUSTERR, "noclusterr" }, { MNT_NOCLUSTERW, "noclusterw" }, { MNT_SUIDDIR, "suiddir" }, { MNT_SOFTDEP, "soft-updates" }, { NULL } }; /* * List of VFS types that can be remounted without becoming mounted on top * of each other. * XXX Is this list correct? */ static const char * remountable_fs_names[] = { "ufs", "ffs", "lfs", "ext2fs", 0 }; int main(argc, argv) int argc; char * const argv[]; { const char *mntfromname, **vfslist, *vfstype; struct fstab *fs; struct statfs *mntbuf; FILE *mountdfp; pid_t pid; int all, ch, i, init_flags, mntsize, rval; char *options; all = init_flags = 0; options = NULL; vfslist = NULL; vfstype = "ufs"; while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1) switch (ch) { case 'a': all = 1; break; case 'd': debug = 1; break; case 'f': init_flags |= MNT_FORCE; break; case 'o': if (*optarg) options = catopt(options, optarg); break; case 'p': fstab_style = 1; verbose = 1; break; case 'r': init_flags |= MNT_RDONLY; break; case 't': if (vfslist != NULL) - errx(1, "only one -t option may be specified."); + errx(1, "only one -t option may be specified"); vfslist = makevfslist(optarg); vfstype = optarg; break; case 'u': init_flags |= MNT_UPDATE; break; case 'v': verbose = 1; break; case 'w': init_flags &= ~MNT_RDONLY; break; case '?': default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) rval = 0; switch (argc) { case 0: if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) err(1, "getmntinfo"); if (all) { while ((fs = getfsent()) != NULL) { if (BADTYPE(fs->fs_type)) continue; if (checkvfsname(fs->fs_vfstype, vfslist)) continue; if (hasopt(fs->fs_mntops, "noauto")) continue; if (ismounted(fs, mntbuf, mntsize)) continue; if (mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops)) rval = 1; } } else if (fstab_style) { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; putfsent(&mntbuf[i]); } } else { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; prmount(&mntbuf[i]); } } exit(rval); case 1: if (vfslist != NULL) usage(); if (init_flags & MNT_UPDATE) { if ((mntbuf = getmntpt(*argv)) == NULL) errx(1, - "unknown special file or file system %s.", + "unknown special file or file system %s", *argv); if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) mntfromname = fs->fs_spec; else mntfromname = mntbuf->f_mntfromname; rval = mountfs(mntbuf->f_fstypename, mntfromname, mntbuf->f_mntonname, init_flags, options, 0); break; } if ((fs = getfsfile(*argv)) == NULL && (fs = getfsspec(*argv)) == NULL) - errx(1, "%s: unknown special file or file system.", + errx(1, "%s: unknown special file or file system", *argv); if (BADTYPE(fs->fs_type)) - errx(1, "%s has unknown file system type.", + errx(1, "%s has unknown file system type", *argv); rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops); break; case 2: /* * If -t flag has not been specified, and spec contains either * a ':' or a '@' then assume that an NFS filesystem is being * specified ala Sun. */ if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL) vfstype = "nfs"; rval = mountfs(vfstype, argv[0], argv[1], init_flags, options, NULL); break; default: usage(); /* NOTREACHED */ } /* * If the mount was successfully, and done by root, tell mountd the * good news. Pid checks are probably unnecessary, but don't hurt. */ if (rval == 0 && getuid() == 0 && (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) { if (fscanf(mountdfp, "%d", &pid) == 1 && pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH) err(1, "signal mountd"); (void)fclose(mountdfp); } exit(rval); } int ismounted(fs, mntbuf, mntsize) struct fstab *fs; struct statfs *mntbuf; int mntsize; { int i; if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0') /* the root file system can always be remounted */ return (0); for (i = mntsize - 1; i >= 0; --i) if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 && (!isremountable(fs->fs_vfstype) || strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0)) return (1); return (0); } int isremountable(vfsname) const char *vfsname; { const char **cp; for (cp = remountable_fs_names; *cp; cp++) if (strcmp(*cp, vfsname) == 0) return (1); return (0); } int hasopt(mntopts, option) const char *mntopts, *option; { int negative, found; char *opt, *optbuf; if (option[0] == 'n' && option[1] == 'o') { negative = 1; option += 2; } else negative = 0; optbuf = strdup(mntopts); found = 0; for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { if (opt[0] == 'n' && opt[1] == 'o') { if (!strcasecmp(opt + 2, option)) found = negative; } else if (!strcasecmp(opt, option)) found = !negative; } free(optbuf); return (found); } int mountfs(vfstype, spec, name, flags, options, mntopts) const char *vfstype, *spec, *name, *options, *mntopts; int flags; { /* List of directories containing mount_xxx subcommands. */ static const char *edirs[] = { _PATH_SBIN, _PATH_USRSBIN, NULL }; const char *argv[100], **edir; struct stat sb; struct statfs sf; pid_t pid; int argc, i, status; char *optbuf, execname[MAXPATHLEN + 1], mntpath[MAXPATHLEN]; #if __GNUC__ (void)&optbuf; (void)&name; #endif if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) { if (!S_ISDIR(sb.st_mode)) { - warnx("%s: Not a directory", mntpath); + warnx("%s: not a directory", mntpath); return (1); } } else { warn("%s", mntpath); return (1); } name = mntpath; if (mntopts == NULL) mntopts = ""; if (options == NULL) { if (*mntopts == '\0') { options = "rw"; } else { options = mntopts; mntopts = ""; } } optbuf = catopt(strdup(mntopts), options); if (strcmp(name, "/") == 0) flags |= MNT_UPDATE; if (flags & MNT_FORCE) optbuf = catopt(optbuf, "force"); if (flags & MNT_RDONLY) optbuf = catopt(optbuf, "ro"); /* * XXX * The mount_mfs (newfs) command uses -o to select the - * optimisation mode. We don't pass the default "-o rw" + * optimization mode. We don't pass the default "-o rw" * for that reason. */ if (flags & MNT_UPDATE) optbuf = catopt(optbuf, "update"); argc = 0; argv[argc++] = vfstype; mangle(optbuf, &argc, argv); argv[argc++] = spec; argv[argc++] = name; argv[argc] = NULL; if (debug) { (void)printf("exec: mount_%s", vfstype); for (i = 1; i < argc; i++) (void)printf(" %s", argv[i]); (void)printf("\n"); return (0); } switch (pid = fork()) { case -1: /* Error. */ warn("fork"); free(optbuf); return (1); case 0: /* Child. */ if (strcmp(vfstype, "ufs") == 0) exit(mount_ufs(argc, (char * const *) argv)); /* Go find an executable. */ for (edir = edirs; *edir; edir++) { (void)snprintf(execname, sizeof(execname), "%s/mount_%s", *edir, vfstype); execv(execname, (char * const *)argv); } if (errno == ENOENT) { int len = 0; char *cp; for (edir = edirs; *edir; edir++) len += strlen(*edir) + 2; /* ", " */ - if ((cp = malloc(len)) == NULL) { - warn(NULL); - exit(1); - } + if ((cp = malloc(len)) == NULL) + errx(1, "malloc failed"); cp[0] = '\0'; for (edir = edirs; *edir; edir++) { strcat(cp, *edir); if (edir[1] != NULL) strcat(cp, ", "); } warn("exec mount_%s not found in %s", vfstype, cp); } exit(1); /* NOTREACHED */ default: /* Parent. */ free(optbuf); if (waitpid(pid, &status, 0) < 0) { warn("waitpid"); return (1); } if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) return (WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { warnx("%s: %s", name, sys_siglist[WTERMSIG(status)]); return (1); } if (verbose) { if (statfs(name, &sf) < 0) { warn("statfs %s", name); return (1); } if (fstab_style) putfsent(&sf); else prmount(&sf); } break; } return (0); } void prmount(sfp) struct statfs *sfp; { int flags; struct opt *o; struct passwd *pw; int f; (void)printf("%s on %s", sfp->f_mntfromname, sfp->f_mntonname); flags = sfp->f_flags & MNT_VISFLAGMASK; for (f = 0, o = optnames; flags && o->o_opt; o++) if (flags & o->o_opt) { (void)printf("%s%s", !f++ ? " (" : ", ", o->o_name); flags &= ~o->o_opt; } if (sfp->f_owner) { (void)printf("%smounted by ", !f++ ? " (" : ", "); if ((pw = getpwuid(sfp->f_owner)) != NULL) (void)printf("%s", pw->pw_name); else (void)printf("%d", sfp->f_owner); } if (sfp->f_syncwrites != 0 || sfp->f_asyncwrites != 0) (void)printf("%swrites: sync %ld async %ld", !f++ ? " (" : ", ", sfp->f_syncwrites, sfp->f_asyncwrites); (void)printf("%s\n", f ? ")" : ""); } struct statfs * getmntpt(name) const char *name; { struct statfs *mntbuf; int i, mntsize; mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = 0; i < mntsize; i++) if (strcmp(mntbuf[i].f_mntfromname, name) == 0 || strcmp(mntbuf[i].f_mntonname, name) == 0) return (&mntbuf[i]); return (NULL); } char * catopt(s0, s1) char *s0; const char *s1; { size_t i; char *cp; if (s0 && *s0) { i = strlen(s0) + strlen(s1) + 1 + 1; if ((cp = malloc(i)) == NULL) - err(1, NULL); + errx(1, "malloc failed"); (void)snprintf(cp, i, "%s,%s", s0, s1); } else cp = strdup(s1); if (s0) free(s0); return (cp); } void mangle(options, argcp, argv) char *options; int *argcp; const char **argv; { char *p, *s; int argc; argc = *argcp; for (s = options; (p = strsep(&s, ",")) != NULL;) if (*p != '\0') if (*p == '-') { argv[argc++] = p; p = strchr(p, '='); if (p) { *p = '\0'; argv[argc++] = p+1; } } else if (strcmp(p, "rw") != 0) { argv[argc++] = "-o"; argv[argc++] = p; } *argcp = argc; } void usage() { - (void)fprintf(stderr, - "usage: mount %s %s\n mount %s\n mount %s\n", - "[-dfpruvw] [-o options] [-t ufs | external_type]", - "special node", - "[-adfpruvw] [-t ufs | external_type]", - "[-dfpruvw] special | node"); + (void)fprintf(stderr, "%s\n%s\n%s\n", +"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node", +" mount [-adfpruvw] [-t ufs | external_type]", +" mount [-dfpruvw] special | node"); exit(1); } void putfsent(ent) const struct statfs *ent; { struct fstab *fst; printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname, ent->f_fstypename, (ent->f_flags & MNT_RDONLY) ? "ro" : "rw"); /* XXX should use optnames[] - put shorter names in it. */ if (ent->f_flags & MNT_SYNCHRONOUS) printf(",sync"); if (ent->f_flags & MNT_NOEXEC) printf(",noexec"); if (ent->f_flags & MNT_NOSUID) printf(",nosuid"); if (ent->f_flags & MNT_NODEV) printf(",nodev"); if (ent->f_flags & MNT_UNION) printf(",union"); if (ent->f_flags & MNT_ASYNC) printf(",async"); if (ent->f_flags & MNT_NOATIME) printf(",noatime"); if (ent->f_flags & MNT_NOCLUSTERR) printf(",noclusterr"); if (ent->f_flags & MNT_NOCLUSTERW) printf(",noclusterw"); if (ent->f_flags & MNT_NOSYMFOLLOW) printf (",nosymfollow"); if (ent->f_flags & MNT_SUIDDIR) printf(",suiddir"); if ((fst = getfsspec(ent->f_mntfromname))) printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); else if ((fst = getfsfile(ent->f_mntonname))) printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); else if (strcmp(ent->f_fstypename, "ufs") == 0) printf("\t1 1\n"); else printf("\t0 0\n"); } Index: head/sbin/mount/mount_ufs.c =================================================================== --- head/sbin/mount/mount_ufs.c (revision 37424) +++ head/sbin/mount/mount_ufs.c (revision 37425) @@ -1,188 +1,186 @@ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95"; -#else -static const char rcsid[] = - "$Id: mount_ufs.c,v 1.12 1998/03/08 19:03:05 steve Exp $"; #endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include #include #include #include -#include -#include #include #include #include "extern.h" #include "mntopts.h" static void ufs_usage __P((void)); static struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_ASYNC, MOPT_FORCE, MOPT_SYNC, MOPT_UPDATE, { NULL } }; int mount_ufs(argc, argv) int argc; char * const argv[]; { extern int optreset; struct ufs_args args; int ch, mntflags; char *fs_name; struct vfsconf vfc; int error = 0; #ifdef ROOTSLICE_HUNT int slice, result, unit; char part, devbuf[MAXPATHLEN], devpfx[MAXPATHLEN]; #endif mntflags = 0; optind = optreset = 1; /* Reset for parse of new argv. */ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: ufs_usage(); } argc -= optind; argv += optind; if (argc != 2) ufs_usage(); args.fspec = argv[0]; /* The name of the device file. */ fs_name = argv[1]; /* The mount point. */ #define DEFAULT_ROOTUID -2 args.export.ex_root = DEFAULT_ROOTUID; if (mntflags & MNT_RDONLY) args.export.ex_flags = MNT_EXRDONLY; else args.export.ex_flags = 0; error = getvfsbyname("ufs", &vfc); if (error && vfsisloadable("ufs")) { if (vfsload("ufs")) { warn("vfsload(ufs)"); return (1); } endvfsent(); /* flush old table */ error = getvfsbyname("ufs", &vfc); } if (error) { warnx("ufs filesystem is not available"); return (1); } #ifdef ROOTSLICE_HUNT result = -1; /* * If we are mounting root, and we have a mount of something that - * might be the compatability slice, try mounting other slices + * might be the compatibility slice, try mounting other slices * first. If the kernel has done the right thing and mounted * the slice because the disk is really sliced, this will find * the real root filesystem. If not, we'll try what was supplied. */ if (!strcmp(fs_name, "/") && (sscanf(args.fspec, "%[^0-9]%d%c", devpfx, &unit, &part) == 3) && (part >= 'a') && (part <= 'h')) { for (slice = 1; (slice < 32) && (result < 0); slice++) { sprintf(devbuf, "%s%ds%d%c", devpfx, unit, slice, part); args.fspec = devbuf; result = mount(vfc.vfc_name, fs_name, mntflags, &args); } args.fspec = argv[0]; } if (result == 0) warnx("*** update /etc/fstab entry for %s to use %s ***", fs_name, devbuf); /* Try the mount as originally requested */ if ((result < 0) && (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0)) { #else if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) { #endif - (void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name); switch (errno) { case EMFILE: - (void)fprintf(stderr, "mount table full.\n"); + warnx("%s on %s: mount table full", + args.fspec, fs_name); break; case EINVAL: if (mntflags & MNT_UPDATE) - (void)fprintf(stderr, - "Specified device does not match mounted device.\n"); + warnx( + "%s on %s: specified device does not match mounted device", + args.fspec, fs_name); else - (void)fprintf(stderr, - "Incorrect super block.\n"); + warnx("%s on %s: incorrect super block", + args.fspec, fs_name); break; default: - (void)fprintf(stderr, "%s\n", strerror(errno)); + warn(NULL); break; } return (1); } return (0); } static void ufs_usage() { (void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n"); exit(1); } Index: head/sbin/mount/vfslist.c =================================================================== --- head/sbin/mount/vfslist.c (revision 37424) +++ head/sbin/mount/vfslist.c (revision 37425) @@ -1,98 +1,96 @@ /*- * Copyright (c) 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint #if 0 static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; -#else +#endif static const char rcsid[] = "$Id$"; -#endif #endif /* not lint */ #include #include #include -#include #include "extern.h" static int skipvfs; int checkvfsname(vfsname, vfslist) const char *vfsname; const char **vfslist; { if (vfslist == NULL) return (0); while (*vfslist != NULL) { if (strcmp(vfsname, *vfslist) == 0) return (skipvfs); ++vfslist; } return (!skipvfs); } const char ** makevfslist(fslist) char *fslist; { const char **av; int i; char *nextcp; if (fslist == NULL) return (NULL); if (fslist[0] == 'n' && fslist[1] == 'o') { fslist += 2; skipvfs = 1; } for (i = 0, nextcp = fslist; *nextcp; nextcp++) if (*nextcp == ',') i++; if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { - warn(NULL); + warnx("malloc failed"); return (NULL); } nextcp = fslist; i = 0; av[i++] = nextcp; while ((nextcp = strchr(nextcp, ',')) != NULL) { *nextcp++ = '\0'; av[i++] = nextcp; } av[i++] = NULL; return (av); } Index: head/sbin/mount_ifs/getmntopts.3 =================================================================== --- head/sbin/mount_ifs/getmntopts.3 (revision 37424) +++ head/sbin/mount_ifs/getmntopts.3 (revision 37425) @@ -1,179 +1,179 @@ .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95 .\" .Dd March 30, 1995 .Dt GETMNTOPTS 3 .Os BSD 4.4 .Sh NAME .Nm getmntopts .Nd scan mount options .Sh SYNOPSIS .Fd #include .Ft void .Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp" .Sh DESCRIPTION The .Nm getmntopts function takes a comma separated option list and a list of valid option names, and computes the bitmask corresponding to the requested set of options. .Pp The string .Dv options is broken down into a sequence of comma separated tokens. Each token is looked up in the table described by .Dv mopts and the bits in the word referenced by either .Dv flagp or .Dv altflagp (depending on the .Dv m_altloc field of the option's table entry) are updated. The flag words are not initialized by .Nm getmntopt . The table, .Dv mopts , has the following format: .Bd -literal struct mntopt { char *m_option; /* option name */ - int m_inverse; /* is this a negative option, eg "dev" */ - int m_flag; /* bit to set, eg MNT_RDONLY */ + int m_inverse; /* is this a negative option, e.g. "dev" */ + int m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* non-zero to use altflagp rather than flagp */ }; .Ed .Pp The members of this structure are: .Bl -tag -width m_inverse .It Fa m_option the option name, for example .Dq suid . .It Fa m_inverse tells .Nm getmntopts that the name has the inverse meaning of the bit. For example, .Dq suid is the string, whereas the mount flag is .Dv MNT_NOSUID . In this case, the sense of the string and the flag are inverted, so the .Dv m_inverse flag should be set. .It Fa m_flag the value of the bit to be set or cleared in the flag word when the option is recognized. The bit is set when the option is discovered, but cleared if the option name was preceded by the letters .Dq no . The .Dv m_inverse flag causes these two operations to be reversed. .It Fa m_altloc the bit should be set or cleared in .Dv altflagp rather than .Dv flagp . .El .Pp Each of the user visible .Dv MNT_ flags has a corresponding .Dv MOPT_ macro which defines an appropriate .Li "struct mntopt" entry. To simplify the program interface and ensure consistency across all programs, a general purpose macro, .Dv MOPT_STDOPTS , is defined which contains an entry for all the generic VFS options. In addition, the macros .Dv MOPT_FORCE and .Dv MOPT_UPDATE exist to enable the .Dv MNT_FORCE and .Dv MNT_UPDATE flags to be set. Finally, the table must be terminated by an entry with a NULL first element. .Sh EXAMPLES Most commands will use the standard option set. Local filesystems which support the .Dv MNT_UPDATE flag, would also have an .Dv MOPT_UPDATE entry. This can be declared and used as follows: .Bd -literal #include "mntopts.h" struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_UPDATE, { NULL } }; ... mntflags = mntaltflags = 0; ... getmntopts(options, mopts, &mntflags, &mntaltflags); ... .Ed .Sh DIAGNOSTICS If the external integer variable .Dv getmnt_silent is non-zero then the .Nm getmntopts function displays an error message and exits if an unrecognized option is encountered. By default .Dv getmnt_silent is zero. .Sh SEE ALSO .Xr err 3 , .Xr mount 8 .Sh HISTORY The .Fn getmntopts function appeared in .Bx 4.4 . Index: head/sbin/mount_ifs/getmntopts.c =================================================================== --- head/sbin/mount_ifs/getmntopts.c (revision 37424) +++ head/sbin/mount_ifs/getmntopts.c (revision 37425) @@ -1,112 +1,108 @@ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint #if 0 static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95"; #else static const char rcsid[] = - "$Id$"; + "$Id: getmntopts.c,v 1.6 1997/08/24 21:02:47 steve Exp $"; #endif #endif /* not lint */ #include -#include #include -#include -#include #include #include -#include "extern.h" #include "mntopts.h" int getmnt_silent = 0; void getmntopts(options, m0, flagp, altflagp) const char *options; const struct mntopt *m0; int *flagp; int *altflagp; { const struct mntopt *m; int negative, len; char *opt, *optbuf, *p; int *thisflagp; /* Copy option string, since it is about to be torn asunder... */ if ((optbuf = strdup(options)) == NULL) err(1, NULL); for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { /* Check for "no" prefix. */ if (opt[0] == 'n' && opt[1] == 'o') { negative = 1; opt += 2; } else negative = 0; /* * for options with assignments in them (ie. quotas) * ignore the assignment as it's handled elsewhere */ p = strchr(opt, '='); if (p) *++p = '\0'; /* Scan option table. */ for (m = m0; m->m_option != NULL; ++m) { len = strlen(m->m_option); if (strncasecmp(opt, m->m_option, len) == 0) if ( m->m_option[len] == '\0' || m->m_option[len] == '=' ) break; } - /* Save flag, or fail if option is not recognised. */ + /* Save flag, or fail if option is not recognized. */ if (m->m_option) { thisflagp = m->m_altloc ? altflagp : flagp; if (negative == m->m_inverse) *thisflagp |= m->m_flag; else *thisflagp &= ~m->m_flag; } else if (!getmnt_silent) { errx(1, "-o %s: option not supported", opt); } } free(optbuf); } Index: head/sbin/mount_ifs/mntopts.h =================================================================== --- head/sbin/mount_ifs/mntopts.h (revision 37424) +++ head/sbin/mount_ifs/mntopts.h (revision 37425) @@ -1,91 +1,91 @@ /*- * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mntopts.h 8.7 (Berkeley) 3/29/95 - * $Id: mntopts.h,v 1.12 1997/11/13 00:28:48 julian Exp $ + * $Id: mntopts.h,v 1.13 1998/04/08 18:31:17 wosch Exp $ */ 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_inverse; /* if a negative option, e.g. "dev" */ + int m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* 1 => set bit in altflags */ }; /* User-visible MNT_ flags. */ #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 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_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 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 } #define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } #define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } #define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } /* Control flags. */ #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. */ #define MOPT_AUTO { "auto", 0, 0, 0 } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ MOPT_AUTO /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_USERQUOTA, \ MOPT_GROUPQUOTA, \ MOPT_FSTAB_COMPAT, \ MOPT_NOATIME, \ MOPT_NODEV, \ MOPT_NOEXEC, \ MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ MOPT_NOSUID, \ MOPT_NOSYMFOLLOW, \ MOPT_RDONLY, \ MOPT_UNION, \ MOPT_NOCLUSTERR, \ MOPT_NOCLUSTERW void getmntopts __P((const char *, const struct mntopt *, int *, int *)); extern int getmnt_silent; Index: head/sbin/mount_ifs/mount.c =================================================================== --- head/sbin/mount_ifs/mount.c (revision 37424) +++ head/sbin/mount_ifs/mount.c (revision 37425) @@ -1,623 +1,618 @@ /*- * Copyright (c) 1980, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1980, 1989, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95"; -#else -static const char rcsid[] = - "$Id: mount.c,v 1.26 1998/05/17 21:57:17 dt Exp $"; #endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "extern.h" #include "pathnames.h" int debug, fstab_style, verbose; char *catopt __P((char *, const char *)); struct statfs *getmntpt __P((const char *)); int hasopt __P((const char *, const char *)); int ismounted __P((struct fstab *, struct statfs *, int)); int isremountable __P((const char *)); void mangle __P((char *, int *, const char **)); int mountfs __P((const char *, const char *, const char *, int, const char *, const char *)); void prmount __P((struct statfs *)); void putfsent __P((const struct statfs *)); void usage __P((void)); -/* Map from mount otions to printable formats. */ +/* Map from mount options to printable formats. */ static struct opt { int o_opt; const char *o_name; } optnames[] = { { MNT_ASYNC, "asynchronous" }, { MNT_EXPORTED, "NFS exported" }, { MNT_LOCAL, "local" }, { MNT_NOATIME, "noatime" }, { MNT_NODEV, "nodev" }, { MNT_NOEXEC, "noexec" }, { MNT_NOSUID, "nosuid" }, { MNT_NOSYMFOLLOW, "nosymfollow" }, { MNT_QUOTA, "with quotas" }, { MNT_RDONLY, "read-only" }, { MNT_SYNCHRONOUS, "synchronous" }, { MNT_UNION, "union" }, { MNT_NOCLUSTERR, "noclusterr" }, { MNT_NOCLUSTERW, "noclusterw" }, { MNT_SUIDDIR, "suiddir" }, { MNT_SOFTDEP, "soft-updates" }, { NULL } }; /* * List of VFS types that can be remounted without becoming mounted on top * of each other. * XXX Is this list correct? */ static const char * remountable_fs_names[] = { "ufs", "ffs", "lfs", "ext2fs", 0 }; int main(argc, argv) int argc; char * const argv[]; { const char *mntfromname, **vfslist, *vfstype; struct fstab *fs; struct statfs *mntbuf; FILE *mountdfp; pid_t pid; int all, ch, i, init_flags, mntsize, rval; char *options; all = init_flags = 0; options = NULL; vfslist = NULL; vfstype = "ufs"; while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1) switch (ch) { case 'a': all = 1; break; case 'd': debug = 1; break; case 'f': init_flags |= MNT_FORCE; break; case 'o': if (*optarg) options = catopt(options, optarg); break; case 'p': fstab_style = 1; verbose = 1; break; case 'r': init_flags |= MNT_RDONLY; break; case 't': if (vfslist != NULL) - errx(1, "only one -t option may be specified."); + errx(1, "only one -t option may be specified"); vfslist = makevfslist(optarg); vfstype = optarg; break; case 'u': init_flags |= MNT_UPDATE; break; case 'v': verbose = 1; break; case 'w': init_flags &= ~MNT_RDONLY; break; case '?': default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) rval = 0; switch (argc) { case 0: if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) err(1, "getmntinfo"); if (all) { while ((fs = getfsent()) != NULL) { if (BADTYPE(fs->fs_type)) continue; if (checkvfsname(fs->fs_vfstype, vfslist)) continue; if (hasopt(fs->fs_mntops, "noauto")) continue; if (ismounted(fs, mntbuf, mntsize)) continue; if (mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops)) rval = 1; } } else if (fstab_style) { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; putfsent(&mntbuf[i]); } } else { for (i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; prmount(&mntbuf[i]); } } exit(rval); case 1: if (vfslist != NULL) usage(); if (init_flags & MNT_UPDATE) { if ((mntbuf = getmntpt(*argv)) == NULL) errx(1, - "unknown special file or file system %s.", + "unknown special file or file system %s", *argv); if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) mntfromname = fs->fs_spec; else mntfromname = mntbuf->f_mntfromname; rval = mountfs(mntbuf->f_fstypename, mntfromname, mntbuf->f_mntonname, init_flags, options, 0); break; } if ((fs = getfsfile(*argv)) == NULL && (fs = getfsspec(*argv)) == NULL) - errx(1, "%s: unknown special file or file system.", + errx(1, "%s: unknown special file or file system", *argv); if (BADTYPE(fs->fs_type)) - errx(1, "%s has unknown file system type.", + errx(1, "%s has unknown file system type", *argv); rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, fs->fs_mntops); break; case 2: /* * If -t flag has not been specified, and spec contains either * a ':' or a '@' then assume that an NFS filesystem is being * specified ala Sun. */ if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL) vfstype = "nfs"; rval = mountfs(vfstype, argv[0], argv[1], init_flags, options, NULL); break; default: usage(); /* NOTREACHED */ } /* * If the mount was successfully, and done by root, tell mountd the * good news. Pid checks are probably unnecessary, but don't hurt. */ if (rval == 0 && getuid() == 0 && (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) { if (fscanf(mountdfp, "%d", &pid) == 1 && pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH) err(1, "signal mountd"); (void)fclose(mountdfp); } exit(rval); } int ismounted(fs, mntbuf, mntsize) struct fstab *fs; struct statfs *mntbuf; int mntsize; { int i; if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0') /* the root file system can always be remounted */ return (0); for (i = mntsize - 1; i >= 0; --i) if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 && (!isremountable(fs->fs_vfstype) || strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0)) return (1); return (0); } int isremountable(vfsname) const char *vfsname; { const char **cp; for (cp = remountable_fs_names; *cp; cp++) if (strcmp(*cp, vfsname) == 0) return (1); return (0); } int hasopt(mntopts, option) const char *mntopts, *option; { int negative, found; char *opt, *optbuf; if (option[0] == 'n' && option[1] == 'o') { negative = 1; option += 2; } else negative = 0; optbuf = strdup(mntopts); found = 0; for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) { if (opt[0] == 'n' && opt[1] == 'o') { if (!strcasecmp(opt + 2, option)) found = negative; } else if (!strcasecmp(opt, option)) found = !negative; } free(optbuf); return (found); } int mountfs(vfstype, spec, name, flags, options, mntopts) const char *vfstype, *spec, *name, *options, *mntopts; int flags; { /* List of directories containing mount_xxx subcommands. */ static const char *edirs[] = { _PATH_SBIN, _PATH_USRSBIN, NULL }; const char *argv[100], **edir; struct stat sb; struct statfs sf; pid_t pid; int argc, i, status; char *optbuf, execname[MAXPATHLEN + 1], mntpath[MAXPATHLEN]; #if __GNUC__ (void)&optbuf; (void)&name; #endif if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) { if (!S_ISDIR(sb.st_mode)) { - warnx("%s: Not a directory", mntpath); + warnx("%s: not a directory", mntpath); return (1); } } else { warn("%s", mntpath); return (1); } name = mntpath; if (mntopts == NULL) mntopts = ""; if (options == NULL) { if (*mntopts == '\0') { options = "rw"; } else { options = mntopts; mntopts = ""; } } optbuf = catopt(strdup(mntopts), options); if (strcmp(name, "/") == 0) flags |= MNT_UPDATE; if (flags & MNT_FORCE) optbuf = catopt(optbuf, "force"); if (flags & MNT_RDONLY) optbuf = catopt(optbuf, "ro"); /* * XXX * The mount_mfs (newfs) command uses -o to select the - * optimisation mode. We don't pass the default "-o rw" + * optimization mode. We don't pass the default "-o rw" * for that reason. */ if (flags & MNT_UPDATE) optbuf = catopt(optbuf, "update"); argc = 0; argv[argc++] = vfstype; mangle(optbuf, &argc, argv); argv[argc++] = spec; argv[argc++] = name; argv[argc] = NULL; if (debug) { (void)printf("exec: mount_%s", vfstype); for (i = 1; i < argc; i++) (void)printf(" %s", argv[i]); (void)printf("\n"); return (0); } switch (pid = fork()) { case -1: /* Error. */ warn("fork"); free(optbuf); return (1); case 0: /* Child. */ if (strcmp(vfstype, "ufs") == 0) exit(mount_ufs(argc, (char * const *) argv)); /* Go find an executable. */ for (edir = edirs; *edir; edir++) { (void)snprintf(execname, sizeof(execname), "%s/mount_%s", *edir, vfstype); execv(execname, (char * const *)argv); } if (errno == ENOENT) { int len = 0; char *cp; for (edir = edirs; *edir; edir++) len += strlen(*edir) + 2; /* ", " */ - if ((cp = malloc(len)) == NULL) { - warn(NULL); - exit(1); - } + if ((cp = malloc(len)) == NULL) + errx(1, "malloc failed"); cp[0] = '\0'; for (edir = edirs; *edir; edir++) { strcat(cp, *edir); if (edir[1] != NULL) strcat(cp, ", "); } warn("exec mount_%s not found in %s", vfstype, cp); } exit(1); /* NOTREACHED */ default: /* Parent. */ free(optbuf); if (waitpid(pid, &status, 0) < 0) { warn("waitpid"); return (1); } if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) return (WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { warnx("%s: %s", name, sys_siglist[WTERMSIG(status)]); return (1); } if (verbose) { if (statfs(name, &sf) < 0) { warn("statfs %s", name); return (1); } if (fstab_style) putfsent(&sf); else prmount(&sf); } break; } return (0); } void prmount(sfp) struct statfs *sfp; { int flags; struct opt *o; struct passwd *pw; int f; (void)printf("%s on %s", sfp->f_mntfromname, sfp->f_mntonname); flags = sfp->f_flags & MNT_VISFLAGMASK; for (f = 0, o = optnames; flags && o->o_opt; o++) if (flags & o->o_opt) { (void)printf("%s%s", !f++ ? " (" : ", ", o->o_name); flags &= ~o->o_opt; } if (sfp->f_owner) { (void)printf("%smounted by ", !f++ ? " (" : ", "); if ((pw = getpwuid(sfp->f_owner)) != NULL) (void)printf("%s", pw->pw_name); else (void)printf("%d", sfp->f_owner); } if (sfp->f_syncwrites != 0 || sfp->f_asyncwrites != 0) (void)printf("%swrites: sync %ld async %ld", !f++ ? " (" : ", ", sfp->f_syncwrites, sfp->f_asyncwrites); (void)printf("%s\n", f ? ")" : ""); } struct statfs * getmntpt(name) const char *name; { struct statfs *mntbuf; int i, mntsize; mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = 0; i < mntsize; i++) if (strcmp(mntbuf[i].f_mntfromname, name) == 0 || strcmp(mntbuf[i].f_mntonname, name) == 0) return (&mntbuf[i]); return (NULL); } char * catopt(s0, s1) char *s0; const char *s1; { size_t i; char *cp; if (s0 && *s0) { i = strlen(s0) + strlen(s1) + 1 + 1; if ((cp = malloc(i)) == NULL) - err(1, NULL); + errx(1, "malloc failed"); (void)snprintf(cp, i, "%s,%s", s0, s1); } else cp = strdup(s1); if (s0) free(s0); return (cp); } void mangle(options, argcp, argv) char *options; int *argcp; const char **argv; { char *p, *s; int argc; argc = *argcp; for (s = options; (p = strsep(&s, ",")) != NULL;) if (*p != '\0') if (*p == '-') { argv[argc++] = p; p = strchr(p, '='); if (p) { *p = '\0'; argv[argc++] = p+1; } } else if (strcmp(p, "rw") != 0) { argv[argc++] = "-o"; argv[argc++] = p; } *argcp = argc; } void usage() { - (void)fprintf(stderr, - "usage: mount %s %s\n mount %s\n mount %s\n", - "[-dfpruvw] [-o options] [-t ufs | external_type]", - "special node", - "[-adfpruvw] [-t ufs | external_type]", - "[-dfpruvw] special | node"); + (void)fprintf(stderr, "%s\n%s\n%s\n", +"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node", +" mount [-adfpruvw] [-t ufs | external_type]", +" mount [-dfpruvw] special | node"); exit(1); } void putfsent(ent) const struct statfs *ent; { struct fstab *fst; printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname, ent->f_fstypename, (ent->f_flags & MNT_RDONLY) ? "ro" : "rw"); /* XXX should use optnames[] - put shorter names in it. */ if (ent->f_flags & MNT_SYNCHRONOUS) printf(",sync"); if (ent->f_flags & MNT_NOEXEC) printf(",noexec"); if (ent->f_flags & MNT_NOSUID) printf(",nosuid"); if (ent->f_flags & MNT_NODEV) printf(",nodev"); if (ent->f_flags & MNT_UNION) printf(",union"); if (ent->f_flags & MNT_ASYNC) printf(",async"); if (ent->f_flags & MNT_NOATIME) printf(",noatime"); if (ent->f_flags & MNT_NOCLUSTERR) printf(",noclusterr"); if (ent->f_flags & MNT_NOCLUSTERW) printf(",noclusterw"); if (ent->f_flags & MNT_NOSYMFOLLOW) printf (",nosymfollow"); if (ent->f_flags & MNT_SUIDDIR) printf(",suiddir"); if ((fst = getfsspec(ent->f_mntfromname))) printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); else if ((fst = getfsfile(ent->f_mntonname))) printf("\t%u %u\n", fst->fs_freq, fst->fs_passno); else if (strcmp(ent->f_fstypename, "ufs") == 0) printf("\t1 1\n"); else printf("\t0 0\n"); } Index: head/sbin/mount_ifs/mount_ufs.c =================================================================== --- head/sbin/mount_ifs/mount_ufs.c (revision 37424) +++ head/sbin/mount_ifs/mount_ufs.c (revision 37425) @@ -1,188 +1,186 @@ /*- * Copyright (c) 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95"; -#else -static const char rcsid[] = - "$Id: mount_ufs.c,v 1.12 1998/03/08 19:03:05 steve Exp $"; #endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include #include #include #include -#include -#include #include #include #include "extern.h" #include "mntopts.h" static void ufs_usage __P((void)); static struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_ASYNC, MOPT_FORCE, MOPT_SYNC, MOPT_UPDATE, { NULL } }; int mount_ufs(argc, argv) int argc; char * const argv[]; { extern int optreset; struct ufs_args args; int ch, mntflags; char *fs_name; struct vfsconf vfc; int error = 0; #ifdef ROOTSLICE_HUNT int slice, result, unit; char part, devbuf[MAXPATHLEN], devpfx[MAXPATHLEN]; #endif mntflags = 0; optind = optreset = 1; /* Reset for parse of new argv. */ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: ufs_usage(); } argc -= optind; argv += optind; if (argc != 2) ufs_usage(); args.fspec = argv[0]; /* The name of the device file. */ fs_name = argv[1]; /* The mount point. */ #define DEFAULT_ROOTUID -2 args.export.ex_root = DEFAULT_ROOTUID; if (mntflags & MNT_RDONLY) args.export.ex_flags = MNT_EXRDONLY; else args.export.ex_flags = 0; error = getvfsbyname("ufs", &vfc); if (error && vfsisloadable("ufs")) { if (vfsload("ufs")) { warn("vfsload(ufs)"); return (1); } endvfsent(); /* flush old table */ error = getvfsbyname("ufs", &vfc); } if (error) { warnx("ufs filesystem is not available"); return (1); } #ifdef ROOTSLICE_HUNT result = -1; /* * If we are mounting root, and we have a mount of something that - * might be the compatability slice, try mounting other slices + * might be the compatibility slice, try mounting other slices * first. If the kernel has done the right thing and mounted * the slice because the disk is really sliced, this will find * the real root filesystem. If not, we'll try what was supplied. */ if (!strcmp(fs_name, "/") && (sscanf(args.fspec, "%[^0-9]%d%c", devpfx, &unit, &part) == 3) && (part >= 'a') && (part <= 'h')) { for (slice = 1; (slice < 32) && (result < 0); slice++) { sprintf(devbuf, "%s%ds%d%c", devpfx, unit, slice, part); args.fspec = devbuf; result = mount(vfc.vfc_name, fs_name, mntflags, &args); } args.fspec = argv[0]; } if (result == 0) warnx("*** update /etc/fstab entry for %s to use %s ***", fs_name, devbuf); /* Try the mount as originally requested */ if ((result < 0) && (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0)) { #else if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) { #endif - (void)fprintf(stderr, "%s on %s: ", args.fspec, fs_name); switch (errno) { case EMFILE: - (void)fprintf(stderr, "mount table full.\n"); + warnx("%s on %s: mount table full", + args.fspec, fs_name); break; case EINVAL: if (mntflags & MNT_UPDATE) - (void)fprintf(stderr, - "Specified device does not match mounted device.\n"); + warnx( + "%s on %s: specified device does not match mounted device", + args.fspec, fs_name); else - (void)fprintf(stderr, - "Incorrect super block.\n"); + warnx("%s on %s: incorrect super block", + args.fspec, fs_name); break; default: - (void)fprintf(stderr, "%s\n", strerror(errno)); + warn(NULL); break; } return (1); } return (0); } static void ufs_usage() { (void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n"); exit(1); } Index: head/sbin/mount_ifs/vfslist.c =================================================================== --- head/sbin/mount_ifs/vfslist.c (revision 37424) +++ head/sbin/mount_ifs/vfslist.c (revision 37425) @@ -1,98 +1,96 @@ /*- * Copyright (c) 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint #if 0 static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; -#else +#endif static const char rcsid[] = "$Id$"; -#endif #endif /* not lint */ #include #include #include -#include #include "extern.h" static int skipvfs; int checkvfsname(vfsname, vfslist) const char *vfsname; const char **vfslist; { if (vfslist == NULL) return (0); while (*vfslist != NULL) { if (strcmp(vfsname, *vfslist) == 0) return (skipvfs); ++vfslist; } return (!skipvfs); } const char ** makevfslist(fslist) char *fslist; { const char **av; int i; char *nextcp; if (fslist == NULL) return (NULL); if (fslist[0] == 'n' && fslist[1] == 'o') { fslist += 2; skipvfs = 1; } for (i = 0, nextcp = fslist; *nextcp; nextcp++) if (*nextcp == ',') i++; if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { - warn(NULL); + warnx("malloc failed"); return (NULL); } nextcp = fslist; i = 0; av[i++] = nextcp; while ((nextcp = strchr(nextcp, ',')) != NULL) { *nextcp++ = '\0'; av[i++] = nextcp; } av[i++] = NULL; return (av); }