]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
binfmt-util: also check if binfmt is mounted in read-write
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 Dec 2022 02:32:24 +0000 (11:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Dec 2022 18:36:24 +0000 (03:36 +0900)
src/shared/binfmt-util.c

index e813c3ebcb44321ab67ff384b7be58e4997993d6..51fc245c0190a5b81c392c19b1ce33d207eec636 100644 (file)
@@ -8,6 +8,7 @@
 #include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
+#include "fs-util.h"
 #include "missing_magic.h"
 #include "stat-util.h"
 
@@ -25,7 +26,7 @@ static int binfmt_mounted(void) {
         if (r <= 0)
                 return r;
 
-        return true;
+        return access_fd(fd, W_OK) >= 0;
 }
 
 int disable_binfmt(void) {
@@ -41,7 +42,7 @@ int disable_binfmt(void) {
         if (r < 0)
                 return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m");
         if (r == 0) {
-                log_debug("binfmt_misc is not mounted, not detaching entries.");
+                log_debug("binfmt_misc is not mounted in read-write mode, not detaching entries.");
                 return 0;
         }