mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Introduce virFileReadAllQuiet
Just like virFileReadAll, but returns -errno instead of reporting errors. Useful for ignoring some errors.
This commit is contained in:
parent
5de9b50259
commit
f638c13ea4
@ -1288,6 +1288,7 @@ virFileOpenAs;
|
|||||||
virFileOpenTty;
|
virFileOpenTty;
|
||||||
virFilePrintf;
|
virFilePrintf;
|
||||||
virFileReadAll;
|
virFileReadAll;
|
||||||
|
virFileReadAllQuiet;
|
||||||
virFileReadHeaderFD;
|
virFileReadHeaderFD;
|
||||||
virFileReadLimFD;
|
virFileReadLimFD;
|
||||||
virFileRelLinkPointsTo;
|
virFileRelLinkPointsTo;
|
||||||
|
@ -1301,6 +1301,21 @@ virFileReadAll(const char *path, int maxlen, char **buf)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virFileReadAllQuiet(const char *path, int maxlen, char **buf)
|
||||||
|
{
|
||||||
|
int fd = open(path, O_RDONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
int len = virFileReadLimFD(fd, maxlen, buf);
|
||||||
|
VIR_FORCE_CLOSE(fd);
|
||||||
|
if (len < 0)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/* Truncate @path and write @str to it. If @mode is 0, ensure that
|
/* Truncate @path and write @str to it. If @mode is 0, ensure that
|
||||||
@path exists; otherwise, use @mode if @path must be created.
|
@path exists; otherwise, use @mode if @path must be created.
|
||||||
Return 0 for success, nonzero for failure.
|
Return 0 for success, nonzero for failure.
|
||||||
|
@ -129,6 +129,8 @@ 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)
|
||||||
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
|
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
|
||||||
|
int virFileReadAllQuiet(const char *path, int maxlen, char **buf)
|
||||||
|
ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
|
||||||
|
|
||||||
int virFileWriteStr(const char *path, const char *str, mode_t mode)
|
int virFileWriteStr(const char *path, const char *str, mode_t mode)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user