sigpipe
snprintf
socket
+stat-time
stdarg
stpcpy
strchrnul
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
+ <timestamps>
+ <atime>1341933637.273190990</atime>
+ <mtime>1341930622.047245868</mtime>
+ <ctime>1341930622.047245868</ctime>
+ </timestamps>
<encryption type='...'>
...
</encryption>
contains the MAC (eg SELinux) label string.
<span class="since">Since 0.4.1</span>
</dd>
+ <dt><code>timestamps</code></dt>
+ <dd>Provides timing information about the volume. Up to four
+ sub-elements are present,
+ where <code>atime</code>, <code>btime</code>, <code>ctime</code>
+ and <code>mtime</code> hold the access, birth, change and
+ modification time of the volume, where known. The used time
+ format is <seconds>.<nanoseconds> since the
+ beginning of the epoch (1 Jan 1970). If nanosecond resolution
+ is 0 or otherwise unsupported by the host OS or filesystem,
+ then the nanoseconds part is omitted. This is a readonly
+ attribute and is ignored when creating a volume.
+ <span class="since">Since 0.10.0</span>
+ </dd>
<dt><code>encryption</code></dt>
<dd>If present, specifies how the volume is encrypted. See
the <a href="formatstorageencryption.html">Storage Encryption</a> page
</optional>
</define>
+ <define name='timestamps'>
+ <optional>
+ <element name='timestamps'>
+ <interleave>
+ <optional>
+ <element name='atime'>
+ <ref name='timestamp'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='btime'>
+ <ref name='timestamp'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='ctime'>
+ <ref name='timestamp'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='mtime'>
+ <ref name='timestamp'/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </optional>
+ </define>
+
+ <define name='timestamp'>
+ <data type='string'>
+ <param name="pattern">[0-9]+(\.[0-9]{0,9})?</param>
+ </data>
+ </define>
+
<define name='target'>
<element name='target'>
<optional>
</optional>
<ref name='format'/>
<ref name='permissions'/>
+ <ref name='timestamps'/>
<optional>
<ref name='encryption'/>
</optional>
dontwarn="$dontwarn -Wunsafe-loop-optimizations"
# Things like virAsprintf mean we can't use this
dontwarn="$dontwarn -Wformat-nonliteral"
+ # Gnulib's stat-time.h violates this
+ dontwarn="$dontwarn -Waggregate-return"
# We might fundamentally need some of these disabled forever, but
# ideally we'd turn many of them on
VIR_FREE(def->target.path);
VIR_FREE(def->target.perms.label);
+ VIR_FREE(def->target.timestamps);
virStorageEncryptionFree(def->target.encryption);
VIR_FREE(def->backingStore.path);
VIR_FREE(def->backingStore.perms.label);
+ VIR_FREE(def->backingStore.timestamps);
virStorageEncryptionFree(def->backingStore.encryption);
VIR_FREE(def);
}
return virStorageVolDefParse(pool, NULL, filename);
}
+static void
+virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
+ struct timespec *ts)
+{
+ if (ts->tv_nsec < 0)
+ return;
+ virBufferAsprintf(buf, " <%s>%llu", name,
+ (unsigned long long) ts->tv_sec);
+ if (ts->tv_nsec)
+ virBufferAsprintf(buf, ".%09ld", ts->tv_nsec);
+ virBufferAsprintf(buf, "</%s>\n", name);
+}
+
static int
virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferPtr buf,
virBufferAddLit(buf," </permissions>\n");
+ if (def->timestamps) {
+ virBufferAddLit(buf, " <timestamps>\n");
+ virStorageVolTimestampFormat(buf, "atime", &def->timestamps->atime);
+ virStorageVolTimestampFormat(buf, "mtime", &def->timestamps->mtime);
+ virStorageVolTimestampFormat(buf, "ctime", &def->timestamps->ctime);
+ virStorageVolTimestampFormat(buf, "btime", &def->timestamps->btime);
+ virBufferAddLit(buf, " </timestamps>\n");
+ }
+
if (def->encryption) {
virBufferAdjustIndent(buf, 4);
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
/* Storage volumes */
+typedef struct _virStorageTimestamps virStorageTimestamps;
+typedef virStorageTimestamps *virStorageTimestampsPtr;
+struct _virStorageTimestamps {
+ struct timespec atime;
+ /* if btime.tv_nsec == -1 then
+ * birth time is unknown
+ */
+ struct timespec btime;
+ struct timespec ctime;
+ struct timespec mtime;
+};
+
/*
* How the volume's data is stored on underlying
char *path;
int format;
virStoragePerms perms;
+ virStorageTimestampsPtr timestamps;
int type; /* only used by disk backend for partition type */
/* Currently used only in virStorageVolDef.target, not in .backingstore. */
virStorageEncryptionPtr encryption;
/*
* storage_backend.c: internal storage driver backend contract
*
- * Copyright (C) 2007-2011 Red Hat, Inc.
+ * Copyright (C) 2007-2012 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
#include "storage_backend.h"
#include "logging.h"
#include "virfile.h"
+#include "stat-time.h"
#if WITH_STORAGE_LVM
# include "storage_backend_logical.h"
target->perms.uid = sb.st_uid;
target->perms.gid = sb.st_gid;
+ if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ target->timestamps->atime = get_stat_atime(&sb);
+ target->timestamps->btime = get_stat_birthtime(&sb);
+ target->timestamps->ctime = get_stat_ctime(&sb);
+ target->timestamps->mtime = get_stat_mtime(&sb);
+
VIR_FREE(target->perms.label);
#if HAVE_SELINUX
<group>0</group>
<label>virt_image_t</label>
</permissions>
+ <timestamps>
+ <atime>1341933637.273190990</atime>
+ <mtime>1341930622.047245868</mtime>
+ <ctime>1341930622.047245868</ctime>
+ </timestamps>
</target>
</volume>