diff -ruN --exclude=CVS ../src.old/sbin/mount/getmntopts.c ./sbin/mount/getmntopts.c --- ../src.old/sbin/mount/getmntopts.c Mon Nov 18 15:22:45 2002 +++ ./sbin/mount/getmntopts.c Tue Dec 10 19:44:21 2002 @@ -34,6 +34,7 @@ * SUCH DAMAGE. */ +#include #ifndef lint #if 0 static char sccsid[] = "@(#)getmntopts.c 8.1 (Berkeley) 3/27/94"; @@ -53,15 +54,19 @@ #include "mntopts.h" +int getmnt_silent = 0; + void -getmntopts(options, m0, flagp) +getmntopts(options, m0, flagp, altflagp) const char *options; const struct mntopt *m0; int *flagp; + int *altflagp; { 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) @@ -90,12 +95,14 @@ /* Save flag, or fail if option is not recognised. */ if (m->m_option) { + thisflagp = m->m_altloc ? altflagp : flagp; if (negative == m->m_inverse) - *flagp |= m->m_flag; + *thisflagp |= m->m_flag; else - *flagp &= ~m->m_flag; - } else + *thisflagp &= ~m->m_flag; + } else if (!getmnt_silent) { errx(1, "-o %s: option not supported", opt); + } } free(optbuf); diff -ruN --exclude=CVS ../src.old/sbin/mount/mntopts.h ./sbin/mount/mntopts.h --- ../src.old/sbin/mount/mntopts.h Mon Nov 18 15:22:45 2002 +++ ./sbin/mount/mntopts.h Tue Dec 10 19:38:11 2002 @@ -40,6 +40,7 @@ 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. */ @@ -86,4 +87,4 @@ MOPT_RDONLY, \ MOPT_UNION -void getmntopts(const char *, const struct mntopt *, int *); +void getmntopts __P((const char *, const struct mntopt *, int *, int *)); diff -ruN --exclude=CVS ../src.old/sbin/mount_ados/mount_ados.c ./sbin/mount_ados/mount_ados.c --- ../src.old/sbin/mount_ados/mount_ados.c Tue Apr 23 14:54:12 2002 +++ ./sbin/mount_ados/mount_ados.c Tue Dec 10 19:38:11 2002 @@ -89,7 +89,7 @@ set_mask = 1; break; case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_cd9660/mount_cd9660.c ./sbin/mount_cd9660/mount_cd9660.c --- ../src.old/sbin/mount_cd9660/mount_cd9660.c Tue Apr 23 14:54:12 2002 +++ ./sbin/mount_cd9660/mount_cd9660.c Tue Dec 10 19:38:11 2002 @@ -96,7 +96,7 @@ opts |= ISOFSMNT_NOJOLIET; break; case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case 'R': opts |= ISOFSMNT_NORRIP; diff -ruN --exclude=CVS ../src.old/sbin/mount_ext2fs/mount_ext2fs.c ./sbin/mount_ext2fs/mount_ext2fs.c --- ../src.old/sbin/mount_ext2fs/mount_ext2fs.c Tue Apr 23 14:54:12 2002 +++ ./sbin/mount_ext2fs/mount_ext2fs.c Tue Dec 10 19:38:11 2002 @@ -82,7 +82,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_fdesc/mount_fdesc.c ./sbin/mount_fdesc/mount_fdesc.c --- ../src.old/sbin/mount_fdesc/mount_fdesc.c Sat Feb 16 16:27:36 2002 +++ ./sbin/mount_fdesc/mount_fdesc.c Tue Dec 10 19:38:12 2002 @@ -82,7 +82,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_ffs/mount_ffs.c ./sbin/mount_ffs/mount_ffs.c --- ../src.old/sbin/mount_ffs/mount_ffs.c Tue Apr 23 14:54:12 2002 +++ ./sbin/mount_ffs/mount_ffs.c Tue Dec 10 19:38:12 2002 @@ -87,7 +87,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_kernfs/mount_kernfs.c ./sbin/mount_kernfs/mount_kernfs.c --- ../src.old/sbin/mount_kernfs/mount_kernfs.c Sat Feb 16 16:27:36 2002 +++ ./sbin/mount_kernfs/mount_kernfs.c Tue Dec 10 19:38:12 2002 @@ -82,7 +82,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_msdos/mount_msdos.c ./sbin/mount_msdos/mount_msdos.c --- ../src.old/sbin/mount_msdos/mount_msdos.c Tue Apr 23 14:54:12 2002 +++ ./sbin/mount_msdos/mount_msdos.c Tue Dec 10 19:38:12 2002 @@ -103,7 +103,7 @@ set_mask = 1; break; case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/mount_null/mount_null.c ./sbin/mount_null/mount_null.c --- ../src.old/sbin/mount_null/mount_null.c Sat Feb 16 16:27:36 2002 +++ ./sbin/mount_null/mount_null.c Tue Dec 10 19:38:12 2002 @@ -64,17 +64,29 @@ #include "mntopts.h" -const struct mntopt mopts[] = { +static const struct mntopt mopts[] = { MOPT_STDOPTS, { NULL } }; -int subdir(const char *, const char *); -void usage(void); +int main __P((int, char *[])); +int mount_null __P((int argc, char **argv)); +static int subdir __P((const char *, const char *)); +static void usage __P((void)); +#ifndef MOUNT_NOMAIN int main(argc, argv) int argc; + char **argv; +{ + return mount_null(argc, argv); +} +#endif + +int +mount_null(argc, argv) + int argc; char *argv[]; { struct null_args args; @@ -85,7 +97,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch(ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: @@ -104,7 +116,7 @@ errx(1, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); - args.target = target; + args.la.target = target; if (mount(MOUNT_NULL, argv[1], mntflags, &args)) { if (errno == EOPNOTSUPP) @@ -116,7 +128,7 @@ exit(0); } -int +static int subdir(p, dir) const char *p; const char *dir; @@ -133,7 +145,7 @@ return (0); } -void +static void usage() { (void)fprintf(stderr, diff -ruN --exclude=CVS ../src.old/sbin/mount_portal/mount_portal.c ./sbin/mount_portal/mount_portal.c --- ../src.old/sbin/mount_portal/mount_portal.c Fri Sep 6 17:16:34 2002 +++ ./sbin/mount_portal/mount_portal.c Tue Dec 10 19:38:12 2002 @@ -143,7 +143,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) { switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; default: error = 1; diff -ruN --exclude=CVS ../src.old/sbin/mount_umap/mount_umap.c ./sbin/mount_umap/mount_umap.c --- ../src.old/sbin/mount_umap/mount_umap.c Sun Jun 9 04:13:08 2002 +++ ./sbin/mount_umap/mount_umap.c Wed Dec 11 00:59:35 2002 @@ -37,6 +37,7 @@ * SUCH DAMAGE. */ +#include #ifndef lint char copyright[] = "@(#) Copyright (c) 1992, 1993, 1994\n\ @@ -84,16 +85,28 @@ * will, in turn, call the umap version of mount. */ -const struct mntopt mopts[] = { +static const struct mntopt mopts[] = { MOPT_STDOPTS, { NULL } }; -void usage(void); +int main __P((int, char *[])); +int mount_umap __P((int argc, char **argv)); +static void usage __P((void)); +#ifndef MOUNT_NOMAIN int main(argc, argv) int argc; + char **argv; +{ + return mount_umap(argc, argv); +} +#endif + +int +mount_umap(argc, argv) + int argc; char *argv[]; { static char not[] = "; not mounted."; @@ -101,23 +114,23 @@ struct umap_args args; FILE *fp, *gfp; long d1, d2; - id_t umapdata[UMAPFILEENTRIES][2]; - id_t gmapdata[GMAPFILEENTRIES][2]; - int ch, count, gnentries, mntflags, unentries; - char *gmapfile, *umapfile, *source, *target, buf[20]; + u_long mapdata[MAPFILEENTRIES][2]; + u_long gmapdata[GMAPFILEENTRIES][2]; + int ch, count, gnentries, mntflags, nentries; + char *gmapfile, *mapfile, *source, *target, buf[20]; mntflags = 0; - umapfile = gmapfile = NULL; + mapfile = gmapfile = NULL; while ((ch = getopt(argc, argv, "g:o:u:")) != -1) switch (ch) { case 'g': gmapfile = optarg; break; case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case 'u': - umapfile = optarg; + mapfile = optarg; break; case '?': default: @@ -126,55 +139,55 @@ argc -= optind; argv += optind; - if (argc != 2 || umapfile == NULL || gmapfile == NULL) + if (argc != 2 || mapfile == NULL || gmapfile == NULL) usage(); source = argv[0]; target = argv[1]; /* Read in uid mapping data. */ - if ((fp = fopen(umapfile, "r")) == NULL) - err(1, "%s%s", umapfile, not); + if ((fp = fopen(mapfile, "r")) == NULL) + err(1, "%s%s", mapfile, not); #ifdef MAPSECURITY /* * Check that group and other don't have write permissions on - * this umapfile, and that the umapfile belongs to root. + * this mapfile, and that the mapfile belongs to root. */ if (fstat(fileno(fp), &statbuf)) - err(1, "%s%s", umapfile, not); + err(1, "%s%s", mapfile, not); if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) { strmode(statbuf.st_mode, buf); err(1, "%s: improper write permissions (%s)%s", - umapfile, buf, not); + mapfile, buf, not); } if (statbuf.st_uid != ROOTUSER) - errx(1, "%s does not belong to root%s", umapfile, not); + errx(1, "%s does not belong to root%s", mapfile, not); #endif /* MAPSECURITY */ - if ((fscanf(fp, "%d\n", &unentries)) != 1) - errx(1, "%s: nentries not found%s", umapfile, not); - if (unentries > UMAPFILEENTRIES) + if ((fscanf(fp, "%d\n", &nentries)) != 1) + errx(1, "%s: nentries not found%s", mapfile, not); + if (nentries > MAPFILEENTRIES) errx(1, - "maximum number of entries is %d%s", UMAPFILEENTRIES, not); + "maximum number of entries is %d%s", MAPFILEENTRIES, not); #if 0 - (void)printf("reading %d entries\n", unentries); + (void)printf("reading %d entries\n", nentries); #endif - for (count = 0; count < unentries; ++count) { + for (count = 0; count < nentries; ++count) { if ((fscanf(fp, "%lu %lu\n", &d1, &d2)) != 2) { if (ferror(fp)) - err(1, "%s%s", umapfile, not); + err(1, "%s%s", mapfile, not); if (feof(fp)) errx(1, "%s: unexpected end-of-file%s", - umapfile, not); + mapfile, not); errx(1, "%s: illegal format (line %d)%s", - umapfile, count + 2, not); + mapfile, count + 2, not); } - umapdata[count][0] = d1; - umapdata[count][1] = d2; + mapdata[count][0] = d1; + mapdata[count][1] = d2; #if 0 /* Fix a security hole. */ - if (umapdata[count][1] == 0) + if (mapdata[count][1] == 0) errx(1, "mapping id 0 not permitted (line %d)%s", count + 2, not); #endif @@ -187,7 +200,7 @@ #ifdef MAPSECURITY /* * Check that group and other don't have write permissions on - * this group mapfile, and that the file belongs to root. + * this group mapfile, and that the file belongs to root. */ if (fstat(fileno(gfp), &statbuf)) err(1, "%s%s", gmapfile, not); @@ -201,8 +214,8 @@ #endif /* MAPSECURITY */ if ((fscanf(gfp, "%d\n", &gnentries)) != 1) - errx(1, "%s: nentries not found%s", gmapfile, not); - if (gnentries > GMAPFILEENTRIES) + errx(1, "nentries not found%s", not); + if (gnentries > MAPFILEENTRIES) errx(1, "maximum number of entries is %d%s", GMAPFILEENTRIES, not); #if 0 @@ -210,7 +223,8 @@ #endif for (count = 0; count < gnentries; ++count) { - if ((fscanf(gfp, "%lu %lu\n", &d1, &d2)) != 2) { + if ((fscanf(gfp, "%lu %lu\n", + &(gmapdata[count][0]), &(gmapdata[count][1]))) != 2) { if (ferror(gfp)) err(1, "%s%s", gmapfile, not); if (feof(gfp)) @@ -219,17 +233,15 @@ errx(1, "%s: illegal format (line %d)%s", gmapfile, count + 2, not); } - gmapdata[count][0] = d1; - gmapdata[count][1] = d2; } /* Setup mount call args. */ - args.target = source; - args.unentries = unentries; - args.umapdata = umapdata; + args.la.target = source; + args.nentries = nentries; + args.mapdata = mapdata; args.gnentries = gnentries; - args.gmapdata = gmapdata; + args.gmapdata = gmapdata; if (mount(MOUNT_UMAP, argv[1], mntflags, &args)) { if (errno == EOPNOTSUPP) @@ -241,7 +253,7 @@ exit(0); } -void +static void usage() { (void)fprintf(stderr, diff -ruN --exclude=CVS ../src.old/sbin/mount_union/mount_union.c ./sbin/mount_union/mount_union.c --- ../src.old/sbin/mount_union/mount_union.c Sat Feb 16 16:27:36 2002 +++ ./sbin/mount_union/mount_union.c Tue Dec 10 19:38:12 2002 @@ -62,20 +62,33 @@ #include #include #include +#include #include "mntopts.h" -const struct mntopt mopts[] = { +static const struct mntopt mopts[] = { MOPT_STDOPTS, { NULL } }; -int subdir(const char *, const char *); -void usage(void); +int main __P((int, char *[])); +int mount_union __P((int argc, char **argv)); +static int subdir __P((const char *, const char *)); +static void usage __P((void)); +#ifndef MOUNT_NOMAIN int main(argc, argv) int argc; + char **argv; +{ + return mount_union(argc, argv); +} +#endif + +int +mount_union(argc, argv) + int argc; char *argv[]; { struct union_args args; @@ -91,7 +104,7 @@ args.mntflags |= UNMNT_BELOW; break; case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case 'r': args.mntflags &= ~UNMNT_OPMASK; @@ -127,7 +140,7 @@ exit(0); } -int +static int subdir(p, dir) const char *p; const char *dir; @@ -144,7 +157,7 @@ return (0); } -void +static void usage() { (void)fprintf(stderr, diff -ruN --exclude=CVS ../src.old/sbin/mount_xfs/mount_xfs.c ./sbin/mount_xfs/mount_xfs.c --- ../src.old/sbin/mount_xfs/mount_xfs.c Sat Jan 22 15:25:02 2000 +++ ./sbin/mount_xfs/mount_xfs.c Tue Dec 10 19:38:13 2002 @@ -77,7 +77,7 @@ while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); break; case '?': default: diff -ruN --exclude=CVS ../src.old/sbin/newfs/newfs.c ./sbin/newfs/newfs.c --- ../src.old/sbin/newfs/newfs.c Sun May 26 05:24:35 2002 +++ ./sbin/newfs/newfs.c Wed Dec 11 00:24:14 2002 @@ -292,7 +292,7 @@ break; case 'o': if (mfs) - getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, 0); else { if (strcmp(optarg, "space") == 0) reqopt = opt = FS_OPTSPACE; diff -ruN --exclude=CVS ../src.old/usr.bin/fstat/fstat.c ./usr.bin/fstat/fstat.c --- ../src.old/usr.bin/fstat/fstat.c Sat Aug 3 20:48:34 2002 +++ ./usr.bin/fstat/fstat.c Tue Dec 10 19:38:13 2002 @@ -59,8 +59,8 @@ #include #include #include -#include #define _KERNEL +#include #include #include #include