qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir()
Date: Thu, 2 Jun 2016 15:00:26 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/02/2016 02:52 AM, Greg Kurz wrote:
> This patch changes the 9p code to use readdir() again instead of
> readdir_r(), which is deprecated in glibc 2.24.
> 
> All the locking was put in place by a previous patch.
> 
> Signed-off-by: Greg Kurz <address@hidden>
> ---


> +++ b/hw/9pfs/codir.c
> @@ -17,8 +17,7 @@
>  #include "qemu/coroutine.h"
>  #include "coth.h"
>  
> -int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent *dent,
> -                      struct dirent **result)
> +int v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent **dent)
>  {
>      int err;
>      V9fsState *s = pdu->s;
> @@ -28,11 +27,14 @@ int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *fidp, 
> struct dirent *dent,
>      }
>      v9fs_co_run_in_worker(
>          {
> -            errno = 0;
> -            err = s->ops->readdir_r(&s->ctx, &fidp->fs, dent, result);
> -            if (!*result && errno) {
> +            struct dirent *entry;
> +            int old_errno = errno;
> +
> +            entry = s->ops->readdir(&s->ctx, &fidp->fs);
> +            if (!entry && errno != old_errno) {
>                  err = -errno;

Not safe. The only safe way to check errno after readdir() is to assign
it to 0 before readdir().

>              } else {
> +                *dent = entry;
>                  err = 0;
>              }
>          });


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]