Can telldir() == 0 value be made special?

Nikolaus Rath Nikolaus at rath.org
Wed Aug 23 10:11:41 UTC 2017


On Aug 22 2017, Conrad Meyer <cem at freebsd.org> wrote:
> One could also make it reserve the zero slot for the loc == 0 entry,
> but not create it dynamically.  Just set loccnt=1 at initialization
> and then special-case dd_loc==0.  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 = NULL;
>         dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
>         LIST_INIT(&dirp->dd_td->td_locq);
> -       dirp->dd_td->td_loccnt = 0;
> +       dirp->dd_td->td_loccnt = 1;
>         dirp->dd_compat_de = 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 = dirp->dd_td->td_loccnt++;
> +               if (dirp->dd_loc == 0)
> +                       lp->loc_index = 0;
> +               else
> +                       lp->loc_index = dirp->dd_td->td_loccnt++;
>                 lp->loc_seek = dirp->dd_seek;
>                 lp->loc_loc = dirp->dd_loc;
>                 if (flp != 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

-- 
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the freebsd-fs mailing list