1 /* 2 * Copyright (c) 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)getvfsbyname.c 8.1 (Berkeley) 04/03/95"; 10 #endif /* not lint */ 11 12 #include <sys/param.h> 13 #include <sys/mount.h> 14 #include <sys/sysctl.h> 15 #include <errno.h> 16 #include <kvm.h> 17 18 int getvfsbyname __P((const char *, struct vfsconf *)); 19 20 /* 21 * Given a filesystem name, determine if it is resident in the kernel, 22 * and if it is resident, return its vfsconf structure. 23 */ 24 getvfsbyname(fsname, vfcp) 25 const char *fsname; 26 struct vfsconf *vfcp; 27 { 28 int name[4], maxtypenum, cnt; 29 size_t buflen; 30 31 name[0] = CTL_VFS; 32 name[1] = VFS_GENERIC; 33 name[2] = VFS_MAXTYPENUM; 34 buflen = 4; 35 if (sysctl(name, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0) 36 return (-1); 37 name[2] = VFS_CONF; 38 buflen = sizeof *vfcp; 39 for (cnt = 0; cnt < maxtypenum; cnt++) { 40 name[3] = cnt; 41 if (sysctl(name, 4, vfcp, &buflen, (void *)0, (size_t)0) < 0) { 42 if (errno != EOPNOTSUPP) 43 return (-1); 44 continue; 45 } 46 if (!strcmp(fsname, vfcp->vfc_name)) 47 return (0); 48 } 49 errno = ENOENT; 50 return (-1); 51 } 52