提交 40fc85e7 编写于 作者: P Paolo Bonzini 提交者: Jiri Denemark

util: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD

Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 8d424f1b
...@@ -1760,6 +1760,7 @@ virFileReadAll; ...@@ -1760,6 +1760,7 @@ virFileReadAll;
virFileReadAllQuiet; virFileReadAllQuiet;
virFileReadBufQuiet; virFileReadBufQuiet;
virFileReadHeaderFD; virFileReadHeaderFD;
virFileReadHeaderQuiet;
virFileReadLimFD; virFileReadLimFD;
virFileReadLink; virFileReadLink;
virFileReadValueBitmap; virFileReadValueBitmap;
......
...@@ -1367,6 +1367,25 @@ virFileReadHeaderFD(int fd, int maxlen, char **buf) ...@@ -1367,6 +1367,25 @@ virFileReadHeaderFD(int fd, int maxlen, char **buf)
} }
int
virFileReadHeaderQuiet(const char *path,
int maxlen,
char **buf)
{
int fd;
int len;
fd = open(path, O_RDONLY);
if (fd < 0)
return -1;
len = virFileReadHeaderFD(fd, maxlen, buf);
VIR_FORCE_CLOSE(fd);
return len;
}
/* A wrapper around saferead_lim that maps a failure due to /* A wrapper around saferead_lim that maps a failure due to
exceeding the maximum size limitation to EOVERFLOW. */ exceeding the maximum size limitation to EOVERFLOW. */
int int
......
...@@ -131,6 +131,8 @@ int virFileDeleteTree(const char *dir); ...@@ -131,6 +131,8 @@ int virFileDeleteTree(const char *dir);
int virFileReadHeaderFD(int fd, int maxlen, char **buf) int virFileReadHeaderFD(int fd, int maxlen, char **buf)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3); ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3);
int virFileReadHeaderQuiet(const char *path, int maxlen, char **buf)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virFileReadLimFD(int fd, int maxlen, char **buf) int virFileReadLimFD(int fd, int maxlen, char **buf)
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3); ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3);
int virFileReadAll(const char *path, int maxlen, char **buf) int virFileReadAll(const char *path, int maxlen, char **buf)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册