toaruos/apps/block-dev-stats.c

33 lines
589 B
C

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int main(int argc, char * argv[]) {
if (argc < 2) return 1;
int fd = open(argv[1],O_RDONLY);
if (fd < 0) {
fprintf(stderr, "open: %d\n", fd);
return 2;
}
uint64_t stats[4] = {-1};
long res = ioctl(fd, 0x2A01234UL, &stats);
if (res < 0) {
fprintf(stderr, "ioctl: %ld\n", res);
return 3;
}
fprintf(stderr, "hits:\t%zu\n", stats[0]);
fprintf(stderr, "misses:\t%zu\n", stats[1]);
fprintf(stderr, "evicts:\t%zu\n", stats[2]);
fprintf(stderr, "writes:\t%zu\n", stats[3]);
return 0;
}