blob: cb53e496b67fda64b463d774105eae585b8d5fe4 [file] [log] [blame]
b.liu9bcf4932024-02-06 17:17:43 +08001#include <stdio.h>
2#include <unistd.h>
3#include <errno.h>
4#include <fcntl.h>
5
6#define BUFF_SIZE 4096
7
8int main(int argc, char *argv[])
9{
b.liub3b923a2024-06-06 15:15:49 +080010 int fd = open("/test.data", O_WRONLY | O_CREAT | O_APPEND, 0666);
b.liu9bcf4932024-02-06 17:17:43 +080011 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