1 /* 2 * lsvfs - list loaded VFSes 3 * Garrett A. Wollman, September 1994 4 * This file is in the public domain. 5 * 6 */ 7 8 #include <sys/cdefs.h> 9 __FBSDID("$FreeBSD$"); 10 11 #define _NEW_VFSCONF 12 13 #include <sys/param.h> 14 #include <sys/mount.h> 15 16 #include <err.h> 17 #include <stdio.h> 18 #include <string.h> 19 20 #define FMT "%-32.32s %5d %s\n" 21 #define HDRFMT "%-32.32s %5.5s %s\n" 22 #define DASHES "-------------------------------- ----- ---------------\n" 23 24 static const char *fmt_flags(int); 25 26 int 27 main(int argc, char **argv) 28 { 29 int rv = 0; 30 struct vfsconf vfc; 31 struct ovfsconf *ovfcp; 32 argc--, argv++; 33 34 setvfsent(1); 35 36 printf(HDRFMT, "Filesystem", "Refs", "Flags"); 37 fputs(DASHES, stdout); 38 39 if(argc) { 40 for(; argc; argc--, argv++) { 41 if (getvfsbyname(*argv, &vfc) == 0) { 42 printf(FMT, vfc.vfc_name, vfc.vfc_refcount, fmt_flags(vfc.vfc_flags)); 43 } else { 44 warnx("VFS %s unknown or not loaded", *argv); 45 rv++; 46 } 47 } 48 } else { 49 while ((ovfcp = getvfsent()) != NULL) { 50 printf(FMT, ovfcp->vfc_name, ovfcp->vfc_refcount, 51 fmt_flags(ovfcp->vfc_flags)); 52 } 53 } 54 55 endvfsent(); 56 return rv; 57 } 58 59 static const char * 60 fmt_flags(int flags) 61 { 62 /* 63 * NB: if you add new flags, don't forget to add them here vvvvvv too. 64 */ 65 static char buf[sizeof 66 "static, network, read-only, synthetic, loopback, unicode"]; 67 int comma = 0; 68 69 buf[0] = '\0'; 70 71 if(flags & VFCF_STATIC) { 72 if(comma++) strcat(buf, ", "); 73 strcat(buf, "static"); 74 } 75 76 if(flags & VFCF_NETWORK) { 77 if(comma++) strcat(buf, ", "); 78 strcat(buf, "network"); 79 } 80 81 if(flags & VFCF_READONLY) { 82 if(comma++) strcat(buf, ", "); 83 strcat(buf, "read-only"); 84 } 85 86 if(flags & VFCF_SYNTHETIC) { 87 if(comma++) strcat(buf, ", "); 88 strcat(buf, "synthetic"); 89 } 90 91 if(flags & VFCF_LOOPBACK) { 92 if(comma++) strcat(buf, ", "); 93 strcat(buf, "loopback"); 94 } 95 96 if(flags & VFCF_UNICODE) { 97 if(comma++) strcat(buf, ", "); 98 strcat(buf, "unicode"); 99 } 100 101 return buf; 102 } 103