xref: /freebsd/sbin/mount/vfslist.c (revision fbbd9655e5107c68e4e0146ff22b73d7350475bc)
1fba1c154SSteve Price /*-
292e2d9beSBruce Evans  * Copyright (c) 1995
392e2d9beSBruce Evans  *	The Regents of the University of California.  All rights reserved.
492e2d9beSBruce Evans  *
592e2d9beSBruce Evans  * Redistribution and use in source and binary forms, with or without
692e2d9beSBruce Evans  * modification, are permitted provided that the following conditions
792e2d9beSBruce Evans  * are met:
892e2d9beSBruce Evans  * 1. Redistributions of source code must retain the above copyright
992e2d9beSBruce Evans  *    notice, this list of conditions and the following disclaimer.
1092e2d9beSBruce Evans  * 2. Redistributions in binary form must reproduce the above copyright
1192e2d9beSBruce Evans  *    notice, this list of conditions and the following disclaimer in the
1292e2d9beSBruce Evans  *    documentation and/or other materials provided with the distribution.
13*fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
1492e2d9beSBruce Evans  *    may be used to endorse or promote products derived from this software
1592e2d9beSBruce Evans  *    without specific prior written permission.
1692e2d9beSBruce Evans  *
1792e2d9beSBruce Evans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1892e2d9beSBruce Evans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1992e2d9beSBruce Evans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2092e2d9beSBruce Evans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2192e2d9beSBruce Evans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2292e2d9beSBruce Evans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2392e2d9beSBruce Evans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2492e2d9beSBruce Evans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2592e2d9beSBruce Evans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2692e2d9beSBruce Evans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2792e2d9beSBruce Evans  * SUCH DAMAGE.
2892e2d9beSBruce Evans  */
2992e2d9beSBruce Evans 
3092e2d9beSBruce Evans #ifndef lint
31fba1c154SSteve Price #if 0
3292e2d9beSBruce Evans static char sccsid[] = "@(#)vfslist.c	8.1 (Berkeley) 5/8/95";
33bcb1d846SPhilippe Charnier #endif
3492e2d9beSBruce Evans #endif /* not lint */
35c69284caSDavid E. O'Brien #include <sys/cdefs.h>
36c69284caSDavid E. O'Brien __FBSDID("$FreeBSD$");
3792e2d9beSBruce Evans 
38fba1c154SSteve Price #include <err.h>
3992e2d9beSBruce Evans #include <stdlib.h>
4092e2d9beSBruce Evans #include <string.h>
4192e2d9beSBruce Evans 
42fba1c154SSteve Price #include "extern.h"
43fba1c154SSteve Price 
4492e2d9beSBruce Evans static int	  skipvfs;
4592e2d9beSBruce Evans 
4692e2d9beSBruce Evans int
4710bc3a7fSEd Schouten checkvfsname(const char *vfsname, const char **vfslist)
4892e2d9beSBruce Evans {
4992e2d9beSBruce Evans 
5092e2d9beSBruce Evans 	if (vfslist == NULL)
5192e2d9beSBruce Evans 		return (0);
5292e2d9beSBruce Evans 	while (*vfslist != NULL) {
5392e2d9beSBruce Evans 		if (strcmp(vfsname, *vfslist) == 0)
5492e2d9beSBruce Evans 			return (skipvfs);
5592e2d9beSBruce Evans 		++vfslist;
5692e2d9beSBruce Evans 	}
5792e2d9beSBruce Evans 	return (!skipvfs);
5892e2d9beSBruce Evans }
5992e2d9beSBruce Evans 
6092e2d9beSBruce Evans const char **
6110bc3a7fSEd Schouten makevfslist(char *fslist)
6292e2d9beSBruce Evans {
6392e2d9beSBruce Evans 	const char **av;
6492e2d9beSBruce Evans 	int i;
6592e2d9beSBruce Evans 	char *nextcp;
6692e2d9beSBruce Evans 
6792e2d9beSBruce Evans 	if (fslist == NULL)
6892e2d9beSBruce Evans 		return (NULL);
6992e2d9beSBruce Evans 	if (fslist[0] == 'n' && fslist[1] == 'o') {
7092e2d9beSBruce Evans 		fslist += 2;
7192e2d9beSBruce Evans 		skipvfs = 1;
7292e2d9beSBruce Evans 	}
7392e2d9beSBruce Evans 	for (i = 0, nextcp = fslist; *nextcp; nextcp++)
7492e2d9beSBruce Evans 		if (*nextcp == ',')
7592e2d9beSBruce Evans 			i++;
7692e2d9beSBruce Evans 	if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
77bcb1d846SPhilippe Charnier 		warnx("malloc failed");
7892e2d9beSBruce Evans 		return (NULL);
7992e2d9beSBruce Evans 	}
8092e2d9beSBruce Evans 	nextcp = fslist;
8192e2d9beSBruce Evans 	i = 0;
8292e2d9beSBruce Evans 	av[i++] = nextcp;
8392e2d9beSBruce Evans 	while ((nextcp = strchr(nextcp, ',')) != NULL) {
8492e2d9beSBruce Evans 		*nextcp++ = '\0';
8592e2d9beSBruce Evans 		av[i++] = nextcp;
8692e2d9beSBruce Evans 	}
8792e2d9beSBruce Evans 	av[i++] = NULL;
8892e2d9beSBruce Evans 	return (av);
8992e2d9beSBruce Evans }
90