stat-util: add new APIs device_path_make_{major_minor|canonical}() and device_path_pa...
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Jun 2018 13:57:49 +0000 (15:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 29 Nov 2018 19:21:39 +0000 (20:21 +0100)
commit846b3bd61e1d575b0b28f73c4d15385f94bb1662
tree6c5a149cf229086e30ee76a0c9d0a55f67ea8e3a
parent8e8b5d2e6d91180a57844b09cdbdcbc1fa466bfa
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/*
src/basic/stat-util.c
src/basic/stat-util.h
src/core/cgroup.c
src/test/test-stat-util.c