1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Author: SeongJae Park <sj@kernel.org> 4 */ 5 6 #include <fcntl.h> 7 #include <stdlib.h> 8 #include <unistd.h> 9 #include <stdio.h> 10 11 void write_read_with_huge_count(char *file) 12 { 13 int filedesc = open(file, O_RDWR); 14 char buf[25]; 15 int ret; 16 17 printf("%s %s\n", __func__, file); 18 if (filedesc < 0) { 19 fprintf(stderr, "failed opening %s\n", file); 20 exit(1); 21 } 22 23 write(filedesc, "", 0xfffffffful); 24 perror("after write: "); 25 ret = read(filedesc, buf, 0xfffffffful); 26 perror("after read: "); 27 close(filedesc); 28 } 29 30 int main(int argc, char *argv[]) 31 { 32 if (argc != 2) { 33 fprintf(stderr, "Usage: %s <file>\n", argv[0]); 34 exit(1); 35 } 36 write_read_with_huge_count(argv[1]); 37 38 return 0; 39 } 40