Add backends for this frontend function so that we can use it in the
snapshot creation code.
---
src/storage/storage_backend_fs.c | 17 +++++++++++++++++
src/storage/storage_backend_gluster.c | 28 ++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index c93fc1e..bd5cab8 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1367,6 +1367,22 @@ virStorageFileBackendFileInit(virStorageSourcePtr src)
static int
+virStorageFileBackendFileCreate(virStorageSourcePtr src)
+{
+ int fd = -1;
+
+ if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, 0,
+ src->drv->uid, src->drv->gid, 0)) < 0) {
+ errno = -fd;
+ return -1;
+ }
+
+ VIR_FORCE_CLOSE(fd);
+ return 0;
+}
+
+
+static int
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
{
return unlink(src->path);
@@ -1441,6 +1457,7 @@ virStorageFileBackend virStorageFileBackendFile = {
.backendInit = virStorageFileBackendFileInit,
.backendDeinit = virStorageFileBackendFileDeinit,
+ .storageFileCreate = virStorageFileBackendFileCreate,
.storageFileUnlink = virStorageFileBackendFileUnlink,
.storageFileStat = virStorageFileBackendFileStat,
.storageFileReadHeader = virStorageFileBackendFileReadHeader,
diff --git a/src/storage/storage_backend_gluster.c
b/src/storage/storage_backend_gluster.c
index 1a2b4ec..ae23999 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -623,6 +623,33 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
static int
+virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
+{
+ virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
+ glfs_fd_t *fd = NULL;
+ int save_errno;
+ int ret = -1;
+
+ if (!(fd = glfs_open(priv->vol, src->path, O_CREAT | O_TRUNC | O_WRONLY)))
+ return -1;
+
+ if (src->drv->uid != 0 || src->drv->gid != 0) {
+ if (glfs_fchown(fd, src->drv->uid, src->drv->gid) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ save_errno = errno;
+ ignore_value(glfs_close(fd));
+ errno = save_errno;
+
+ return ret;
+}
+
+
+static int
virStorageFileBackendGlusterUnlink(virStorageSourcePtr src)
{
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
@@ -797,6 +824,7 @@ virStorageFileBackend virStorageFileBackendGluster = {
.backendInit = virStorageFileBackendGlusterInit,
.backendDeinit = virStorageFileBackendGlusterDeinit,
+ .storageFileCreate = virStorageFileBackendGlusterCreate,
.storageFileUnlink = virStorageFileBackendGlusterUnlink,
.storageFileStat = virStorageFileBackendGlusterStat,
.storageFileReadHeader = virStorageFileBackendGlusterReadHeader,
--
1.9.3