Patch: Re: elm 2.5.3 and glibc 2.1.93
H . J . Lu
hjl@lucon.org
Fri Sep 22 00:17:00 GMT 2000
On Thu, Sep 21, 2000 at 09:16:43PM -0700, H . J . Lu wrote:
> With glibc 2.1.93, I got
>
> # elm
> Cannot lock folder - giving up. Please try again in a few minutes.
>
> >From strace, I got
>
> open("/var/spool/mail/hjl", O_RDWR) = 4
> fcntl64(4, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = -1 ENOSYS (Function not implemented)
> fcntl(4, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
> write(1, "\33[?1l\33>", 7^[[?1l^[>) = 7
> write(1, "\33[24;1H\r\n", 9^[[24;1H^M) = 9
> write(1, "\33[2J\33[?47l\0338", 12^[[2J^[[?47l^[8) = 12
> ioctl(0, SNDCTL_TMR_STOP, {B9600 opost isig icanon echo ...}) = 0
> write(2, "Cannot lock folder - giving up. "..., 67Cannot lock folder - giving up. Please try again in a few minutes.) = 67
>
> It looks like elm 2.5.3 may check errno even when fcntl returns 0. I
> believe it is a glibc bug. Here is my patch. Someone please double
> check if there are any more functions like that need fix.
>
Here is a patch for the problems I found.
H.J.
----
2000-09-21 H.J. Lu <hjl@gnu.org>
* sysdeps/posix/pathconf.c (__pathconf): Use __set_errno to
set errno.
* sysdeps/unix/sysv/linux/powerpc/chown.c (__chown): Likewise.
* sysdeps/unix/sysv/linux/pread.c (__libc_pread): Save and
restore errno if necessary.
* sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Likewise.
* sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
* sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64):
Likewise.
* sysdeps/unix/sysv/linux/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/alpha/adjtime.c (__adjtime): Likewise.
(__adjtimex_tv64): Likewise.
* sysdeps/unix/sysv/linux/i386/fcntl.c (__libc_fcntl): Likewise.
* sysdeps/unix/sysv/linux/i386/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/getrlimit.c (__new_getrlimit):
Likewise.
* sysdeps/unix/sysv/linux/i386/lockf64.c (lockf64): Likewise.
* sysdeps/unix/sysv/linux/i386/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/i386/setrlimit.c (__new_setrlimit):
Likewise.
* sysdeps/unix/sysv/linux/i386/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/mips/pread.c (__libc_pread): Likewise.
* sysdeps/unix/sysv/linux/mips/pread64.c (__libc_pread64):
Likewise.
* sysdeps/unix/sysv/linux/mips/pwrite.c (__libc_pwrite):
Likewise.
* sysdeps/unix/sysv/linux/mips/pwrite64.c (__libc_pwrite64):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/pread.c (__libc_pread):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/pread64.c (__libc_pread64):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/pwrite.c (__libc_pwrite):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/pwrite64.c (__libc_pwrite64):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c (setegid):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c (seteuid):
Likewise.
Index: sysdeps/posix/pathconf.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/posix/pathconf.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pathconf.c
--- sysdeps/posix/pathconf.c 2000/09/22 05:54:49 1.1.1.1
+++ sysdeps/posix/pathconf.c 2000/09/22 06:30:11
@@ -70,7 +70,7 @@ __pathconf (const char *path, int name)
{
if (errno == ENOSYS)
{
- errno = save_errno;
+ __set_errno (save_errno);
return NAME_MAX;
}
return -1;
Index: sysdeps/unix/sysv/linux/pread.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/pread.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread.c
--- sysdeps/unix/sysv/linux/pread.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/pread.c 2000/09/22 06:01:36
@@ -47,14 +47,20 @@ __libc_pread (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+# if __ASSUME_PREAD_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count,
__LONG_LONG_PAIR (0, offset));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread (fd, buf, count, offset);
+ {
+ /* No system call available. Use the emulation. */
+ __set_errno (saved_errno);
+ result = __emulate_pread (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/pread64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/pread64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread64.c
--- sysdeps/unix/sysv/linux/pread64.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/pread64.c 2000/09/22 06:02:22
@@ -46,6 +46,9 @@ __libc_pread64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+# if __ASSUME_PREAD_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count,
@@ -53,8 +56,11 @@ __libc_pread64 (fd, buf, count, offset)
(off_t) (offset & 0xffffffff)));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread64 (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/pwrite.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/pwrite.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite.c
--- sysdeps/unix/sysv/linux/pwrite.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/pwrite.c 2000/09/22 06:02:53
@@ -47,14 +47,20 @@ __libc_pwrite (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+# if __ASSUME_PWRITE_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count,
__LONG_LONG_PAIR (0, offset));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/pwrite64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/pwrite64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite64.c
--- sysdeps/unix/sysv/linux/pwrite64.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/pwrite64.c 2000/09/22 06:03:25
@@ -46,6 +46,9 @@ __libc_pwrite64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+# if __ASSUME_PWRITE_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count,
@@ -53,8 +56,11 @@ __libc_pwrite64 (fd, buf, count, offset)
(off_t) (offset & 0xffffffff)));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite64 (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/setegid.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/setegid.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 setegid.c
--- sysdeps/unix/sysv/linux/setegid.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/setegid.c 2000/09/22 06:35:25
@@ -29,6 +29,7 @@ int
setegid (gid_t gid)
{
int result;
+ int saved_errno = errno;
if (gid == (gid_t) ~0)
{
@@ -39,10 +40,14 @@ setegid (gid_t gid)
/* First try the syscall. */
result = __setresgid (-1, gid, -1);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use emulation. This may not work
- since `setregid' also sets the saved group ID when GID is not
- equal to the real group ID, making it impossible to switch back. */
- result = __setregid (-1, gid);
+ {
+ /* No system call available. Use emulation. This may not work
+ since `setregid' also sets the saved group ID when GID is not
+ equal to the real group ID, making it impossible to switch
+ back. */
+ __set_errno (saved_errno);
+ result = __setregid (-1, gid);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/seteuid.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/seteuid.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 seteuid.c
--- sysdeps/unix/sysv/linux/seteuid.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/seteuid.c 2000/09/22 06:33:33
@@ -31,6 +31,9 @@ int
seteuid (uid_t uid)
{
int result;
+# if __ASSUME_SETRESUID_SYSCALL == 0
+ int saved_errno = errno;
+# endif
if (uid == (uid_t) ~0)
{
@@ -42,10 +45,14 @@ seteuid (uid_t uid)
result = __setresuid (-1, uid, -1);
# if __ASSUME_SETRESUID_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use emulation. This may not work
- since `setreuid' also sets the saved user ID when UID is not
- equal to the real user ID, making it impossible to switch back. */
- result = __setreuid (-1, uid);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use emulation. This may not work
+ since `setreuid' also sets the saved user ID when UID is not
+ equal to the real user ID, making it impossible to switch
+ back. */
+ result = __setreuid (-1, uid);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/alpha/adjtime.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/alpha/adjtime.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 adjtime.c
--- sysdeps/unix/sysv/linux/alpha/adjtime.c 2000/09/22 05:54:57 1.1.1.1
+++ sysdeps/unix/sysv/linux/alpha/adjtime.c 2000/09/22 06:13:09
@@ -94,12 +94,16 @@ __adjtime (itv, otv)
struct timeval *otv;
{
int ret;
+ int saved_errno = errno;
if (!missing_adjtimex)
{
ret = __adjtime_tv64 (itv, otv);
if (ret && errno == ENOSYS)
- missing_adjtimex = 1;
+ {
+ __set_errno (saved_errno);
+ missing_adjtimex = 1;
+ }
}
if (missing_adjtimex)
@@ -127,13 +131,17 @@ int
__adjtimex_tv64 (struct timex *tx)
{
int ret;
+ int saved_errno = errno;
if (!missing_adjtimex)
- {
- ret = __syscall_adjtimex_tv64 (tx);
- if (ret && errno == ENOSYS)
- missing_adjtimex = 1;
- }
+ {
+ ret = __syscall_adjtimex_tv64 (tx);
+ if (ret && errno == ENOSYS)
+ {
+ __set_errno (saved_errno);
+ missing_adjtimex = 1;
+ }
+ }
if (missing_adjtimex)
{
Index: sysdeps/unix/sysv/linux/i386/fcntl.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/fcntl.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fcntl.c
--- sysdeps/unix/sysv/linux/i386/fcntl.c 2000/09/22 05:55:00 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/fcntl.c 2000/09/22 05:56:52
@@ -50,10 +50,13 @@ __libc_fcntl (int fd, int cmd, ...)
# ifdef __NR_fcntl64
if (! __have_no_fcntl64)
{
+ int saved_errno = errno;
int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+
if (result >= 0 || errno != ENOSYS)
return result;
+ __set_errno (saved_errno);
__have_no_fcntl64 = 1;
}
# endif
Index: sysdeps/unix/sysv/linux/i386/fxstat.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/fxstat.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fxstat.c
--- sysdeps/unix/sysv/linux/i386/fxstat.c 2000/09/22 05:55:00 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/fxstat.c 2000/09/22 06:13:56
@@ -73,6 +73,7 @@ __fxstat (int vers, int fd, struct stat
if (! __have_no_stat64)
{
struct stat64 buf64;
+ int saved_errno = errno;
result = INLINE_SYSCALL (fstat64, 2, fd, __ptrvalue (&buf64));
@@ -82,6 +83,7 @@ __fxstat (int vers, int fd, struct stat
if (result != -1 || errno != ENOSYS)
return result;
+ __set_errno (saved_errno);
__have_no_stat64 = 1;
}
# endif
Index: sysdeps/unix/sysv/linux/i386/getrlimit.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/getrlimit.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 getrlimit.c
--- sysdeps/unix/sysv/linux/i386/getrlimit.c 2000/09/22 05:55:00 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/getrlimit.c 2000/09/22 06:14:41
@@ -48,6 +48,7 @@ __new_getrlimit (enum __rlimit_resource
# ifdef __NR_ugetrlimit
if (__have_no_new_getrlimit <= 0)
{
+ int saved_errno = errno;
result = INLINE_SYSCALL (ugetrlimit, 2, resource, CHECK_1 (rlimits));
/* If the system call is available remember this fact and return. */
@@ -57,6 +58,7 @@ __new_getrlimit (enum __rlimit_resource
return result;
}
+ __set_errno (saved_errno);
/* Remember that the system call is not available. */
__have_no_new_getrlimit = 1;
}
Index: sysdeps/unix/sysv/linux/i386/lockf64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/lockf64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 lockf64.c
--- sysdeps/unix/sysv/linux/i386/lockf64.c 2000/09/22 05:55:01 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/lockf64.c 2000/09/22 06:15:48
@@ -95,6 +95,7 @@ lockf64 (int fd, int cmd, off64_t len64)
# ifdef __NR_fcntl64
if (!__have_no_fcntl64)
{
+ int saved_errno = errno;
int res = INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64);
/* If errno == ENOSYS try the 32bit interface if len64 can
@@ -108,7 +109,10 @@ lockf64 (int fd, int cmd, off64_t len64)
return -1;
}
else if (errno == ENOSYS)
- __have_no_fcntl64 = 1;
+ {
+ __set_errno (saved_errno);
+ __have_no_fcntl64 = 1;
+ }
else
/* res < 0 && errno != ENOSYS. */
return -1;
@@ -169,6 +173,7 @@ lockf64 (int fd, int cmd, off64_t len64)
if (!__have_no_fcntl64)
{
+ int saved_errno = errno;
int res = INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64);
/* If errno == ENOSYS try the 32bit interface if len64 can
@@ -176,6 +181,7 @@ lockf64 (int fd, int cmd, off64_t len64)
if (res == 0 || errno != ENOSYS)
return res;
+ __set_errno (saved_errno);
__have_no_fcntl64 = 1;
if (len64 != (off64_t) len)
Index: sysdeps/unix/sysv/linux/i386/lxstat.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/lxstat.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 lxstat.c
--- sysdeps/unix/sysv/linux/i386/lxstat.c 2000/09/22 05:55:00 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/lxstat.c 2000/09/22 06:16:04
@@ -76,6 +76,7 @@ __lxstat (int vers, const char *name, st
if (! __have_no_stat64)
{
struct stat64 buf64;
+ int saved_errno = errno;
result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64));
if (result == 0)
@@ -84,6 +85,7 @@ __lxstat (int vers, const char *name, st
if (result != -1 || errno != ENOSYS)
return result;
+ __set_errno (saved_errno);
__have_no_stat64 = 1;
}
# endif
Index: sysdeps/unix/sysv/linux/i386/seteuid.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/seteuid.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 seteuid.c
--- sysdeps/unix/sysv/linux/i386/seteuid.c 2000/09/22 05:55:00 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/seteuid.c 2000/09/22 06:17:30
@@ -32,13 +32,20 @@ seteuid (uid_t uid)
int result;
/* First try the syscall. */
#ifdef __NR_setresuid
+ int saved_errno = errno;
result = __setresuid (-1, uid, -1);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use emulation. This may not work
- since `setreuid' also sets the saved user ID when UID is not
- equal to the real user ID, making it impossible to switch back. */
-#endif
+ {
+ /* No system call available. Use emulation. This may not work
+ since `setreuid' also sets the saved user ID when UID is not
+ equal to the real user ID, making it impossible to switch
+ back. */
+ __set_errno (saved_errno);
+ result = __setreuid (-1, uid);
+ }
+#else
result = __setreuid (-1, uid);
+#endif
return result;
}
Index: sysdeps/unix/sysv/linux/i386/setrlimit.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/setrlimit.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 setrlimit.c
--- sysdeps/unix/sysv/linux/i386/setrlimit.c 2000/09/22 05:55:01 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/setrlimit.c 2000/09/22 06:20:26
@@ -49,10 +49,13 @@ __new_setrlimit (enum __rlimit_resource
# ifdef __NR_ugetrlimit
if (__have_no_new_getrlimit == 0)
{
+ int saved_errno = errno;
/* Check if the new ugetrlimit syscall exists. We must do this
first because older kernels don't reject negative rlimit
values in setrlimit. */
int result = INLINE_SYSCALL (ugetrlimit, 2, resource, __ptrvalue (&rlimits_small));
+
+ __set_errno (saved_errno);
if (result != -1 || errno != ENOSYS)
/* The syscall exists. */
__have_no_new_getrlimit = -1;
Index: sysdeps/unix/sysv/linux/i386/xstat.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/i386/xstat.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 xstat.c
--- sysdeps/unix/sysv/linux/i386/xstat.c 2000/09/22 05:55:01 1.1.1.1
+++ sysdeps/unix/sysv/linux/i386/xstat.c 2000/09/22 06:21:04
@@ -75,6 +75,7 @@ __xstat (int vers, const char *name, str
if (! __have_no_stat64)
{
struct stat64 buf64;
+ int saved_errno = errno;
result = INLINE_SYSCALL (stat64, 2, CHECK_STRING (name), __ptrvalue (&buf64));
@@ -84,6 +85,7 @@ __xstat (int vers, const char *name, str
if (result != -1 || errno != ENOSYS)
return result;
+ __set_errno (saved_errno);
__have_no_stat64 = 1;
}
# endif
Index: sysdeps/unix/sysv/linux/mips/pread.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/mips/pread.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread.c
--- sysdeps/unix/sysv/linux/mips/pread.c 2000/09/22 05:55:02 1.1.1.1
+++ sysdeps/unix/sysv/linux/mips/pread.c 2000/09/22 06:21:55
@@ -46,14 +46,20 @@ __libc_pread (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+# if __ASSUME_PREAD_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
__LONG_LONG_PAIR (0, offset));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread (fd, buf, count, offset);
+ }
# endif
return result;
}
Index: sysdeps/unix/sysv/linux/mips/pread64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/mips/pread64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread64.c
--- sysdeps/unix/sysv/linux/mips/pread64.c 2000/09/22 05:55:02 1.1.1.1
+++ sysdeps/unix/sysv/linux/mips/pread64.c 2000/09/22 06:22:28
@@ -47,6 +47,9 @@ __libc_pread64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+# if __ASSUME_PREAD_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
@@ -54,8 +57,11 @@ __libc_pread64 (fd, buf, count, offset)
(off_t) (offset & 0xffffffff)));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread64 (fd, buf, count, offset);
+ }
# endif
return result;
}
Index: sysdeps/unix/sysv/linux/mips/pwrite.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/mips/pwrite.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite.c
--- sysdeps/unix/sysv/linux/mips/pwrite.c 2000/09/22 05:55:02 1.1.1.1
+++ sysdeps/unix/sysv/linux/mips/pwrite.c 2000/09/22 06:22:58
@@ -45,14 +45,20 @@ __libc_pwrite (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+# if __ASSUME_PWRITE_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
__LONG_LONG_PAIR (0, offset));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/mips/pwrite64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/mips/pwrite64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite64.c
--- sysdeps/unix/sysv/linux/mips/pwrite64.c 2000/09/22 05:55:02 1.1.1.1
+++ sysdeps/unix/sysv/linux/mips/pwrite64.c 2000/09/22 06:23:28
@@ -45,6 +45,9 @@ __libc_pwrite64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+# if __ASSUME_PWRITE_SYSCALL == 0
+ int saved_errno = errno;
+# endif
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
@@ -52,8 +55,11 @@ __libc_pwrite64 (fd, buf, count, offset)
(off_t) (offset & 0xffffffff)));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite64 (fd, buf, count, offset);
+ }
# endif
return result;
Index: sysdeps/unix/sysv/linux/powerpc/chown.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/powerpc/chown.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 chown.c
--- sysdeps/unix/sysv/linux/powerpc/chown.c 2000/09/22 05:55:03 1.1.1.1
+++ sysdeps/unix/sysv/linux/powerpc/chown.c 2000/09/22 06:25:27
@@ -66,14 +66,14 @@ __chown (const char *file, uid_t owner,
err = __readlink (file, link, PATH_MAX+1);
if (err == -1)
{
- errno = old_errno;
+ __set_errno (old_errno);
return __lchown(file, owner, group);
}
filelen = strlen (file) + 1;
if (filelen > sizeof(path))
{
- errno = ENAMETOOLONG;
+ __set_errno (ENAMETOOLONG);
return -1;
}
memcpy (path, file, filelen);
@@ -86,7 +86,7 @@ __chown (const char *file, uid_t owner,
if (err >= PATH_MAX+1)
{
- errno = ENAMETOOLONG;
+ __set_errno (ENAMETOOLONG);
return -1;
}
@@ -106,7 +106,7 @@ __chown (const char *file, uid_t owner,
filelen--;
if (filelen + linklen > sizeof(path))
{
- errno = ENAMETOOLONG;
+ __set_errno (ENAMETOOLONG);
return -1;
}
memcpy (path+filelen, link, linklen);
@@ -116,7 +116,7 @@ __chown (const char *file, uid_t owner,
if (err == -1)
{
- errno = old_errno;
+ __set_errno (old_errno);
return __lchown(path, owner, group);
}
}
Index: sysdeps/unix/sysv/linux/powerpc/pread.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/powerpc/pread.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread.c
--- sysdeps/unix/sysv/linux/powerpc/pread.c 2000/09/22 05:55:03 1.1.1.1
+++ sysdeps/unix/sysv/linux/powerpc/pread.c 2000/09/22 06:25:57
@@ -40,12 +40,16 @@ __libc_pread (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+ int saved_errno = errno;
/* First try the syscall. */
result = __syscall_pread (fd, buf, count, (off64_t) offset);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread (fd, buf, count, offset);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/powerpc/pread64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/powerpc/pread64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pread64.c
--- sysdeps/unix/sysv/linux/powerpc/pread64.c 2000/09/22 05:55:03 1.1.1.1
+++ sysdeps/unix/sysv/linux/powerpc/pread64.c 2000/09/22 06:26:20
@@ -40,12 +40,16 @@ __libc_pread64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+ int saved_errno = errno;
/* First try the syscall. */
result = __syscall_pread (fd, buf, count, offset);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pread64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread64 (fd, buf, count, offset);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/powerpc/pwrite.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/powerpc/pwrite.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite.c
--- sysdeps/unix/sysv/linux/powerpc/pwrite.c 2000/09/22 05:55:03 1.1.1.1
+++ sysdeps/unix/sysv/linux/powerpc/pwrite.c 2000/09/22 06:26:44
@@ -40,12 +40,16 @@ __libc_pwrite (fd, buf, count, offset)
off_t offset;
{
ssize_t result;
+ int saved_errno = errno;
/* First try the syscall. */
result = __syscall_pwrite (fd, buf, count, (off64_t) offset);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite (fd, buf, count, offset);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/powerpc/pwrite64.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/powerpc/pwrite64.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 pwrite64.c
--- sysdeps/unix/sysv/linux/powerpc/pwrite64.c 2000/09/22 05:55:03 1.1.1.1
+++ sysdeps/unix/sysv/linux/powerpc/pwrite64.c 2000/09/22 06:27:05
@@ -40,12 +40,16 @@ __libc_pwrite64 (fd, buf, count, offset)
off64_t offset;
{
ssize_t result;
+ int saved_errno = errno;
/* First try the syscall. */
result = __syscall_pwrite (fd, buf, count, offset);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use the emulation. */
- result = __emulate_pwrite64 (fd, buf, count, offset);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite64 (fd, buf, count, offset);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 setegid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c 2000/09/22 05:55:06 1.1.1.1
+++ sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c 2000/09/22 06:27:56
@@ -29,6 +29,7 @@ int
setegid (gid_t gid)
{
int result;
+ int saved_errno = errno;
if (gid == (gid_t) ~0)
{
@@ -39,10 +40,14 @@ setegid (gid_t gid)
/* First try the syscall. */
result = __setresgid (-1, gid, -1);
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use emulation. This may not work
- since `setregid' also sets the saved group ID when GID is not
- equal to the real group ID, making it impossible to switch back. */
- result = __setregid (-1, gid);
+ {
+ /* No system call available. Use emulation. This may not work
+ since `setregid' also sets the saved group ID when GID is not
+ equal to the real group ID, making it impossible to switch
+ back. */
+ __set_errno (saved_errno);
+ result = __setregid (-1, gid);
+ }
return result;
}
Index: sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 seteuid.c
--- sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c 2000/09/22 05:55:06 1.1.1.1
+++ sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c 2000/09/22 06:28:28
@@ -42,10 +42,14 @@ seteuid (uid_t uid)
result = __setresuid (-1, uid, -1);
# if __ASSUME_SETRESUID_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
- /* No system call available. Use emulation. This may not work
- since `setreuid' also sets the saved user ID when UID is not
- equal to the real user ID, making it impossible to switch back. */
- result = __setreuid (-1, uid);
+ {
+ __set_errno (saved_errno);
+ /* No system call available. Use emulation. This may not work
+ since `setreuid' also sets the saved user ID when UID is not
+ equal to the real user ID, making it impossible to switch
+ back. */
+ result = __setreuid (-1, uid);
+ }
# endif
return result;
More information about the Libc-hacker
mailing list