Re: [PATCH] read/write: documentation of limits v3

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

 



* Shawn Landden <shawn@xxxxxxx>, 2019-05-06, 08:06:
--- a/man2/write.2
+++ b/man2/write.2
@@ -190,10 +190,18 @@ flag, and either the address specified in
.IR buf ,
the value specified in
.IR count ,
or the file offset is not suitably aligned.
.TP
+.B EINVAL
+.\" MAX_RW_COUNT in include/linux/fs.h
+The write amount is greater than
+.B MAX_RW_COUNT,
+which is
+.B INT_MAX
+rounded down to the page size (INT_MAX & ~PAGE_MASK).
+.TP

I can't reproduce this. For me, write() behaves as it is documented in another part of this man page:

"On Linux, write() (and similar system calls) will transfer at most 0x7ffff000 (2,147,479,552) bytes, returning the number of bytes actually transferred. (This is true on both 32-bit and 64-bit systems.)"

I've attached the program that I used for testing.

--
Jakub Wilk
#include <fcntl.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	int fd = open("/dev/zero", O_RDWR);
	if (fd < 0) {
		perror("/dev/zero");
		return 1;
	}
	void *mem = mmap(NULL, INT_MAX, PROT_READ, MAP_PRIVATE, fd, 0);
	if (mem == MAP_FAILED) {
		perror("mmap()");
		return 1;
	}
	int rc = write(fd, mem, INT_MAX);
	if (rc < 0) {
		perror("write()");
		return 1;
	}
	printf("0x%x bytes written\n", rc);
}

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux