Current-Users archive

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

PATCH: Relax fdatasync checks to IEEE Std 1003.1-2008

Currently, fdatasync requires a file descriptor open for writing, as
per IEEE Std 1003.1, 2004:
The fildes argument is not a valid file descriptor open for writing.

While, IEEE Std 1003.1-2008 (and later revisions):
The fildes argument is not a valid file descriptor.

It would appear that mongodb (and likely others) rely on this new
behaviour, and we're now carrying a pkgsrc patch:

The attached patch removes the check and updates the manpage. I've
booted it under qemu and run some toy code against it (not an
unpatched mongodb, yet), and it looks fine. Thoughts?

Paul Ripke
"Great minds discuss ideas, average minds discuss events, small minds
 discuss people."
-- Disputed: Often attributed to Eleanor Roosevelt. 1948.
diff --git a/lib/libc/sys/fdatasync.2 b/lib/libc/sys/fdatasync.2
index 3f12119f0dbb..20da609191f5 100644
--- a/lib/libc/sys/fdatasync.2
+++ b/lib/libc/sys/fdatasync.2
@@ -68,7 +68,7 @@ function will fail if:
 .It Bq Er EBADF
 .Fa fd
-argument is not a valid file descriptor open for writing.
+argument is not a valid file descriptor.
 This implementation does not support synchronized I/O for this file.
@@ -93,4 +93,4 @@ and outstanding I/O operations are not guaranteed to have been completed.
 .Fn fdatasync
 function conforms to
-.St -p1003.1b-93 .
+.St -p1003.1-2008 .
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index d51beedbfca9..267dd5bc6365 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -4141,10 +4141,6 @@ sys_fdatasync(struct lwp *l, const struct sys_fdatasync_args *uap, register_t *r
 	/* 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