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