17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*d1a180b0Smaheshvs * Common Development and Distribution License (the "License").
6*d1a180b0Smaheshvs * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*d1a180b0Smaheshvs * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
277c478bd9Sstevel@tonic-gate /* All Rights Reserved */
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
317c478bd9Sstevel@tonic-gate * The Regents of the University of California
327c478bd9Sstevel@tonic-gate * All Rights Reserved
337c478bd9Sstevel@tonic-gate *
347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
367c478bd9Sstevel@tonic-gate * contributors.
377c478bd9Sstevel@tonic-gate */
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate * Turn quota on/off for a filesystem.
437c478bd9Sstevel@tonic-gate */
447c478bd9Sstevel@tonic-gate #include <sys/param.h>
457c478bd9Sstevel@tonic-gate #include <sys/types.h>
467c478bd9Sstevel@tonic-gate #include <sys/stat.h>
477c478bd9Sstevel@tonic-gate #include <sys/mntent.h>
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate #define bcopy(f, t, n) memcpy(t, f, n)
507c478bd9Sstevel@tonic-gate #define bzero(s, n) memset(s, 0, n)
517c478bd9Sstevel@tonic-gate #define bcmp(s, d, n) memcmp(s, d, n)
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate #define index(s, r) strchr(s, r)
547c478bd9Sstevel@tonic-gate #define rindex(s, r) strrchr(s, r)
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate #include <string.h>
577c478bd9Sstevel@tonic-gate #include <stdlib.h>
587c478bd9Sstevel@tonic-gate #include <unistd.h>
597c478bd9Sstevel@tonic-gate #include <sys/file.h>
607c478bd9Sstevel@tonic-gate #include <signal.h>
617c478bd9Sstevel@tonic-gate #include <fcntl.h>
627c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_quota.h>
637c478bd9Sstevel@tonic-gate #include <stdio.h>
647c478bd9Sstevel@tonic-gate #include <sys/mnttab.h>
657c478bd9Sstevel@tonic-gate #include <errno.h>
667c478bd9Sstevel@tonic-gate #include <sys/vfstab.h>
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gate int vflag; /* verbose */
697c478bd9Sstevel@tonic-gate int aflag; /* all file systems */
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate #define QFNAME "quotas"
727c478bd9Sstevel@tonic-gate #define CHUNK 50
737c478bd9Sstevel@tonic-gate char **listbuf;
747c478bd9Sstevel@tonic-gate char *mntopt(), *hasvfsopt(), *hasmntopt();
757c478bd9Sstevel@tonic-gate char *whoami;
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate static void fixmntent();
787c478bd9Sstevel@tonic-gate static void mnterror();
79*d1a180b0Smaheshvs static void usage(char *);
807c478bd9Sstevel@tonic-gate static int oneof();
817c478bd9Sstevel@tonic-gate static int quotaonoff();
82*d1a180b0Smaheshvs static int quotactl(int, char *, uid_t, caddr_t);
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate extern int optind;
857c478bd9Sstevel@tonic-gate extern char *optarg;
867c478bd9Sstevel@tonic-gate
87*d1a180b0Smaheshvs int
main(int argc,char ** argv)88*d1a180b0Smaheshvs main(int argc, char **argv)
897c478bd9Sstevel@tonic-gate {
907c478bd9Sstevel@tonic-gate struct mnttab mntp;
917c478bd9Sstevel@tonic-gate struct vfstab vfsbuf;
927c478bd9Sstevel@tonic-gate char **listp;
937c478bd9Sstevel@tonic-gate int listcnt;
947c478bd9Sstevel@tonic-gate FILE *mtab, *vfstab, *tmp;
957c478bd9Sstevel@tonic-gate int offmode = 0;
967c478bd9Sstevel@tonic-gate int listmax = 0;
977c478bd9Sstevel@tonic-gate int errs = 0;
987c478bd9Sstevel@tonic-gate char *tmpname = "/etc/mnttab.temp";
997c478bd9Sstevel@tonic-gate int status;
1007c478bd9Sstevel@tonic-gate int opt;
1017c478bd9Sstevel@tonic-gate mode_t oldumask;
1027c478bd9Sstevel@tonic-gate struct stat statbuf;
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate whoami = (char *)rindex(*argv, '/') + 1;
1057c478bd9Sstevel@tonic-gate if (whoami == (char *)1)
1067c478bd9Sstevel@tonic-gate whoami = *argv;
1077c478bd9Sstevel@tonic-gate if (strcmp(whoami, "quotaoff") == 0)
1087c478bd9Sstevel@tonic-gate offmode++;
1097c478bd9Sstevel@tonic-gate else if (strcmp(whoami, "quotaon") != 0) {
1107c478bd9Sstevel@tonic-gate fprintf(stderr, "Name must be quotaon or quotaoff not %s\n",
1117c478bd9Sstevel@tonic-gate whoami);
1127c478bd9Sstevel@tonic-gate exit(31+1);
1137c478bd9Sstevel@tonic-gate }
1147c478bd9Sstevel@tonic-gate if ((listbuf = (char **)malloc(sizeof (char *) * CHUNK)) == NULL) {
1157c478bd9Sstevel@tonic-gate fprintf(stderr, "Can't alloc lisbuf array.");
1167c478bd9Sstevel@tonic-gate exit(31+1);
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate listmax = CHUNK;
1197c478bd9Sstevel@tonic-gate while ((opt = getopt(argc, argv, "avV")) != EOF) {
1207c478bd9Sstevel@tonic-gate switch (opt) {
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gate case 'v':
1237c478bd9Sstevel@tonic-gate vflag++;
1247c478bd9Sstevel@tonic-gate break;
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate case 'a':
1277c478bd9Sstevel@tonic-gate aflag++;
1287c478bd9Sstevel@tonic-gate break;
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate case 'V': /* Print command line */
1317c478bd9Sstevel@tonic-gate {
1327c478bd9Sstevel@tonic-gate char *opt_text;
1337c478bd9Sstevel@tonic-gate int opt_cnt;
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s -F UFS ", whoami);
1367c478bd9Sstevel@tonic-gate for (opt_cnt = 1; opt_cnt < argc; opt_cnt++) {
1377c478bd9Sstevel@tonic-gate opt_text = argv[opt_cnt];
1387c478bd9Sstevel@tonic-gate if (opt_text)
1397c478bd9Sstevel@tonic-gate (void) fprintf(stdout, " %s ",
1407c478bd9Sstevel@tonic-gate opt_text);
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n");
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate break;
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate case '?':
1477c478bd9Sstevel@tonic-gate usage(whoami);
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate if (argc <= optind && !aflag) {
1517c478bd9Sstevel@tonic-gate usage(whoami);
1527c478bd9Sstevel@tonic-gate }
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate * If aflag go through vfstab and make a list of appropriate
1557c478bd9Sstevel@tonic-gate * filesystems.
1567c478bd9Sstevel@tonic-gate */
1577c478bd9Sstevel@tonic-gate if (aflag) {
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate listp = listbuf;
1607c478bd9Sstevel@tonic-gate listcnt = 0;
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate vfstab = fopen(VFSTAB, "r");
1637c478bd9Sstevel@tonic-gate if (vfstab == NULL) {
1647c478bd9Sstevel@tonic-gate fprintf(stderr, "Can't open %s\n", VFSTAB);
1657c478bd9Sstevel@tonic-gate perror(VFSTAB);
1667c478bd9Sstevel@tonic-gate exit(31+1);
1677c478bd9Sstevel@tonic-gate }
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gate while ((status = getvfsent(vfstab, &vfsbuf)) == NULL) {
1707c478bd9Sstevel@tonic-gate if (strcmp(vfsbuf.vfs_fstype, MNTTYPE_UFS) != 0 ||
1717c478bd9Sstevel@tonic-gate (vfsbuf.vfs_mntopts == 0) ||
1727c478bd9Sstevel@tonic-gate hasvfsopt(&vfsbuf, MNTOPT_RO) ||
1737c478bd9Sstevel@tonic-gate (!hasvfsopt(&vfsbuf, MNTOPT_RQ) &&
1747c478bd9Sstevel@tonic-gate !hasvfsopt(&vfsbuf, MNTOPT_QUOTA)))
1757c478bd9Sstevel@tonic-gate continue;
1767c478bd9Sstevel@tonic-gate *listp = malloc(strlen(vfsbuf.vfs_special) + 1);
1777c478bd9Sstevel@tonic-gate strcpy(*listp, vfsbuf.vfs_special);
1787c478bd9Sstevel@tonic-gate listp++;
1797c478bd9Sstevel@tonic-gate listcnt++;
1807c478bd9Sstevel@tonic-gate /* grow listbuf if needed */
1817c478bd9Sstevel@tonic-gate if (listcnt >= listmax) {
1827c478bd9Sstevel@tonic-gate listmax += CHUNK;
1837c478bd9Sstevel@tonic-gate listbuf = (char **)realloc(listbuf,
1847c478bd9Sstevel@tonic-gate sizeof (char *) * listmax);
1857c478bd9Sstevel@tonic-gate if (listbuf == NULL) {
1867c478bd9Sstevel@tonic-gate fprintf(stderr,
1877c478bd9Sstevel@tonic-gate "Can't grow listbuf.\n");
1887c478bd9Sstevel@tonic-gate exit(31+1);
1897c478bd9Sstevel@tonic-gate }
1907c478bd9Sstevel@tonic-gate listp = &listbuf[listcnt];
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate }
1937c478bd9Sstevel@tonic-gate fclose(vfstab);
1947c478bd9Sstevel@tonic-gate *listp = (char *)0;
1957c478bd9Sstevel@tonic-gate listp = listbuf;
1967c478bd9Sstevel@tonic-gate } else {
1977c478bd9Sstevel@tonic-gate listp = &argv[optind];
1987c478bd9Sstevel@tonic-gate listcnt = argc - optind;
1997c478bd9Sstevel@tonic-gate }
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate /*
2027c478bd9Sstevel@tonic-gate * Open real mnttab
2037c478bd9Sstevel@tonic-gate */
2047c478bd9Sstevel@tonic-gate mtab = fopen(MNTTAB, "r");
2057c478bd9Sstevel@tonic-gate if (mtab == NULL) {
2067c478bd9Sstevel@tonic-gate fprintf(stderr, "Can't open %s\n", MNTTAB);
2077c478bd9Sstevel@tonic-gate perror(whoami);
2087c478bd9Sstevel@tonic-gate exit(31+1);
2097c478bd9Sstevel@tonic-gate }
2107c478bd9Sstevel@tonic-gate /* check every entry for validity before we change mnttab */
2117c478bd9Sstevel@tonic-gate while ((status = getmntent(mtab, &mntp)) == 0)
2127c478bd9Sstevel@tonic-gate ;
2137c478bd9Sstevel@tonic-gate if (status > 0)
2147c478bd9Sstevel@tonic-gate mnterror(status);
2157c478bd9Sstevel@tonic-gate rewind(mtab);
2167c478bd9Sstevel@tonic-gate
2177c478bd9Sstevel@tonic-gate signal(SIGHUP, SIG_IGN);
2187c478bd9Sstevel@tonic-gate signal(SIGQUIT, SIG_IGN);
2197c478bd9Sstevel@tonic-gate signal(SIGINT, SIG_IGN);
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate * Loop through mnttab, if a file system gets turned on or off
2237c478bd9Sstevel@tonic-gate * do the quota call.
2247c478bd9Sstevel@tonic-gate */
2257c478bd9Sstevel@tonic-gate while ((status = getmntent(mtab, &mntp)) == NULL) {
2267c478bd9Sstevel@tonic-gate if (strcmp(mntp.mnt_fstype, MNTTYPE_UFS) == 0 &&
2277c478bd9Sstevel@tonic-gate !hasmntopt(&mntp, MNTOPT_RO) &&
2287c478bd9Sstevel@tonic-gate (oneof(mntp.mnt_special, listp, listcnt) ||
2297c478bd9Sstevel@tonic-gate oneof(mntp.mnt_mountp, listp, listcnt))) {
2307c478bd9Sstevel@tonic-gate errs += quotaonoff(&mntp, offmode);
2317c478bd9Sstevel@tonic-gate }
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate fclose(mtab);
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate while (listcnt--) {
2367c478bd9Sstevel@tonic-gate if (*listp) {
2377c478bd9Sstevel@tonic-gate fprintf(stderr, "Cannot do %s\n", *listp);
2387c478bd9Sstevel@tonic-gate errs++;
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate listp++;
2417c478bd9Sstevel@tonic-gate }
2427c478bd9Sstevel@tonic-gate if (errs > 0)
2437c478bd9Sstevel@tonic-gate errs += 31;
244*d1a180b0Smaheshvs return (errs);
2457c478bd9Sstevel@tonic-gate }
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate int
quotaonoff(struct mnttab * mntp,int offmode)248*d1a180b0Smaheshvs quotaonoff(struct mnttab *mntp, int offmode)
2497c478bd9Sstevel@tonic-gate {
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate if (offmode) {
2527c478bd9Sstevel@tonic-gate if (quotactl(Q_QUOTAOFF, mntp->mnt_mountp, (uid_t)0, NULL) < 0)
2537c478bd9Sstevel@tonic-gate goto bad;
2547c478bd9Sstevel@tonic-gate if (vflag)
2557c478bd9Sstevel@tonic-gate printf("%s: quotas turned off\n", mntp->mnt_mountp);
2567c478bd9Sstevel@tonic-gate } else {
2577c478bd9Sstevel@tonic-gate if (quotactl(Q_QUOTAON, mntp->mnt_mountp, (uid_t)0, NULL) <
2587c478bd9Sstevel@tonic-gate 0)
2597c478bd9Sstevel@tonic-gate goto bad;
2607c478bd9Sstevel@tonic-gate if (vflag)
2617c478bd9Sstevel@tonic-gate printf("%s: quotas turned on\n", mntp->mnt_mountp);
2627c478bd9Sstevel@tonic-gate }
2637c478bd9Sstevel@tonic-gate return (0);
2647c478bd9Sstevel@tonic-gate bad:
2657c478bd9Sstevel@tonic-gate fprintf(stderr, "quotactl: ");
2667c478bd9Sstevel@tonic-gate perror(mntp->mnt_special);
2677c478bd9Sstevel@tonic-gate return (1);
2687c478bd9Sstevel@tonic-gate }
2697c478bd9Sstevel@tonic-gate
2707c478bd9Sstevel@tonic-gate int
oneof(char * target,char ** olistp,int on)271*d1a180b0Smaheshvs oneof(char *target, char **olistp, int on)
2727c478bd9Sstevel@tonic-gate {
2737c478bd9Sstevel@tonic-gate int n = on;
2747c478bd9Sstevel@tonic-gate char **listp = olistp;
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gate while (n--) {
2777c478bd9Sstevel@tonic-gate if (*listp && strcmp(target, *listp) == 0) {
2787c478bd9Sstevel@tonic-gate *listp = (char *)0;
2797c478bd9Sstevel@tonic-gate return (1);
2807c478bd9Sstevel@tonic-gate }
2817c478bd9Sstevel@tonic-gate listp++;
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate return (0);
2847c478bd9Sstevel@tonic-gate }
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate void
usage(char * whoami)287*d1a180b0Smaheshvs usage(char *whoami)
2887c478bd9Sstevel@tonic-gate {
2897c478bd9Sstevel@tonic-gate
2907c478bd9Sstevel@tonic-gate fprintf(stderr, "ufs usage:\n");
2917c478bd9Sstevel@tonic-gate fprintf(stderr, "\t%s [-v] -a\n", whoami);
2927c478bd9Sstevel@tonic-gate fprintf(stderr, "\t%s [-v] filesys ...\n", whoami);
2937c478bd9Sstevel@tonic-gate exit(31+1);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gate int
quotactl(int cmd,char * mountpt,uid_t uid,caddr_t addr)298*d1a180b0Smaheshvs quotactl(int cmd, char *mountpt, uid_t uid, caddr_t addr)
2997c478bd9Sstevel@tonic-gate {
3007c478bd9Sstevel@tonic-gate int fd;
3017c478bd9Sstevel@tonic-gate int status;
3027c478bd9Sstevel@tonic-gate struct quotctl quota;
3037c478bd9Sstevel@tonic-gate char qfile[MAXPATHLEN];
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate if (mountpt == NULL || mountpt[0] == '\0') {
3067c478bd9Sstevel@tonic-gate errno = ENOENT;
3077c478bd9Sstevel@tonic-gate return (-1);
3087c478bd9Sstevel@tonic-gate }
3097c478bd9Sstevel@tonic-gate if ((strlcpy(qfile, mountpt, sizeof (qfile)) >= sizeof (qfile)) ||
3107c478bd9Sstevel@tonic-gate (strlcat(qfile, "/" QFNAME, sizeof (qfile)) >= sizeof (qfile))) {
3117c478bd9Sstevel@tonic-gate errno = ENOENT;
3127c478bd9Sstevel@tonic-gate return (-1);
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate if ((fd = open64(qfile, O_RDWR)) < 0) {
3157c478bd9Sstevel@tonic-gate fprintf(stderr, "quotactl: %s ", qfile);
3167c478bd9Sstevel@tonic-gate perror("open");
3177c478bd9Sstevel@tonic-gate exit(31+1);
3187c478bd9Sstevel@tonic-gate }
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate quota.op = cmd;
3217c478bd9Sstevel@tonic-gate quota.uid = uid;
3227c478bd9Sstevel@tonic-gate quota.addr = addr;
3237c478bd9Sstevel@tonic-gate status = ioctl(fd, Q_QUOTACTL, "a);
3247c478bd9Sstevel@tonic-gate close(fd);
3257c478bd9Sstevel@tonic-gate return (status);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate char *
hasvfsopt(struct vfstab * vfs,char * opt)329*d1a180b0Smaheshvs hasvfsopt(struct vfstab *vfs, char *opt)
3307c478bd9Sstevel@tonic-gate {
3317c478bd9Sstevel@tonic-gate char *f, *opts;
3327c478bd9Sstevel@tonic-gate static char *tmpopts;
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate if (tmpopts == 0) {
3357c478bd9Sstevel@tonic-gate tmpopts = (char *)calloc(256, sizeof (char));
3367c478bd9Sstevel@tonic-gate if (tmpopts == 0)
3377c478bd9Sstevel@tonic-gate return (0);
3387c478bd9Sstevel@tonic-gate }
3397c478bd9Sstevel@tonic-gate strcpy(tmpopts, vfs->vfs_mntopts);
3407c478bd9Sstevel@tonic-gate opts = tmpopts;
3417c478bd9Sstevel@tonic-gate f = mntopt(&opts);
3427c478bd9Sstevel@tonic-gate for (; *f; f = mntopt(&opts)) {
3437c478bd9Sstevel@tonic-gate if (strncmp(opt, f, strlen(opt)) == 0)
3447c478bd9Sstevel@tonic-gate return (f - tmpopts + vfs->vfs_mntopts);
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate return (NULL);
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate void
mnterror(int flag)350*d1a180b0Smaheshvs mnterror(int flag)
3517c478bd9Sstevel@tonic-gate {
3527c478bd9Sstevel@tonic-gate switch (flag) {
3537c478bd9Sstevel@tonic-gate case MNT_TOOLONG:
3547c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in mnttab exceeds %d characters\n",
3557c478bd9Sstevel@tonic-gate whoami, MNT_LINE_MAX-2);
3567c478bd9Sstevel@tonic-gate break;
3577c478bd9Sstevel@tonic-gate case MNT_TOOFEW:
3587c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in mnttab has too few entries\n",
3597c478bd9Sstevel@tonic-gate whoami);
3607c478bd9Sstevel@tonic-gate break;
3617c478bd9Sstevel@tonic-gate case MNT_TOOMANY:
3627c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in mnttab has too many entries\n",
3637c478bd9Sstevel@tonic-gate whoami);
3647c478bd9Sstevel@tonic-gate break;
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate exit(1);
3677c478bd9Sstevel@tonic-gate }
368