nfsd(8) wasn't dealing with the death of a child correctly.
[unix-history] / usr / src / sbin / mount / getmntopts.c
CommitLineData
f6019b74
KB
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#ifndef lint
8d5eb8c2 9static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) %G%";
f6019b74
KB
10#endif /* not lint */
11
12#include <sys/param.h>
13#include <sys/mount.h>
14
15#include <err.h>
16#include <errno.h>
17#include <fstab.h>
18#include <stdlib.h>
19#include <string.h>
20
21#include "mntopts.h"
22
8d5eb8c2
KM
23int getmnt_silent = 0;
24
f6019b74 25void
8d5eb8c2 26getmntopts(options, m0, flagp, altflagp)
f6019b74
KB
27 const char *options;
28 const struct mntopt *m0;
29 int *flagp;
8d5eb8c2 30 int *altflagp;
f6019b74
KB
31{
32 const struct mntopt *m;
33 int negative;
e9945329 34 char *opt, *optbuf, *p;
8d5eb8c2 35 int *thisflagp;
f6019b74
KB
36
37 /* Copy option string, since it is about to be torn asunder... */
38 if ((optbuf = strdup(options)) == NULL)
39 err(1, NULL);
40
41 for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
42 /* Check for "no" prefix. */
43 if (opt[0] == 'n' && opt[1] == 'o') {
44 negative = 1;
45 opt += 2;
46 } else
47 negative = 0;
48
e9945329
KM
49 /*
50 * for options with assignments in them (ie. quotas)
51 * ignore the assignment as it's handled elsewhere
52 */
53 p = strchr(opt, '=');
54 if (p)
55 *p = '\0';
56
f6019b74
KB
57 /* Scan option table. */
58 for (m = m0; m->m_option != NULL; ++m)
59 if (strcasecmp(opt, m->m_option) == 0)
60 break;
61
62 /* Save flag, or fail if option is not recognised. */
63 if (m->m_option) {
8d5eb8c2 64 thisflagp = m->m_altloc ? altflagp : flagp;
f6019b74 65 if (negative == m->m_inverse)
8d5eb8c2 66 *thisflagp |= m->m_flag;
f6019b74 67 else
8d5eb8c2
KM
68 *thisflagp &= ~m->m_flag;
69 } else if (!getmnt_silent) {
f6019b74 70 errx(1, "-o %s: option not supported", opt);
8d5eb8c2 71 }
f6019b74
KB
72 }
73
74 free(optbuf);
75}