Date: Wed, 23 Aug 2017 12:11:35 +0200 From: Nikolaus Rath <Nikolaus@rath.org> To: freebsd-fs@freebsd.org Subject: Re: Can telldir() == 0 value be made special? Message-ID: <87ziaqr3u0.fsf@vostro.rath.org> In-Reply-To: <CAG6CVpWf33CxbVJLtr-2-NESdoiPUWQHfcL_qaYrCUR2kQFS4g@mail.gmail.com> (Conrad Meyer's message of "Tue, 22 Aug 2017 12:05:29 -0700") References: <87bmn7kf3b.fsf@vostro.rath.org> <CAG6CVpVViqnbGuVn_JETBC5Q0NoYfC4VJK7iWjEfA7tFurQ2ag@mail.gmail.com> <87lgmbfob2.fsf@vostro.rath.org> <CAF6rxg=J7TYQQtG4%2B9TzEPPAb7LTReAm6U3A19Aq24PWrnK4vw@mail.gmail.com> <CAG6CVpWf33CxbVJLtr-2-NESdoiPUWQHfcL_qaYrCUR2kQFS4g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Aug 22 2017, Conrad Meyer <cem@freebsd.org> wrote: > One could also make it reserve the zero slot for the loc =3D=3D 0 entry, > but not create it dynamically. Just set loccnt=3D1 at initialization > and then special-case dd_loc=3D=3D0. Like this: > > --- a/lib/libc/gen/opendir.c > +++ b/lib/libc/gen/opendir.c > @@ -295,7 +295,7 @@ __opendir_common(int fd, int flags, bool use_current_= pos) > dirp->dd_lock =3D NULL; > dirp->dd_td =3D (struct _telldir *)((char *)dirp + sizeof(DIR)); > LIST_INIT(&dirp->dd_td->td_locq); > - dirp->dd_td->td_loccnt =3D 0; > + dirp->dd_td->td_loccnt =3D 1; > dirp->dd_compat_de =3D NULL; > > /* > --- a/lib/libc/gen/telldir.c > +++ b/lib/libc/gen/telldir.c > @@ -76,7 +76,10 @@ telldir(DIR *dirp) > _pthread_mutex_unlock(&dirp->dd_lock); > return (-1); > } > - lp->loc_index =3D dirp->dd_td->td_loccnt++; > + if (dirp->dd_loc =3D=3D 0) > + lp->loc_index =3D 0; > + else > + lp->loc_index =3D dirp->dd_td->td_loccnt++; > lp->loc_seek =3D dirp->dd_seek; > lp->loc_loc =3D dirp->dd_loc; > if (flp !=3D NULL) > This would improve Linux/fuse compatibility a lot, and seems like a minimal increase in complexity. Is there any way I can help to get it merged? Best, -Nikolaus --=20 GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2= =AB
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87ziaqr3u0.fsf>