2 #include <sys/statvfs.h>
5 #include "binfmt-util.h"
7 #include "missing_magic.h"
10 int disable_binfmt(void) {
13 /* Flush out all rules. This is important during shutdown to cover for rules using "F", since those
14 * might pin a file and thus block us from unmounting stuff cleanly.
16 * We are a bit careful here, since binfmt_misc might still be an autofs which we don't want to
19 r
= path_is_fs_type("/proc/sys/fs/binfmt_misc", BINFMTFS_MAGIC
);
20 if (r
== 0 || r
== -ENOENT
) {
21 log_debug("binfmt_misc is not mounted, not detaching entries.");
25 return log_warning_errno(r
, "Failed to determine whether binfmt_misc is mounted: %m");
27 r
= write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER
);
29 return log_warning_errno(r
, "Failed to unregister binfmt_misc entries: %m");
31 log_debug("Unregistered all remaining binfmt_misc entries.");