string_utils: add fdstr()

parent aabafa68
......@@ -159,4 +159,15 @@ static inline const char *proc_self_fd(int fd)
return buf;
}
static inline const char *fdstr(int fd)
{
static const char *fdstr_invalid = "-EBADF";
static char buf[INTTYPE_TO_STRLEN(int)];
if (strnprintf(buf, sizeof(buf), "%d", fd) < 0)
return fdstr_invalid;
return buf;
}
#endif /* __LXC_STRING_UTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment