From cb43d2942f99bb9200b212e0b76397ba66ab70ee Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 3 Jun 2014 17:38:00 -0400 Subject: [PATCH] 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 --- src/switchroot/ostree-remount.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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.