-
Notifications
You must be signed in to change notification settings - Fork 1
/
replay.c
47 lines (39 loc) · 910 Bytes
/
replay.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
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 Park Ju Hyung
*/
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
struct cheeze_req_user {
int id;
int op;
unsigned int pos; // sector_t
unsigned int len;
} __attribute__((aligned(8), packed));
#define TRACE_TARGET "/trace"
int main() {
int dumpfd;
unsigned int i;
uint32_t crc;
struct cheeze_req_user ureq;
dumpfd = open(TRACE_TARGET, O_RDONLY);
if (dumpfd < 0) {
perror("Failed to open " TRACE_TARGET);
return 1;
}
while (read(dumpfd, &ureq, sizeof(ureq)) == sizeof(ureq)) {
printf("id=%d\n op=%d\n pos=%u\n len=%u\n\n", ureq.id, ureq.op, ureq.pos, ureq.len);
if (ureq.len) {
printf(" crc {\n");
for (i = 0; i < ureq.len; i += 4096) {
read(dumpfd, &crc, sizeof(crc));
printf(" 0x%x,\n", crc);
}
printf(" }\n");
}
}
close(dumpfd);
return 0;
}