]>
git.proxmox.com Git - mirror_lxcfs.git/blob - tests/test-read.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #ifndef FUSE_USE_VERSION
8 #define FUSE_USE_VERSION 26
11 #define _FILE_OFFSET_BITS 64
15 #include <sys/types.h>
27 int main(int argc
, char *argv
[]){
29 fprintf(stderr
, "usage: %s <file> <count> [buffer|direct]\n", argv
[0]);
33 read_count
= atoi(argv
[2]);
34 int ret
= 0,sum
= 0, i
= 0, fd
= -1;
35 if(argc
== 4 && strncmp(argv
[3], "direct",6) == 0)
36 fd
= open(file
, O_RDONLY
|O_DIRECT
);
38 fd
= open(file
, O_RDONLY
);
40 while(i
++ < read_count
){
41 memset(buf
, 0, BUFSIZE
);
42 ret
= read(fd
, buf
, BUFSIZE
-1);
44 write(STDOUT_FILENO
, buf
, ret
);
47 printf("======read end======\n");
50 printf("error:%d\n", errno
);
55 printf("======read sum: %d======\n", sum
);