diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-31 09:37:15 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-11-30 12:59:23 +0100 |
commit | 553e15f21bd7b1ecb709edfb5686d5768fe942f2 (patch) | |
tree | 7d28580207ffd053c6a5a144e41edb4db5812243 /src/basic/device-nodes.h | |
parent | ee3467c6bd63d38c43ec15e485bd07706483a09c (diff) | |
download | systemd-553e15f21bd7b1ecb709edfb5686d5768fe942f2.tar.gz |
Add a little helper to make /sys/dev/block/major:minor paths
Diffstat (limited to 'src/basic/device-nodes.h')
-rw-r--r-- | src/basic/device-nodes.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/device-nodes.h b/src/basic/device-nodes.h index 1e09bdc830..9f3c6d60c0 100644 --- a/src/basic/device-nodes.h +++ b/src/basic/device-nodes.h @@ -23,5 +23,13 @@ #include <stddef.h> #include <sys/types.h> +#include "macro.h" +#include "stdio-util.h" + int encode_devnode_name(const char *str, char *str_enc, size_t len); int whitelisted_char_for_devnode(char c, const char *additional); + +#define SYS_BLOCK_PATH_MAX(suffix) \ + (strlen("/sys/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t) + strlen_ptr(suffix)) +#define xsprintf_sys_block_path(buf, suffix, devno) \ + xsprintf(buf, "/sys/dev/block/%u:%u%s", major(devno), minor(devno), strempty(suffix)) |