vfslist.c revision 28671
128671Ssteve/*- 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 3528671Ssteve#if 0 3623412Sbdestatic char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; 3728671Ssteve#else 3828671Sstevestatic const char rcsid[] = 3928671Ssteve "$Id$"; 4028671Ssteve#endif 4123412Sbde#endif /* not lint */ 4223412Sbde 4328671Ssteve#include <err.h> 4423412Sbde#include <stdlib.h> 4523412Sbde#include <string.h> 4623412Sbde#include <unistd.h> 4723412Sbde 4828671Ssteve#include "extern.h" 4928671Ssteve 5023412Sbdestatic int skipvfs; 5123412Sbde 5223412Sbdeint 5323412Sbdecheckvfsname(vfsname, vfslist) 5423412Sbde const char *vfsname; 5523412Sbde const char **vfslist; 5623412Sbde{ 5723412Sbde 5823412Sbde if (vfslist == NULL) 5923412Sbde return (0); 6023412Sbde while (*vfslist != NULL) { 6123412Sbde if (strcmp(vfsname, *vfslist) == 0) 6223412Sbde return (skipvfs); 6323412Sbde ++vfslist; 6423412Sbde } 6523412Sbde return (!skipvfs); 6623412Sbde} 6723412Sbde 6823412Sbdeconst char ** 6923412Sbdemakevfslist(fslist) 7023412Sbde char *fslist; 7123412Sbde{ 7223412Sbde const char **av; 7323412Sbde int i; 7423412Sbde char *nextcp; 7523412Sbde 7623412Sbde if (fslist == NULL) 7723412Sbde return (NULL); 7823412Sbde if (fslist[0] == 'n' && fslist[1] == 'o') { 7923412Sbde fslist += 2; 8023412Sbde skipvfs = 1; 8123412Sbde } 8223412Sbde for (i = 0, nextcp = fslist; *nextcp; nextcp++) 8323412Sbde if (*nextcp == ',') 8423412Sbde i++; 8523412Sbde if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { 8623412Sbde warn(NULL); 8723412Sbde return (NULL); 8823412Sbde } 8923412Sbde nextcp = fslist; 9023412Sbde i = 0; 9123412Sbde av[i++] = nextcp; 9223412Sbde while ((nextcp = strchr(nextcp, ',')) != NULL) { 9323412Sbde *nextcp++ = '\0'; 9423412Sbde av[i++] = nextcp; 9523412Sbde } 9623412Sbde av[i++] = NULL; 9723412Sbde return (av); 9823412Sbde} 99