summary refs log tree commit diff
path: root/nixos/modules/system/boot/readonly-mountpoint.c
blob: 27b666873821a67c6199f34f9525c18e0ee5ef6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <sys/statvfs.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char ** argv) {
	struct statvfs stat;
	if (argc != 2) {
		fprintf(stderr, "Usage: %s PATH", argv[0]);
		exit(2);
	}
	if (statvfs(argv[1], &stat) != 0) {
		perror("statvfs");
		exit(3);
	}
	if (stat.f_flag & ST_RDONLY)
		exit(0);
	else
		exit(1);
}