[PATCHv4 7/8] storage: improve handling of symlinks in gluster

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

 



With this patch, dangling and looping symlinks are silently
ignored, while links to files and directories are treated the
same as the underlying file or directory.  This is the same
behavior as both 'directory' and 'netfs' pools.

* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Treat symlinks similar to
directory and netfs pools.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/storage/storage_backend_gluster.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index a4fd4b3..e935583 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -166,6 +166,17 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     if (STREQ(name, ".") || STREQ(name, ".."))
         return 0;

+    /* Follow symlinks; silently skip broken links and loops.  */
+    if (S_ISLNK(st->st_mode) && glfs_stat(state->vol, name, st) < 0) {
+        if (errno == ENOENT || errno == ELOOP) {
+            VIR_WARN("ignoring dangling symlink '%s'", name);
+            ret = 0;
+        } else {
+            virReportSystemError(errno, _("cannot stat '%s'"), name);
+        }
+        return ret;
+    }
+
     if (VIR_ALLOC(vol) < 0)
         goto cleanup;

-- 
1.8.3.1

--
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]