All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir()
Date: Thu, 2 Jun 2016 15:00:26 -0600	[thread overview]
Message-ID: <57509E6A.3090604@redhat.com> (raw)
In-Reply-To: <146485754874.31047.6226537020118792004.stgit@bahia.huguette.org>

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

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 <gkurz@linux.vnet.ibm.com>
> ---


> +++ 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-06-02 21:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02  8:51 [Qemu-devel] [PATCH 0/4] 9p: get rid of readdir_r() Greg Kurz
2016-06-02  8:52 ` [Qemu-devel] [PATCH 1/4] 9p: drop useless out: label Greg Kurz
2016-06-02 19:57   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 2/4] 9p: introduce the V9fsDir type Greg Kurz
2016-06-02 20:05   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 3/4] 9p: add locking to V9fsDir Greg Kurz
2016-06-02 20:46   ` Eric Blake
2016-06-02  8:52 ` [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir() Greg Kurz
2016-06-02 21:00   ` Eric Blake [this message]
2016-06-03  6:29     ` Greg Kurz
2016-06-02  9:33 ` [Qemu-devel] [PATCH 0/4] 9p: get rid of readdir_r() Peter Maydell
2016-06-02  9:42   ` Greg Kurz
2016-06-02 12:05     ` Peter Maydell
2016-06-02 13:59     ` Michael Fritscher
2016-06-02 15:47       ` Greg Kurz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57509E6A.3090604@redhat.com \
    --to=eblake@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.