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(a)redhat.com>
---
[...]
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