1#include <sys/statvfs.h>
2#include <stdio.h>
3#include <stdlib.h>
4
5int main(int argc, char ** argv) {
6 struct statvfs stat;
7 if (argc != 2) {
8 fprintf(stderr, "Usage: %s PATH", argv[0]);
9 exit(2);
10 }
11 if (statvfs(argv[1], &stat) != 0) {
12 perror("statvfs");
13 exit(3);
14 }
15 if (stat.f_flag & ST_RDONLY)
16 exit(0);
17 else
18 exit(1);
19}
20