vfslist.c revision 23412
179543Sru/* 2151497Sru * Copyright (c) 1995 318099Spst * The Regents of the University of California. All rights reserved. 418099Spst * 518099Spst * Redistribution and use in source and binary forms, with or without 618099Spst * modification, are permitted provided that the following conditions 718099Spst * are met: 818099Spst * 1. Redistributions of source code must retain the above copyright 918099Spst * notice, this list of conditions and the following disclaimer. 1018099Spst * 2. Redistributions in binary form must reproduce the above copyright 1118099Spst * notice, this list of conditions and the following disclaimer in the 1218099Spst * documentation and/or other materials provided with the distribution. 1318099Spst * 3. All advertising materials mentioning features or use of this software 1418099Spst * must display the following acknowledgement: 1518099Spst * This product includes software developed by the University of 1618099Spst * California, Berkeley and its contributors. 1718099Spst * 4. Neither the name of the University nor the names of its contributors 1818099Spst * may be used to endorse or promote products derived from this software 19104862Sru * without specific prior written permission. 20151497Sru * 21151497Sru * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22151497Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2318099Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24151497Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25151497Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26151497Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2718099Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28104862Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2918099Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3018099Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3118099Spst * SUCH DAMAGE. 32151497Sru */ 33151497Sru 3418099Spst#ifndef lint 35104862Srustatic char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95"; 36104862Sru#endif /* not lint */ 3718099Spst 38104862Sru#include <stdlib.h> 39104862Sru#include <string.h> 4018099Spst#include <unistd.h> 4118099Spst 42104862Sruint checkvfsname __P((const char *, const char **)); 43104862Sruconst char **makevfslist __P((char *)); 4418099Spststatic int skipvfs; 4518099Spst 4618099Spstint 47104862Srucheckvfsname(vfsname, vfslist) 4818099Spst const char *vfsname; 4918099Spst const char **vfslist; 5018099Spst{ 51151497Sru 52151497Sru if (vfslist == NULL) 53104862Sru return (0); 5418099Spst while (*vfslist != NULL) { 5518099Spst if (strcmp(vfsname, *vfslist) == 0) 5618099Spst return (skipvfs); 5718099Spst ++vfslist; 5818099Spst } 5918099Spst return (!skipvfs); 6018099Spst} 61104862Sru 6218099Spstconst char ** 63104862Srumakevfslist(fslist) 6418099Spst char *fslist; 65104862Sru{ 66104862Sru const char **av; 6718099Spst int i; 68104862Sru char *nextcp; 69104862Sru 70104862Sru if (fslist == NULL) 71104862Sru return (NULL); 72104862Sru if (fslist[0] == 'n' && fslist[1] == 'o') { 7318099Spst fslist += 2; 74104862Sru skipvfs = 1; 75104862Sru } 76104862Sru for (i = 0, nextcp = fslist; *nextcp; nextcp++) 77104862Sru if (*nextcp == ',') 78104862Sru i++; 7918099Spst if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) { 80104862Sru warn(NULL); 81104862Sru return (NULL); 82104862Sru } 83104862Sru nextcp = fslist; 84104862Sru i = 0; 85104862Sru av[i++] = nextcp; 86104862Sru while ((nextcp = strchr(nextcp, ',')) != NULL) { 87104862Sru *nextcp++ = '\0'; 88104862Sru av[i++] = nextcp; 89104862Sru } 90104862Sru av[i++] = NULL; 91104862Sru return (av); 92104862Sru} 93104862Sru