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