Re: [PATCH v2 01/13] util: add APIs for reading/writing from/to rotating files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 12, 2015 at 17:18:58 +0000, Daniel Berrange wrote:
> Add virRotatingFileReader and virRotatingFileWriter objects
> which allow reading & writing from/to files with automation
> rotation to N backup files when a size limit is reached. This
> is useful for guest logging when a guaranteed finite size
> limit is required. Use of external tools like logrotate is
> inadequate since it leaves the possibility for guest to DOS
> the host in between invokations of logrotate.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---

[...]

> diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c
> new file mode 100644
> index 0000000..840b55f
> --- /dev/null
> +++ b/src/util/virrotatingfile.c
> @@ -0,0 +1,608 @@

[...]

> +
> +
> +/**
> + * virRotatingFileWriterGetPath:
> + * @file: the file context
> + *
> + * Return the primary file path
> + */
> +const char *virRotatingFileWriterGetPath(virRotatingFileWriterPtr file)
> +{
> +    return file->basepath;
> +}
> +
> +
> +/**
> + * virRotatingFileWriterGetINode:
> + * @file: the file context
> + *
> + * Return the inode of the file currently being written to
> + */
> +ino_t virRotatingFileWriterGetINode(virRotatingFileWriterPtr file)
> +{
> +    return file->entry->inode;
> +}
> +
> +
> +/**
> + * virRotatingFileWriterGetOffset:
> + * @file: the file context
> + *
> + * Return the offset at which data is currently being written
> + */
> +off_t virRotatingFileWriterGetOffset(virRotatingFileWriterPtr file)
> +{
> +    return file->entry->pos;
> +}

I see how you are going to use this. I think the usage pattern is a bit
complicated, but for the purpose it will serve it's probably all right.

ACK

Peter

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]