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: Greg Kurz
Subject: Re: [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir()
Date: Fri, 3 Jun 2016 08:29:07 +0200

On Thu, 2 Jun 2016 15:00:26 -0600
Eric Blake <address@hidden> wrote:

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

Yeah, you're right, errno could already be set to one of the values
returned by readdir() in case of error... 

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




reply via email to

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