summary refs log tree commit diff
path: root/nixos/modules/system/boot/readonly-mountpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/system/boot/readonly-mountpoint.c')
-rw-r--r--nixos/modules/system/boot/readonly-mountpoint.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/readonly-mountpoint.c b/nixos/modules/system/boot/readonly-mountpoint.c
new file mode 100644
index 00000000000..27b66687382
--- /dev/null
+++ b/nixos/modules/system/boot/readonly-mountpoint.c
@@ -0,0 +1,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);
+}
+