fix a goof in my previous code, that i thought of while reading pr 749.

add a -A flag, which does the same thing as '-a', but doesn't check for
remounts.
This commit is contained in:
cgd 1995-07-12 06:05:04 +00:00
parent f72d54fa88
commit f03626292f

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount.c,v 1.21 1995/07/12 03:45:14 cgd Exp $ */ /* $NetBSD: mount.c,v 1.22 1995/07/12 06:05:04 cgd Exp $ */
/* /*
* Copyright (c) 1980, 1989, 1993, 1994 * Copyright (c) 1980, 1989, 1993, 1994
@ -43,7 +43,7 @@ static char copyright[] =
#if 0 #if 0
static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94"; static char sccsid[] = "@(#)mount.c 8.19 (Berkeley) 4/19/94";
#else #else
static char rcsid[] = "$NetBSD: mount.c,v 1.21 1995/07/12 03:45:14 cgd Exp $"; static char rcsid[] = "$NetBSD: mount.c,v 1.22 1995/07/12 06:05:04 cgd Exp $";
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -73,7 +73,7 @@ int hasopt __P((const char *, const char *));
void maketypelist __P((char *)); void maketypelist __P((char *));
void mangle __P((char *, int *, const char **)); void mangle __P((char *, int *, const char **));
int mountfs __P((const char *, const char *, const char *, int mountfs __P((const char *, const char *, const char *,
int, const char *, const char *)); int, const char *, const char *, int));
void prmount __P((struct statfs *)); void prmount __P((struct statfs *));
void usage __P((void)); void usage __P((void));
@ -105,14 +105,17 @@ main(argc, argv)
struct statfs *mntbuf; struct statfs *mntbuf;
FILE *mountdfp; FILE *mountdfp;
pid_t pid; pid_t pid;
int all, ch, i, init_flags, mntsize, rval; int all, ch, forceall, i, init_flags, mntsize, rval;
char *options; char *options;
all = init_flags = 0; all = forceall = init_flags = 0;
options = NULL; options = NULL;
vfstype = "ufs"; vfstype = "ufs";
while ((ch = getopt(argc, argv, "adfo:rwt:uv")) != EOF) while ((ch = getopt(argc, argv, "Aadfo:rwt:uv")) != EOF)
switch (ch) { switch (ch) {
case 'A':
all = forceall = 1;
break;
case 'a': case 'a':
all = 1; all = 1;
break; break;
@ -169,7 +172,7 @@ main(argc, argv)
continue; continue;
if (mountfs(fs->fs_vfstype, fs->fs_spec, if (mountfs(fs->fs_vfstype, fs->fs_spec,
fs->fs_file, init_flags, options, fs->fs_file, init_flags, options,
fs->fs_mntops)) fs->fs_mntops, !forceall))
rval = 1; rval = 1;
} }
else { else {
@ -209,7 +212,7 @@ main(argc, argv)
mntonname = fs->fs_file; mntonname = fs->fs_file;
} }
rval = mountfs(fs->fs_vfstype, fs->fs_spec, rval = mountfs(fs->fs_vfstype, fs->fs_spec,
mntonname, init_flags, options, fs->fs_mntops); mntonname, init_flags, options, fs->fs_mntops, 0);
break; break;
case 2: case 2:
/* /*
@ -220,7 +223,7 @@ main(argc, argv)
if (typelist == NULL && strpbrk(argv[0], ":@") != NULL) if (typelist == NULL && strpbrk(argv[0], ":@") != NULL)
vfstype = "nfs"; vfstype = "nfs";
rval = mountfs(vfstype, rval = mountfs(vfstype,
argv[0], argv[1], init_flags, options, NULL); argv[0], argv[1], init_flags, options, NULL, 0);
break; break;
default: default:
usage(); usage();
@ -268,9 +271,9 @@ hasopt(mntopts, option)
} }
int int
mountfs(vfstype, spec, name, flags, options, mntopts) mountfs(vfstype, spec, name, flags, options, mntopts, skipmounted)
const char *vfstype, *spec, *name, *options, *mntopts; const char *vfstype, *spec, *name, *options, *mntopts;
int flags; int flags, skipmounted;
{ {
/* List of directories containing mount_xxx subcommands. */ /* List of directories containing mount_xxx subcommands. */
static const char *edirs[] = { static const char *edirs[] = {
@ -305,7 +308,7 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
if (strcmp(name, "/") == 0) if (strcmp(name, "/") == 0)
flags |= MNT_UPDATE; flags |= MNT_UPDATE;
else { else if (skipmounted) {
if (statfs(name, &sf) < 0) { if (statfs(name, &sf) < 0) {
warn("statfs %s", name); warn("statfs %s", name);
return (1); return (1);