[04/10] linux: Use internal DIR locks when accessing filepos on telldir
Commit Message
Since it might change during a readdir call.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/unix/sysv/linux/telldir.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
* Adhemerval Zanella via Libc-alpha:
> Since it might change during a readdir call.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/unix/sysv/linux/telldir.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/telldir.c b/sysdeps/unix/sysv/linux/telldir.c
> index 1bb822c807..57d435ed21 100644
> --- a/sysdeps/unix/sysv/linux/telldir.c
> +++ b/sysdeps/unix/sysv/linux/telldir.c
> @@ -23,5 +23,11 @@
> long int
> telldir (DIR *dirp)
> {
> - return dirp->filepos;
> + long int ret;
> +
> + __libc_lock_lock (dirp->lock);
> + ret = dirp->filepos;
> + __libc_lock_unlock (dirp->lock);
> +
> + return ret;
> }
This looks okay to me.
@@ -23,5 +23,11 @@
long int
telldir (DIR *dirp)
{
- return dirp->filepos;
+ long int ret;
+
+ __libc_lock_lock (dirp->lock);
+ ret = dirp->filepos;
+ __libc_lock_unlock (dirp->lock);
+
+ return ret;
}