2 * lsvfs - list loaded VFSes
3 * Garrett A. Wollman, September 1994
4 * This file is in the public domain.
11 #include <sys/param.h>
12 #include <sys/mount.h>
13 #include <sys/sysctl.h>
20 #define FMT "%-32.32s %5d %s\n"
21 #define HDRFMT "%-32.32s %5.5s %s\n"
22 #define DASHES "-------------------------------- ----- ---------------\n"
24 static const char *fmt_flags(int);
27 main(int argc, char **argv)
30 struct xvfsconf vfc, *xvfsp;
34 printf(HDRFMT, "Filesystem", "Refs", "Flags");
35 fputs(DASHES, stdout);
38 for(; argc; argc--, argv++) {
39 if (getvfsbyname(*argv, &vfc) == 0) {
40 printf(FMT, vfc.vfc_name, vfc.vfc_refcount, fmt_flags(vfc.vfc_flags));
42 warnx("VFS %s unknown or not loaded", *argv);
47 if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0)
48 err(1, "sysctl(vfs.conflist)");
49 xvfsp = malloc(buflen);
51 errx(1, "malloc failed");
52 if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0)
53 err(1, "sysctl(vfs.conflist)");
54 cnt = buflen / sizeof(struct xvfsconf);
56 for (i = 0; i < cnt; i++) {
57 printf(FMT, xvfsp[i].vfc_name, xvfsp[i].vfc_refcount,
58 fmt_flags(xvfsp[i].vfc_flags));
70 * NB: if you add new flags, don't forget to add them here vvvvvv too.
72 static char buf[sizeof
73 "static, network, read-only, synthetic, loopback, unicode, jail"];
78 if(flags & VFCF_STATIC)
79 strlcat(buf, "static, ", sizeof(buf));
80 if(flags & VFCF_NETWORK)
81 strlcat(buf, "network, ", sizeof(buf));
82 if(flags & VFCF_READONLY)
83 strlcat(buf, "read-only, ", sizeof(buf));
84 if(flags & VFCF_SYNTHETIC)
85 strlcat(buf, "synthetic, ", sizeof(buf));
86 if(flags & VFCF_LOOPBACK)
87 strlcat(buf, "loopback, ", sizeof(buf));
88 if(flags & VFCF_UNICODE)
89 strlcat(buf, "unicode, ", sizeof(buf));
91 strlcat(buf, "jail, ", sizeof(buf));
92 if(flags & VFCF_DELEGADMIN)
93 strlcat(buf, "delegated-administration, ", sizeof(buf));
95 if (len > 2 && buf[len - 2] == ',')