[ostree] ostree-remount: Check for / being *mounted* read-only, not necessarily writable



commit cb43d2942f99bb9200b212e0b76397ba66ab70ee
Author: Colin Walters <walters verbum org>
Date:   Tue Jun 3 17:38:00 2014 -0400

    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 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c
index 6dbeecc..84d9359 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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]