summaryrefslogtreecommitdiff
path: root/src/basic/stat-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-29 15:57:49 +0200
committerLennart Poettering <lennart@poettering.net>2018-11-29 20:21:39 +0100
commit846b3bd61e1d575b0b28f73c4d15385f94bb1662 (patch)
tree6c5a149cf229086e30ee76a0c9d0a55f67ea8e3a /src/basic/stat-util.h
parent8e8b5d2e6d91180a57844b09cdbdcbc1fa466bfa (diff)
downloadsystemd-846b3bd61e1d575b0b28f73c4d15385f94bb1662.tar.gz
stat-util: add new APIs device_path_make_{major_minor|canonical}() and device_path_parse_major_minor()
device_path_make_{major_minor|canonical) generate device node paths given a mode_t and a dev_t. We have similar code all over the place, let's unify this in one place. The former will generate a "/dev/char/" or "/dev/block" path, and never go to disk. The latter then goes to disk and resolves that path to the actual path of the device node. device_path_parse_major_minor() reverses device_path_make_major_minor(), also withozut going to disk. We have similar code doing something like this at various places, let's unify this in a single set of functions. This also allows us to teach them special tricks, for example handling of the /run/systemd/inaccessible/{blk|chr} device nodes, which we use for masking device nodes, and which do not exist in /dev/char/* and /dev/block/*
Diffstat (limited to 'src/basic/stat-util.h')
-rw-r--r--src/basic/stat-util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h
index fe4a4bb717..0a08e642b5 100644
--- a/src/basic/stat-util.h
+++ b/src/basic/stat-util.h
@@ -81,3 +81,7 @@ int fd_verify_directory(int fd);
typeof(x) _x = (x), _y = 0; \
_x >= _y && _x < (UINT32_C(1) << 20); \
})
+
+int device_path_make_major_minor(mode_t mode, dev_t devno, char **ret);
+int device_path_make_canonical(mode_t mode, dev_t devno, char **ret);
+int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno);