Handle hostnames with upper-case letters
[webmin.git] / mount / openbsd-mounts-2.c
1 #include <stdio.h>
2 #include <errno.h>
3 #include <sys/param.h>
4 #include <sys/ucred.h>
5 #include <sys/mount.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 char *find_type(int t);
10 char *expand_flags(int f);
11
12 int main(void)
13 {
14 struct statfs *mntlist;
15 int n, i;
16
17 n = getmntinfo(&mntlist, MNT_NOWAIT);
18 if (n < 0) {
19         fprintf(stderr, "getmntinfo failed : %s\n", strerror(errno));
20         exit(1);
21         }
22 for(i=0; i<n; i++) {
23         printf("%s\t%s\t%s\t%s\t%x\n",
24                 mntlist[i].f_mntonname,
25                 mntlist[i].f_mntfromname,
26                 mntlist[i].f_fstypename,
27                 expand_flags(mntlist[i].f_flags),
28                 mntlist[i].f_flags);
29         }
30 return 0;
31 }
32
33 char *expand_flags(int f)
34 {
35 static char buf[1024];
36 buf[0] = 0;
37 if (f & MNT_RDONLY) strcat(buf, "ro,");
38 if (f & MNT_NOEXEC) strcat(buf, "noexec,");
39 if (f & MNT_NOSUID) strcat(buf, "nosuid,");
40 if (f & MNT_NOATIME) strcat(buf, "noatime,");
41 if (f & MNT_NODEV) strcat(buf, "nodev,");
42 if (f & MNT_SYNCHRONOUS) strcat(buf, "sync,");
43 if (f & MNT_ASYNC) strcat(buf, "async,");
44 if (f & MNT_QUOTA) strcat(buf, "quota,");
45 #ifdef MNT_UNION
46 if (f & MNT_UNION) strcat(buf, "union,");
47 #endif
48 if (buf[0] == 0) return "-";
49 buf[strlen(buf)-1] = 0;
50 return buf;
51 }
52