From 94ce799f82a1d3b7453b1942016f91334c838b85 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 29 Oct 2012 19:35:56 +0100 Subject: Hurd: fix fdatasync/fsync if the fd does not support file_sync Handle the case of the fd port implementing a stub (EOPNOTSUPP), properly returning EINVAL. --- sysdeps/mach/hurd/fdatasync.c | 8 +++++++- sysdeps/mach/hurd/fsync.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/mach/hurd/fdatasync.c b/sysdeps/mach/hurd/fdatasync.c index 19d7a4a58a..22c1d103d4 100644 --- a/sysdeps/mach/hurd/fdatasync.c +++ b/sysdeps/mach/hurd/fdatasync.c @@ -26,6 +26,12 @@ fdatasync (int fd) { error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 1)); if (err) - return __hurd_dfail (fd, err); + { + if (err == EOPNOTSUPP) + /* If the file descriptor does not support sync, return EINVAL + as POSIX specifies. */ + err = EINVAL; + return __hurd_dfail (fd, err); + } return 0; } diff --git a/sysdeps/mach/hurd/fsync.c b/sysdeps/mach/hurd/fsync.c index a474c8a356..fe3e044a3a 100644 --- a/sysdeps/mach/hurd/fsync.c +++ b/sysdeps/mach/hurd/fsync.c @@ -27,6 +27,12 @@ fsync (fd) { error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 0)); if (err) - return __hurd_dfail (fd, err); + { + if (err == EOPNOTSUPP) + /* If the file descriptor does not support sync, return EINVAL + as POSIX specifies. */ + err = EINVAL; + return __hurd_dfail (fd, err); + } return 0; } -- cgit 1.4.1