diff options
author | Sven Eden <yamakuzure@gmx.net> | 2017-06-14 17:44:53 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-06-16 10:13:01 +0200 |
commit | c60d32aa37fc0b10451b0d392d90b3b96eb88ebc (patch) | |
tree | 8feceb57b0b0ebbabc22faa105f1608a1ec8a117 /src/basic/mount-util.c | |
parent | 33863e9c1572a093818e4559e69ca02452b60d5c (diff) |
Prep v231: Apply missing fixes from upstream (1/6) src/basic
Diffstat (limited to 'src/basic/mount-util.c')
-rw-r--r-- | src/basic/mount-util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index d04a49e2f..121619eed 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -534,3 +534,28 @@ int repeat_unmount(const char *path, int flags) { } } #endif // 0 + +const char* mode_to_inaccessible_node(mode_t mode) { + /* This function maps a node type to the correspondent inaccessible node type. + * Character and block inaccessible devices may not be created (because major=0 and minor=0), + * in such case we map character and block devices to the inaccessible node type socket. */ + switch(mode & S_IFMT) { + case S_IFREG: + return "/run/systemd/inaccessible/reg"; + case S_IFDIR: + return "/run/systemd/inaccessible/dir"; + case S_IFCHR: + if (access("/run/systemd/inaccessible/chr", F_OK) == 0) + return "/run/systemd/inaccessible/chr"; + return "/run/systemd/inaccessible/sock"; + case S_IFBLK: + if (access("/run/systemd/inaccessible/blk", F_OK) == 0) + return "/run/systemd/inaccessible/blk"; + return "/run/systemd/inaccessible/sock"; + case S_IFIFO: + return "/run/systemd/inaccessible/fifo"; + case S_IFSOCK: + return "/run/systemd/inaccessible/sock"; + } + return NULL; +} |