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 <gk...@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
signature.asc
Description: OpenPGP digital signature