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 0x%08x %5d %s\n"
21 #define HDRFMT "%-32.32s %10s %5.5s %s\n"
22 #define DASHES "-------------------------------- " \
23 "---------- ----- ---------------\n"
25 static struct flaglist {
27 const char str[32]; /* must be longer than the longest one. */
29 { .flag = VFCF_STATIC, .str = "static", },
30 { .flag = VFCF_NETWORK, .str = "network", },
31 { .flag = VFCF_READONLY, .str = "read-only", },
32 { .flag = VFCF_SYNTHETIC, .str = "synthetic", },
33 { .flag = VFCF_LOOPBACK, .str = "loopback", },
34 { .flag = VFCF_UNICODE, .str = "unicode", },
35 { .flag = VFCF_JAIL, .str = "jail", },
36 { .flag = VFCF_DELEGADMIN, .str = "delegated-administration", },
39 static const char *fmt_flags(int);
42 main(int argc, char **argv)
45 struct xvfsconf vfc, *xvfsp;
49 printf(HDRFMT, "Filesystem", "Num", "Refs", "Flags");
50 fputs(DASHES, stdout);
53 for(; argc; argc--, argv++) {
54 if (getvfsbyname(*argv, &vfc) == 0) {
55 printf(FMT, vfc.vfc_name, vfc.vfc_typenum, vfc.vfc_refcount,
56 fmt_flags(vfc.vfc_flags));
58 warnx("VFS %s unknown or not loaded", *argv);
63 if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0)
64 err(1, "sysctl(vfs.conflist)");
65 xvfsp = malloc(buflen);
67 errx(1, "malloc failed");
68 if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0)
69 err(1, "sysctl(vfs.conflist)");
70 cnt = buflen / sizeof(struct xvfsconf);
72 for (i = 0; i < cnt; i++) {
73 printf(FMT, xvfsp[i].vfc_name, xvfsp[i].vfc_typenum,
74 xvfsp[i].vfc_refcount, fmt_flags(xvfsp[i].vfc_flags));
85 static char buf[sizeof(struct flaglist) * sizeof(fl)];
89 for (i = 0; i < (int)nitems(fl); i++)
90 if (flags & fl[i].flag) {
91 strlcat(buf, fl[i].str, sizeof(buf));
92 strlcat(buf, ", ", sizeof(buf));
95 buf[strlen(buf) - 2] = '\0';