[PATCH] storage: Refetch file status after open

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

 



This partly reverts my previous patch f88de3eb. We need to
get file status after open, as given path could have been symlink,
so fstat() will operate on different file than lstat().
---
 src/storage/storage_backend.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index d30829d..d7394e0 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1041,6 +1041,14 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
         return -1;
     }
 
+    if (fstat(fd, &sb) < 0) {
+        virReportSystemError(errno,
+                             _("cannot stat file '%s'"),
+                             path);
+        VIR_FORCE_CLOSE(fd);
+        return -1;
+    }
+
     if (S_ISREG(sb.st_mode))
         mode = VIR_STORAGE_VOL_OPEN_REG;
     else if (S_ISCHR(sb.st_mode))
-- 
1.7.3.4

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