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

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

On 12/20/2010 12:14 AM, Osier Yang wrote:
> If there is a dangling symbol link in filesystem pool, the pool


> 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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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