]>
git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test-read.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 #include <sys/types.h>
23 int main(int argc
, char *argv
[]){
25 fprintf(stderr
, "usage: %s <file> <count> [buffer|direct]\n", argv
[0]);
29 read_count
= atoi(argv
[2]);
30 int ret
= 0,sum
= 0, i
= 0, fd
= -1;
31 if(argc
== 4 && strncmp(argv
[3], "direct",6) == 0)
32 fd
= open(file
, O_RDONLY
|O_DIRECT
);
34 fd
= open(file
, O_RDONLY
);
36 while(i
++ < read_count
){
37 memset(buf
, 0, BUFSIZE
);
38 ret
= read(fd
, buf
, BUFSIZE
-1);
40 write(STDOUT_FILENO
, buf
, ret
);
43 printf("======read end======\n");
46 printf("error:%d\n", errno
);
51 printf("======read sum: %d======\n", sum
);