yann@2437: 2009-07-25 Aurelien Jarno yann@2437: yann@2437: * sysdeps/unix/sysv/linux/kernel-features.h: define yann@2437: __ASSUME_FDATASYNC. yann@2437: * sysdeps/unix/sysv/linux/fdatasync.c: New file. yann@2437: * sysdeps/unix/sysv/linux/Makefile: compile fdatasync.c with yann@2437: -fexceptions. yann@2437: * sysdeps/unix/sysv/linux/syscalls.list: Remove fdatasync. yann@2437: yann@2437: sysdeps/unix/sysv/linux/Makefile | 1 yann@2437: sysdeps/unix/sysv/linux/fdatasync.c | 69 ++++++++++++++++++++++++++++++ yann@2437: sysdeps/unix/sysv/linux/kernel-features.h | 6 ++ yann@2437: sysdeps/unix/sysv/linux/syscalls.list | 1 yann@2437: 4 files changed, 76 insertions(+), 1 deletion(-) yann@2437: yann@2437: diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/Makefile glibc-2.12.1/sysdeps/unix/sysv/linux/Makefile yann@2437: --- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/Makefile 2009-03-02 17:15:13.000000000 +0100 yann@2437: +++ glibc-2.12.1/sysdeps/unix/sysv/linux/Makefile 2009-11-13 00:51:04.000000000 +0100 yann@2437: @@ -20,6 +20,7 @@ yann@2437: setfsuid setfsgid makedev epoll_pwait signalfd \ yann@2437: eventfd eventfd_read eventfd_write yann@2437: yann@2437: +CFLAGS-fdatasync.c = -fexceptions yann@2437: CFLAGS-gethostid.c = -fexceptions yann@2437: yann@2437: sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ yann@2437: diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/fdatasync.c glibc-2.12.1/sysdeps/unix/sysv/linux/fdatasync.c yann@2437: --- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/fdatasync.c 1970-01-01 01:00:00.000000000 +0100 yann@2437: +++ glibc-2.12.1/sysdeps/unix/sysv/linux/fdatasync.c 2009-11-13 00:51:04.000000000 +0100 yann@2437: @@ -0,0 +1,69 @@ yann@2437: +/* fdatasync -- synchronize at least the data part of a file with yann@2437: + the underlying media. Linux version. yann@2437: + yann@2437: + Copyright (C) 2007 Free Software Foundation, Inc. yann@2437: + This file is part of the GNU C Library. yann@2437: + yann@2437: + The GNU C Library is free software; you can redistribute it and/or yann@2437: + modify it under the terms of the GNU Lesser General Public yann@2437: + License as published by the Free Software Foundation; either yann@2437: + version 2.1 of the License, or (at your option) any later version. yann@2437: + yann@2437: + The GNU C Library is distributed in the hope that it will be useful, yann@2437: + but WITHOUT ANY WARRANTY; without even the implied warranty of yann@2437: + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yann@2437: + Lesser General Public License for more details. yann@2437: + yann@2437: + You should have received a copy of the GNU Lesser General Public yann@2437: + License along with the GNU C Library; if not, write to the Free yann@2437: + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA yann@2437: + 02111-1307 USA. */ yann@2437: + yann@2437: +#include yann@2437: +#include yann@2437: + yann@2437: +#include yann@2437: +#include yann@2437: +#include yann@2437: + yann@2437: +#include yann@2437: + yann@2437: +#if defined __NR_fdatasync && !defined __ASSUME_FDATASYNC yann@2437: +static int __have_no_fdatasync; yann@2437: +#endif yann@2437: + yann@2437: +static int yann@2437: +do_fdatasync (int fd) yann@2437: +{ yann@2437: +#ifdef __ASSUME_FDATASYNC yann@2437: + return INLINE_SYSCALL (fdatasync, 1, fd); yann@2437: +#elif defined __NR_fdatasync yann@2437: + if (!__builtin_expect (__have_no_fdatasync, 0)) yann@2437: + { yann@2437: + int result = INLINE_SYSCALL (fdatasync, 1, fd); yann@2437: + if (__builtin_expect (result, 0) != -1 || errno != ENOSYS) yann@2437: + return result; yann@2437: + yann@2437: + __have_no_fdatasync = 1; yann@2437: + } yann@2437: +#endif yann@2437: + return INLINE_SYSCALL (fsync, 1, fd); yann@2437: +} yann@2437: + yann@2437: +int yann@2437: +__fdatasync (int fd) yann@2437: +{ yann@2437: + if (SINGLE_THREAD_P) yann@2437: + return do_fdatasync (fd); yann@2437: + yann@2437: + int oldtype = LIBC_CANCEL_ASYNC (); yann@2437: + yann@2437: + int result = do_fdatasync (fd); yann@2437: + yann@2437: + LIBC_CANCEL_RESET (oldtype); yann@2437: + yann@2437: + return result; yann@2437: +} yann@2437: + yann@2437: +weak_alias (__fdatasync, fdatasync) yann@2437: + yann@2437: diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/kernel-features.h glibc-2.12.1/sysdeps/unix/sysv/linux/kernel-features.h yann@2437: --- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/kernel-features.h 2009-11-13 00:50:45.000000000 +0100 yann@2437: +++ glibc-2.12.1/sysdeps/unix/sysv/linux/kernel-features.h 2009-11-13 00:51:04.000000000 +0100 yann@2437: @@ -459,6 +459,12 @@ yann@2437: # define __ASSUME_FUTEX_LOCK_PI 1 yann@2437: #endif yann@2437: yann@2437: +/* Support for fsyncdata syscall was added in 2.6.22 on alpha, but it yann@2437: + was already present in 2.0 kernels on other architectures. */ yann@2437: +#if (!defined __alpha || __LINUX_KERNEL_VERSION >= 0x020616) yann@2437: +# define __ASSUME_FDATASYNC 1 yann@2437: +#endif yann@2437: + yann@2437: /* Support for utimensat syscall was added in 2.6.22, on SH yann@2437: only after 2.6.22-rc1. */ yann@2437: #if __LINUX_KERNEL_VERSION >= 0x020616 \ yann@2437: diff -durN glibc-2.12.1.orig/sysdeps/unix/sysv/linux/syscalls.list glibc-2.12.1/sysdeps/unix/sysv/linux/syscalls.list yann@2437: --- glibc-2.12.1.orig/sysdeps/unix/sysv/linux/syscalls.list 2008-08-02 01:29:08.000000000 +0200 yann@2437: +++ glibc-2.12.1/sysdeps/unix/sysv/linux/syscalls.list 2009-11-13 00:51:04.000000000 +0100 yann@2437: @@ -11,7 +11,6 @@ yann@2437: epoll_create1 EXTRA epoll_create1 i:i epoll_create1 yann@2437: epoll_ctl EXTRA epoll_ctl i:iiip epoll_ctl yann@2437: epoll_wait EXTRA epoll_wait Ci:ipii epoll_wait yann@2437: -fdatasync - fdatasync Ci:i fdatasync yann@2437: flock - flock i:ii __flock flock yann@2437: fork - fork i: __libc_fork __fork fork yann@2437: get_kernel_syms EXTRA get_kernel_syms i:p get_kernel_syms