diff options
author | Mark Kettenis <kettenis@gnu.org> | 2001-01-06 12:31:35 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2001-01-06 12:31:35 +0000 |
commit | 655bfb8bffc4da7d5c8411a4e2f94919b64d4e02 (patch) | |
tree | 034cc2481eefb8e539d0448adcf83c6616fba279 /sysdeps | |
parent | 74ec0232c2183cff95b12957039cbdceac0ea3ce (diff) | |
download | glibc-655bfb8bffc4da7d5c8411a4e2f94919b64d4e02.zip glibc-655bfb8bffc4da7d5c8411a4e2f94919b64d4e02.tar.gz glibc-655bfb8bffc4da7d5c8411a4e2f94919b64d4e02.tar.bz2 |
* sysdeps/mach/hurd/readdir_r.c (__readdir_r): Return error number instead of -1 on failure. Don't forget to copy file name into *ENTRY if successful. Set *RESULT to NULL upon reaching the end of the directory.
* sysdeps/mach/hurd/readdir_r.c (__readdir_r): Return error number
instead of -1 on failure. Don't forget to copy file name into
*ENTRY if successful. Set *RESULT to NULL upon reaching the end
of the directory.
2001-01-06 Mark Kettenis <kettenis@gnu.org>
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/readdir_r.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sysdeps/mach/hurd/readdir_r.c b/sysdeps/mach/hurd/readdir_r.c index c8b8e4b..dad4a31 100644 --- a/sysdeps/mach/hurd/readdir_r.c +++ b/sysdeps/mach/hurd/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 94, 95, 96, 1997, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,11 +33,12 @@ int __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; + error_t err = 0; if (dirp == NULL) { errno = EINVAL; - return -1; + return errno; } __libc_lock_lock (dirp->__lock); @@ -50,7 +51,6 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) char *data = dirp->__data; int nentries; - error_t err; if (err = HURD_FD_PORT_USE (dirp->__fd, __dir_readdir (port, @@ -102,11 +102,15 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) if (dp) { *entry = *dp; + memcpy (entry->d_name, dp->d_name, dp->d_namlen + 1); *result = entry; } + else + *result = NULL; __libc_lock_unlock (dirp->__lock); - return dp ? 0 : -1; + return dp ? 0 : err ? errno : 0; } + weak_alias (__readdir_r, readdir_r) |