Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / test_get_blkdev_size.cc
1 #include <stdio.h>
2 #include <errno.h>
3 #include <string.h>
4 #include <fcntl.h>
5 #include <inttypes.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include "include/uuid.h"
9 #include "common/blkdev.h"
10
11 int main(int argc, char **argv)
12 {
13         int fd, ret;
14         int64_t size;
15
16         if (argc != 2) {
17                 fprintf(stderr, "usage: %s <blkdev>\n", argv[0]);
18                 return -1;
19         }
20
21         fd = open(argv[1], O_RDONLY);
22         if (fd < 0) {
23                 perror("open");
24                 return -1;
25         }
26
27         ret = get_block_device_size(fd, &size);
28         if (ret < 0) {
29                 fprintf(stderr, "get_block_device_size: %s\n", strerror(-ret));
30                 return -1;
31         }
32
33         fprintf(stdout, "%" PRId64, size);
34
35         return 0;
36 }