This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix fallocate error return on i386


Unlike posix_fallocate, fallocate should use the normal syscall error
reporting.

Andreas.

2010-04-07  Andreas Schwab  <schwab@redhat.com>

	* sysdeps/unix/sysv/linux/i386/fallocate.c: Set errno on error.
	* sysdeps/unix/sysv/linux/i386/fallocate64.c: Likewise.

diff --git a/sysdeps/unix/sysv/linux/i386/fallocate.c b/sysdeps/unix/sysv/linux/i386/fallocate.c
index 14e7883..1434a83 100644
--- a/sysdeps/unix/sysv/linux/i386/fallocate.c
+++ b/sysdeps/unix/sysv/linux/i386/fallocate.c
@@ -30,7 +30,13 @@ int
 fallocate (int fd, int mode, __off_t offset, __off_t len)
 {
 #ifdef __NR_fallocate
-  return __call_fallocate (fd, mode, offset, len);
+  int err = __call_fallocate (fd, mode, offset, len);
+  if (__builtin_expect (err, 0))
+    {
+      __set_errno (err);
+      err = -1;
+    }
+  return err;
 #else
   __set_errno (ENOSYS);
   return -1;
diff --git a/sysdeps/unix/sysv/linux/i386/fallocate64.c b/sysdeps/unix/sysv/linux/i386/fallocate64.c
index 85f315c..063bab0 100644
--- a/sysdeps/unix/sysv/linux/i386/fallocate64.c
+++ b/sysdeps/unix/sysv/linux/i386/fallocate64.c
@@ -30,7 +30,13 @@ int
 fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
 {
 #ifdef __NR_fallocate
-  return __call_fallocate (fd, mode, offset, len);
+  int err = __call_fallocate (fd, mode, offset, len);
+  if (__builtin_expect (err, 0))
+    {
+      __set_errno (err);
+      err = -1;
+    }
+  return err;
 #else
   __set_errno (ENOSYS);
   return -1;
-- 
1.7.0.1


-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]