mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
util: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
8d424f1b23
commit
40fc85e796
@ -1760,6 +1760,7 @@ virFileReadAll;
|
||||
virFileReadAllQuiet;
|
||||
virFileReadBufQuiet;
|
||||
virFileReadHeaderFD;
|
||||
virFileReadHeaderQuiet;
|
||||
virFileReadLimFD;
|
||||
virFileReadLink;
|
||||
virFileReadValueBitmap;
|
||||
|
@ -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
|
||||
exceeding the maximum size limitation to EOVERFLOW. */
|
||||
int
|
||||
|
@ -131,6 +131,8 @@ int virFileDeleteTree(const char *dir);
|
||||
|
||||
int virFileReadHeaderFD(int fd, int maxlen, char **buf)
|
||||
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)
|
||||
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(3);
|
||||
int virFileReadAll(const char *path, int maxlen, char **buf)
|
||||
|
Loading…
x
Reference in New Issue
Block a user