render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c401cc
From c40bd80dcb6de62d1bd48af22a4dcbd73cf66506 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <c40bd80dcb6de62d1bd48af22a4dcbd73cf66506@dist-git>
c401cc
From: Eric Blake <eblake@redhat.com>
c401cc
Date: Wed, 26 Feb 2014 14:54:27 +0100
c401cc
Subject: [PATCH] storage: improve handling of symlinks in gluster
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
c401cc
c401cc
With this patch, dangling and looping symlinks are silently
c401cc
ignored, while links to files and directories are treated the
c401cc
same as the underlying file or directory.  This is the same
c401cc
behavior as both 'directory' and 'netfs' pools.
c401cc
c401cc
* src/storage/storage_backend_gluster.c
c401cc
(virStorageBackendGlusterRefreshVol): Treat symlinks similar to
c401cc
directory and netfs pools.
c401cc
c401cc
Signed-off-by: Eric Blake <eblake@redhat.com>
c401cc
(cherry picked from commit 79eb21f9765495841daecee2e3ec6bf402022327)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/storage/storage_backend_gluster.c | 11 +++++++++++
c401cc
 1 file changed, 11 insertions(+)
c401cc
c401cc
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
c401cc
index 685ad57..f0ec357 100644
c401cc
--- a/src/storage/storage_backend_gluster.c
c401cc
+++ b/src/storage/storage_backend_gluster.c
c401cc
@@ -166,6 +166,17 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
c401cc
     if (STREQ(name, ".") || STREQ(name, ".."))
c401cc
         return 0;
c401cc
 
c401cc
+    /* Follow symlinks; silently skip broken links and loops.  */
c401cc
+    if (S_ISLNK(st->st_mode) && glfs_stat(state->vol, name, st) < 0) {
c401cc
+        if (errno == ENOENT || errno == ELOOP) {
c401cc
+            VIR_WARN("ignoring dangling symlink '%s'", name);
c401cc
+            ret = 0;
c401cc
+        } else {
c401cc
+            virReportSystemError(errno, _("cannot stat '%s'"), name);
c401cc
+        }
c401cc
+        return ret;
c401cc
+    }
c401cc
+
c401cc
     if (VIR_ALLOC(vol) < 0)
c401cc
         goto cleanup;
c401cc
 
c401cc
-- 
c401cc
1.9.0
c401cc