svn commit: r232494 - head/sys/kern

Konstantin Belousov kib at FreeBSD.org
Sun Mar 4 14:55:38 UTC 2012


Author: kib
Date: Sun Mar  4 14:55:37 2012
New Revision: 232494
URL: http://svn.freebsd.org/changeset/base/232494

Log:
  Instead of incomplete handling of read(2)/write(2) return values that
  does not fit into registers, declare that we do not support this case
  using CTASSERT(), and remove endianess-unsafe code to split return value
  into td_retval.
  
  While there, change the style of the sysctl debug.iosize_max_clamp
  definition.
  
  Requested by:	bde
  MFC after:	3 weeks

Modified:
  head/sys/kern/sys_generic.c

Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c	Sun Mar  4 14:51:42 2012	(r232493)
+++ head/sys/kern/sys_generic.c	Sun Mar  4 14:55:37 2012	(r232494)
@@ -75,8 +75,14 @@ __FBSDID("$FreeBSD$");
 #include <security/audit/audit.h>
 
 int iosize_max_clamp = 1;
-SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW, &iosize_max_clamp, 0,
-    "Clamp max i/o size to INT_MAX");
+SYSCTL_INT(_debug, OID_AUTO, iosize_max_clamp, CTLFLAG_RW,
+    &iosize_max_clamp, 0, "Clamp max i/o size to INT_MAX");
+/*
+ * Assert that the return value of read(2) and write(2) syscalls fits
+ * into a register.  If not, an architecture will need to provide the
+ * usermode wrappers to reconstruct the result.
+ */
+CTASSERT(sizeof(register_t) >= sizeof(size_t));
 
 static MALLOC_DEFINE(M_IOCTLOPS, "ioctlops", "ioctl data buffer");
 static MALLOC_DEFINE(M_SELECT, "select", "select() buffer");
@@ -338,12 +344,7 @@ dofileread(td, fd, fp, auio, offset, fla
 		ktrgenio(fd, UIO_READ, ktruio, error);
 	}
 #endif
-#if SSIZE_MAX > LONG_MAX
-	td->td_retval[1] = cnt >> (sizeof(register_t) * CHAR_BIT);
-	td->td_retval[0] = cnt;
-#else
 	td->td_retval[0] = cnt;
-#endif
 	return (error);
 }
 
@@ -555,12 +556,7 @@ dofilewrite(td, fd, fp, auio, offset, fl
 		ktrgenio(fd, UIO_WRITE, ktruio, error);
 	}
 #endif
-#if SSIZE_MAX > LONG_MAX
-	td->td_retval[1] = cnt >> (sizeof(register_t) * CHAR_BIT);
-	td->td_retval[0] = cnt;
-#else
 	td->td_retval[0] = cnt;
-#endif
 	return (error);
 }
 


More information about the svn-src-all mailing list