1fba1c154SSteve Price /*-
28a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni *
492e2d9beSBruce Evans * Copyright (c) 1995
592e2d9beSBruce Evans * The Regents of the University of California. All rights reserved.
692e2d9beSBruce Evans *
792e2d9beSBruce Evans * Redistribution and use in source and binary forms, with or without
892e2d9beSBruce Evans * modification, are permitted provided that the following conditions
992e2d9beSBruce Evans * are met:
1092e2d9beSBruce Evans * 1. Redistributions of source code must retain the above copyright
1192e2d9beSBruce Evans * notice, this list of conditions and the following disclaimer.
1292e2d9beSBruce Evans * 2. Redistributions in binary form must reproduce the above copyright
1392e2d9beSBruce Evans * notice, this list of conditions and the following disclaimer in the
1492e2d9beSBruce Evans * documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors
1692e2d9beSBruce Evans * may be used to endorse or promote products derived from this software
1792e2d9beSBruce Evans * without specific prior written permission.
1892e2d9beSBruce Evans *
1992e2d9beSBruce Evans * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2092e2d9beSBruce Evans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2192e2d9beSBruce Evans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2292e2d9beSBruce Evans * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2392e2d9beSBruce Evans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2492e2d9beSBruce Evans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2592e2d9beSBruce Evans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2692e2d9beSBruce Evans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2792e2d9beSBruce Evans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2892e2d9beSBruce Evans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2992e2d9beSBruce Evans * SUCH DAMAGE.
3092e2d9beSBruce Evans */
3192e2d9beSBruce Evans
32fba1c154SSteve Price #include <err.h>
3392e2d9beSBruce Evans #include <stdlib.h>
3492e2d9beSBruce Evans #include <string.h>
3592e2d9beSBruce Evans
36fba1c154SSteve Price #include "extern.h"
37fba1c154SSteve Price
3892e2d9beSBruce Evans static int skipvfs;
3992e2d9beSBruce Evans
4092e2d9beSBruce Evans int
checkvfsname(const char * vfsname,const char ** vfslist)4110bc3a7fSEd Schouten checkvfsname(const char *vfsname, const char **vfslist)
4292e2d9beSBruce Evans {
4392e2d9beSBruce Evans
4492e2d9beSBruce Evans if (vfslist == NULL)
4592e2d9beSBruce Evans return (0);
4692e2d9beSBruce Evans while (*vfslist != NULL) {
4792e2d9beSBruce Evans if (strcmp(vfsname, *vfslist) == 0)
4892e2d9beSBruce Evans return (skipvfs);
4992e2d9beSBruce Evans ++vfslist;
5092e2d9beSBruce Evans }
5192e2d9beSBruce Evans return (!skipvfs);
5292e2d9beSBruce Evans }
5392e2d9beSBruce Evans
5492e2d9beSBruce Evans const char **
makevfslist(char * fslist)5510bc3a7fSEd Schouten makevfslist(char *fslist)
5692e2d9beSBruce Evans {
5792e2d9beSBruce Evans const char **av;
5892e2d9beSBruce Evans int i;
5992e2d9beSBruce Evans char *nextcp;
6092e2d9beSBruce Evans
6192e2d9beSBruce Evans if (fslist == NULL)
6292e2d9beSBruce Evans return (NULL);
63*ac413189SStefan Eßer skipvfs = 0;
6492e2d9beSBruce Evans if (fslist[0] == 'n' && fslist[1] == 'o') {
6592e2d9beSBruce Evans fslist += 2;
6692e2d9beSBruce Evans skipvfs = 1;
6792e2d9beSBruce Evans }
6892e2d9beSBruce Evans for (i = 0, nextcp = fslist; *nextcp; nextcp++)
6992e2d9beSBruce Evans if (*nextcp == ',')
7092e2d9beSBruce Evans i++;
7192e2d9beSBruce Evans if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
72bcb1d846SPhilippe Charnier warnx("malloc failed");
7392e2d9beSBruce Evans return (NULL);
7492e2d9beSBruce Evans }
7592e2d9beSBruce Evans nextcp = fslist;
7692e2d9beSBruce Evans i = 0;
7792e2d9beSBruce Evans av[i++] = nextcp;
7892e2d9beSBruce Evans while ((nextcp = strchr(nextcp, ',')) != NULL) {
7992e2d9beSBruce Evans *nextcp++ = '\0';
8092e2d9beSBruce Evans av[i++] = nextcp;
8192e2d9beSBruce Evans }
8292e2d9beSBruce Evans av[i++] = NULL;
8392e2d9beSBruce Evans return (av);
8492e2d9beSBruce Evans }
85