From: Timo Sirainen Date: Mon, 31 Aug 2015 20:25:12 +0000 (+0300) Subject: lib: Added str_to_ino() X-Git-Tag: 2.2.19.rc1~143 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fa2e547a3298fb7855d096db5825b3624ebb5560;p=thirdparty%2Fdovecot%2Fcore.git lib: Added str_to_ino() --- diff --git a/src/lib/strnum.c b/src/lib/strnum.c index a79ce1cbca..5ed2445d34 100644 --- a/src/lib/strnum.c +++ b/src/lib/strnum.c @@ -387,6 +387,19 @@ int str_to_pid(const char *str, pid_t *num_r) return 0; } +int str_to_ino(const char *str, ino_t *num_r) +{ + uintmax_t l; + + if (str_to_uintmax(str, &l) < 0) + return -1; + + if (verify_xid(l, sizeof(*num_r)) < 0) + return -1; + *num_r = (ino_t)l; + return 0; +} + int str_to_uoff(const char *str, uoff_t *num_r) { uintmax_t l; diff --git a/src/lib/strnum.h b/src/lib/strnum.h index 3cd5cdc1bf..58de24fdd4 100644 --- a/src/lib/strnum.h +++ b/src/lib/strnum.h @@ -161,6 +161,9 @@ int str_to_gid(const char *str, gid_t *num_r) int str_to_pid(const char *str, pid_t *num_r) ATTR_WARN_UNUSED_RESULT; +int str_to_ino(const char *str, ino_t *num_r) + ATTR_WARN_UNUSED_RESULT; + int str_to_uoff(const char *str, uoff_t *num_r) ATTR_WARN_UNUSED_RESULT; int str_parse_uoff(const char *str, uoff_t *num_r,