Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Relax fdatasync restriction that fd be writable



details:   https://anonhg.NetBSD.org/src/rev/a2dffca7b644
branches:  trunk
changeset: 746232:a2dffca7b644
user:      gdt <gdt%NetBSD.org@localhost>
date:      Wed Mar 25 18:08:34 2020 +0000

description:
Relax fdatasync restriction that fd be writable

The restriction that a fd passed to fdatasync(2) must be writable was
added in 2003 in order to comply with POSIX.  Since then, POSIX has
removed that requirement, and POSIX-valid programs have been therefore
encountering errors on NetBSD.

Patch by Paul Ripke after discussion on netbsd-users.  Issue
discovered with pkgsrc/databases/mongodb3 as used by pkgsrc/net/unifi.

diffstat:

 lib/libc/sys/fdatasync.2 |   6 +++---
 sys/kern/vfs_syscalls.c  |  11 +++--------
 2 files changed, 6 insertions(+), 11 deletions(-)

diffs (63 lines):

diff -r 8ca9ff28d420 -r a2dffca7b644 lib/libc/sys/fdatasync.2
--- a/lib/libc/sys/fdatasync.2  Wed Mar 25 17:13:49 2020 +0000
+++ b/lib/libc/sys/fdatasync.2  Wed Mar 25 18:08:34 2020 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: fdatasync.2,v 1.16 2008/04/30 13:10:51 martin Exp $
+.\"    $NetBSD: fdatasync.2,v 1.17 2020/03/25 18:08:34 gdt Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -68,7 +68,7 @@
 .It Bq Er EBADF
 The
 .Fa fd
-argument is not a valid file descriptor open for writing.
+argument is not a valid file descriptor.
 .It Bq Er EINVAL
 This implementation does not support synchronized I/O for this file.
 .It Bq Er ENOSYS
@@ -93,4 +93,4 @@
 The
 .Fn fdatasync
 function conforms to
-.St -p1003.1b-93 .
+.St -p1003.1-2008 .
diff -r 8ca9ff28d420 -r a2dffca7b644 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Wed Mar 25 17:13:49 2020 +0000
+++ b/sys/kern/vfs_syscalls.c   Wed Mar 25 18:08:34 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.543 2020/03/03 19:55:16 christos Exp $      */
+/*     $NetBSD: vfs_syscalls.c,v 1.544 2020/03/25 18:08:34 gdt Exp $   */
 
 /*-
  * Copyright (c) 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.543 2020/03/03 19:55:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.544 2020/03/25 18:08:34 gdt Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -4059,8 +4059,7 @@
  * Sync a range of file data.  API modeled after that found in AIX.
  *
  * FDATASYNC indicates that we need only save enough metadata to be able
- * to re-read the written data.  Note we duplicate AIX's requirement that
- * the file be open for writing.
+ * to re-read the written data.
  */
 /* ARGSUSED */
 int
@@ -4141,10 +4140,6 @@
        /* fd_getvnode() will use the descriptor for us */
        if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
                return (error);
-       if ((fp->f_flag & FWRITE) == 0) {
-               fd_putfile(SCARG(uap, fd));
-               return (EBADF);
-       }
        vp = fp->f_vnode;
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_FSYNC(vp, fp->f_cred, FSYNC_WAIT|FSYNC_DATAONLY, 0, 0);



Home | Main Index | Thread Index | Old Index