diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c index 6dbeecc0..84d9359c 100644 --- a/src/switchroot/ostree-remount.c +++ b/src/switchroot/ostree-remount.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,15 @@ main(int argc, char *argv[]) const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", NULL }; struct stat stbuf; int i; + struct statvfs stvfsbuf; - if (access ("/", W_OK) == -1) + if (statvfs ("/", &stvfsbuf) == -1) + { + perror ("statvfs(/): "); + exit (1); + } + + if (stvfsbuf.f_flag & ST_RDONLY) { /* If / isn't writable, don't do any remounts; we don't want * to clear the readonly flag in that case.