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

Eric Blake eblake at redhat.com
Mon Dec 20 16:09:22 UTC 2010


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); 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.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101220/7fda3002/attachment-0001.sig>


More information about the libvir-list mailing list