]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
binfmt-util: rename binfmt_mounted() -> binfmt_mounted_and_writable()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Jul 2025 06:18:24 +0000 (15:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Jul 2025 05:02:00 +0000 (14:02 +0900)
As it does not only check if binfmt_misc is mounted, but also check if
it is writable.

src/binfmt/binfmt.c
src/shared/binfmt-util.c
src/shared/binfmt-util.h
src/test/test-binfmt-util.c

index 36e1d5d135d4274132a51e2565ec93a4df6a9fa1..88af4e8699e319bc64538f6dae791155c8f8ffcb 100644 (file)
@@ -193,10 +193,10 @@ static int parse_argv(int argc, char *argv[]) {
         return 1;
 }
 
-static int binfmt_mounted_warn(void) {
+static int binfmt_mounted_and_writable_warn(void) {
         int r;
 
-        r = binfmt_mounted();
+        r = binfmt_mounted_and_writable();
         if (r < 0)
                 return log_error_errno(r, "Failed to check if /proc/sys/fs/binfmt_misc is mounted: %m");
         if (r == 0)
@@ -222,7 +222,7 @@ static int run(int argc, char *argv[]) {
                 return disable_binfmt();
 
         if (argc > optind) {
-                r = binfmt_mounted_warn();
+                r = binfmt_mounted_and_writable_warn();
                 if (r <= 0)
                         return r;
 
@@ -239,7 +239,7 @@ static int run(int argc, char *argv[]) {
                 if (arg_cat_flags != CAT_CONFIG_OFF)
                         return cat_config(files);
 
-                r = binfmt_mounted_warn();
+                r = binfmt_mounted_and_writable_warn();
                 if (r <= 0)
                         return r;
 
index 49d920c2925367269b563a2ea8c0d1a05813c0bb..d5bf96bbdca73c7ce5f5d5614899bd7356f7dab0 100644 (file)
@@ -11,7 +11,7 @@
 #include "missing_magic.h"
 #include "stat-util.h"
 
-int binfmt_mounted(void) {
+int binfmt_mounted_and_writable(void) {
         _cleanup_close_ int fd = -EBADF;
         int r;
 
@@ -43,7 +43,7 @@ int disable_binfmt(void) {
          * We are a bit careful here, since binfmt_misc might still be an autofs which we don't want to
          * trigger. */
 
-        r = binfmt_mounted();
+        r = binfmt_mounted_and_writable();
         if (r < 0)
                 return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m");
         if (r == 0) {
index 13f4548b7ce8c4283502e61fd52d18ca74675284..f578854011b9d851e3c195e5b66bf267caee280d 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-int binfmt_mounted(void);
+int binfmt_mounted_and_writable(void);
 int disable_binfmt(void);
index 7027efc519595ce626abaacd4ef11ebf9af4456b..63d777e162470848ca07f880efe4640cf61960b7 100644 (file)
@@ -3,8 +3,8 @@
 #include "binfmt-util.h"
 #include "tests.h"
 
-TEST(binfmt_mounted) {
-        ASSERT_OK(binfmt_mounted());
+TEST(binfmt_mounted_and_writable) {
+        ASSERT_OK(binfmt_mounted_and_writable());
 }
 
 DEFINE_TEST_MAIN(LOG_DEBUG);