block-dev-stats: Test tool for ongoing ata rewrite

This commit is contained in:
K. Lange 2021-11-15 21:52:16 +09:00
parent cc31ab9244
commit 8a643583bf
1 changed files with 32 additions and 0 deletions

32
apps/block-dev-stats.c Normal file
View File

@ -0,0 +1,32 @@
#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;
}