b.liu | 9bcf493 | 2024-02-06 17:17:43 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <errno.h> |
| 4 | #include <fcntl.h> |
| 5 | |
| 6 | #define BUFF_SIZE 4096 |
| 7 | |
| 8 | int main(int argc, char *argv[]) |
| 9 | { |
b.liu | b3b923a | 2024-06-06 15:15:49 +0800 | [diff] [blame^] | 10 | int fd = open("/test.data", O_WRONLY | O_CREAT | O_APPEND, 0666); |
b.liu | 9bcf493 | 2024-02-06 17:17:43 +0800 | [diff] [blame] | 11 | if(fd < 0) { |
| 12 | printf("open() fail:%d", errno); |
| 13 | return -1; |
| 14 | } |
| 15 | |
| 16 | char buff[BUFF_SIZE]; |
| 17 | while(1) { |
| 18 | if(write(fd, buff, BUFF_SIZE) < 0) { |
| 19 | printf("write() fail:%d", errno); |
| 20 | break; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | close(fd); |
| 25 | return 0; |
| 26 | } |
| 27 | |