-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdio.c
49 lines (40 loc) · 951 Bytes
/
dio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* dio.c: Probe XFS XFS_IOC_DIOINFO direct IO parameters. */
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <xfs/xfs.h>
static void
dio(const char * path)
{
struct dioattr attr = {0};
int fd = open(path, O_DIRECT | O_RDONLY);
if (fd == -1) {
fprintf(stderr, "open(%s): %s\n", path, strerror(errno));
return;
}
if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, &attr) == -1) {
perror("xfsctl");
close(fd);
return;
}
close(fd);
printf("%s\n", path);
printf("\td_mem %d\n", attr.d_mem);
printf("\td_miniosz %d\n", attr.d_miniosz);
printf("\td_maxiosz %d\n", attr.d_maxiosz);
}
int
main(int argc, const char ** argv)
{
for (int i = 1; i < argc; ++i) {
dio(argv[i]);
}
return EX_OK;
}