changeset 5024:84d44b28471b

6318591 fdatasync(2) needs to set errno to EINVAL if fd is bound to a special file. 6320017 fsync(2) needs to set errno to EINVAL if fd is bound to a special file(such as pipe).
author vk210190
date Tue, 11 Sep 2007 07:05:48 -0700
parents e0c678e511a7
children cc9a15b4f5ed
files usr/src/lib/brand/lx/lx_brand/common/file.c
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/brand/lx/lx_brand/common/file.c	Tue Sep 11 04:26:06 2007 -0700
+++ b/usr/src/lib/brand/lx/lx_brand/common/file.c	Tue Sep 11 07:05:48 2007 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -177,12 +177,26 @@
 int
 lx_fsync(uintptr_t fd)
 {
+	int fildes = (int)fd;
+	struct stat64 statbuf;
+
+	if ((fstat64(fildes, &statbuf) == 0) &&
+	    (S_ISCHR(statbuf.st_mode) || S_ISFIFO(statbuf.st_mode)))
+		return (-EINVAL);
+
 	return (fsync((int)fd) ? -errno : 0);
 }
 
 int
 lx_fdatasync(uintptr_t fd)
 {
+	int fildes = (int)fd;
+	struct stat64 statbuf;
+
+	if ((fstat64(fildes, &statbuf) == 0) &&
+	    (S_ISCHR(statbuf.st_mode) || S_ISFIFO(statbuf.st_mode)))
+		return (-EINVAL);
+
 	return (fdatasync((int)fd) ? -errno : 0);
 }