]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/binfmt-util.c
json: add helpers for dealing with id128 + strv
[thirdparty/systemd.git] / src / shared / binfmt-util.c
1 #include <sys/stat.h>
2 #include <sys/statvfs.h>
3 #include <sys/vfs.h>
4
5 #include "binfmt-util.h"
6 #include "fileio.h"
7 #include "missing_magic.h"
8 #include "stat-util.h"
9
10 int disable_binfmt(void) {
11 int r;
12
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.
15 *
16 * We are a bit careful here, since binfmt_misc might still be an autofs which we don't want to
17 * trigger. */
18
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.");
22 return 0;
23 }
24 if (r < 0)
25 return log_warning_errno(r, "Failed to determine whether binfmt_misc is mounted: %m");
26
27 r = write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", WRITE_STRING_FILE_DISABLE_BUFFER);
28 if (r < 0)
29 return log_warning_errno(r, "Failed to unregister binfmt_misc entries: %m");
30
31 log_debug("Unregistered all remaining binfmt_misc entries.");
32 return 0;
33 }