Re: [v2] storage: Ignore dangling symbol link for filesystem pool

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

 



ä 2010å12æ21æ 00:09, Eric Blake åé:
On 12/20/2010 12:14 AM, Osier Yang wrote:
If there is a dangling symbol link in filesystem pool, the pool

s/symbol/symbolic/

will be failed to start or refresh, this patch is to fix it by

s/will be failed/will fail/

ignoring it with a warning log.

@@ -986,6 +988,12 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
      struct stat sb;

      if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY))<  0) {
+        if (areadlink(path)) {
+            VIR_WARN("cannot open volume '%s': %s", path,
+                     strerror(errno));
+            return -2;

Memory leak - areadlink() returns a malloc()d string that the user must
free.Also, areadlink() is expensive (in addition to malloc(), it makes
several syscalls);

oh, just looked at the source code of areadlink, indeed, thanks.

a more efficient solution would be to check if errno
is ELOOP or ENOENT (the only possibilities for a dangling symlink; any
other error should return -1), and in those two cases a successful
lstat() is sufficient to detect a broken symlink without resorting to
reading its contents.


I guess you mean stat, lstat will not work here, as it doesn't follow
the *symbolic* link. what we need to do is to determine if the symbolic
link is dangling, so use "stat" to update the patch, v3 send, thanks
again.

Regards
Osier

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