vfslist.c revision 23412
123412Sbde/* 223412Sbde * Copyright (c) 1995 323412Sbde * The Regents of the University of California. All rights reserved. 423412Sbde * 523412Sbde * Redistribution and use in source and binary forms, with or without 623412Sbde * modification, are permitted provided that the following conditions 723412Sbde * are met: 823412Sbde * 1. Redistributions of source code must retain the above copyright 923412Sbde * notice, this list of conditions and the following disclaimer. 1023412Sbde * 2. Redistributions in binary form must reproduce the above copyright 1123412Sbde * notice, this list of conditions and the following disclaimer in the 1223412Sbde * documentation and/or other materials provided with the distribution. 1323412Sbde * 3. All advertising materials mentioning features or use of this software 1423412Sbde * must display the following acknowledgement: 1523412Sbde * This product includes software developed by the University of 1623412Sbde * California, Berkeley and its contributors. 1723412Sbde * 4. Neither the name of the University nor the names of its contributors 1823412Sbde * may be used to endorse or promote products derived from this software 1923412Sbde * without specific prior written permission. 2023412Sbde * 2123412Sbde * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2223412Sbde * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2323412Sbde * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2423412Sbde * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2523412Sbde * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2623412Sbde * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2723412Sbde * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2823412Sbde * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2923412Sbde * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3023412Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3123412Sbde * SUCH DAMAGE. 3223412Sbde */ 3323412Sbde 3423412Sbde#ifndef lint 3523412Sbdestatic char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; 3623412Sbde#endif /* not lint */ 3723412Sbde 3823412Sbde#include <stdlib.h> 3923412Sbde#include <string.h> 4023412Sbde#include <unistd.h> 4123412Sbde 4223412Sbdeint checkvfsname __P((const char *, const char **)); 4323412Sbdeconst char **makevfslist __P((char *)); 4423412Sbdestatic int skipvfs; 4523412Sbde 4623412Sbdeint 4723412Sbdecheckvfsname(vfsname, vfslist) 4823412Sbde const char *vfsname; 4923412Sbde const char **vfslist; 5023412Sbde{ 5123412Sbde 5223412Sbde if (vfslist == NULL) 5323412Sbde return (0); 5423412Sbde while (*vfslist != NULL) { 5523412Sbde if (strcmp(vfsname, *vfslist) == 0) 5623412Sbde return (skipvfs); 5723412Sbde ++vfslist; 5823412Sbde } 5923412Sbde return (!skipvfs); 6023412Sbde} 6123412Sbde 6223412Sbdeconst char ** 6323412Sbdemakevfslist(fslist) 6423412Sbde char *fslist; 6523412Sbde{ 6623412Sbde const char **av; 6723412Sbde int i; 6823412Sbde char *nextcp; 6923412Sbde 7023412Sbde if (fslist == NULL) 7123412Sbde return (NULL); 7223412Sbde if (fslist[0] == 'n' && fslist[1] == 'o') { 7323412Sbde fslist += 2; 7423412Sbde skipvfs = 1; 7523412Sbde } 7623412Sbde for (i = 0, nextcp = fslist; *nextcp; nextcp++) 7723412Sbde if (*nextcp == ',') 7823412Sbde i++; 7923412Sbde if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { 8023412Sbde warn(NULL); 8123412Sbde return (NULL); 8223412Sbde } 8323412Sbde nextcp = fslist; 8423412Sbde i = 0; 8523412Sbde av[i++] = nextcp; 8623412Sbde while ((nextcp = strchr(nextcp, ',')) != NULL) { 8723412Sbde *nextcp++ = '\0'; 8823412Sbde av[i++] = nextcp; 8923412Sbde } 9023412Sbde av[i++] = NULL; 9123412Sbde return (av); 9223412Sbde} 93