diff options
author | Colin Walters <walters@verbum.org> | 2014-06-03 17:38:00 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2014-06-03 17:38:00 -0400 |
commit | cb43d2942f99bb9200b212e0b76397ba66ab70ee (patch) | |
tree | 15a0a671075a190399d27d5bfcb72efe207e5c76 | |
parent | f22fa92aef0cf7334d09addacfdfc70c9f10e075 (diff) | |
download | ostree-cb43d2942f99bb9200b212e0b76397ba66ab70ee.tar.gz |
ostree-remount: Check for / being *mounted* read-only, not necessarily writable
The previous S_IMMUTABLE commit broke ostree-remount; / is now not
actually writable. All we really wanted to know though was whether it
was *mounted* writable, so check that via statvfs() which is cleaner
anyways (i.e. not via access() which kernel people hate).
https://bugzilla.gnome.org/show_bug.cgi?id=728006
-rw-r--r-- | src/switchroot/ostree-remount.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 <stdint.h> #include <sys/param.h> #include <sys/mount.h> +#include <sys/statvfs.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> @@ -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. |