move blk out of the way into masters-pmf, because I'm the only real user for now
[lttv.git] / trunk / masters-pmf / blk / blktrace_start.c
diff --git a/trunk/masters-pmf/blk/blktrace_start.c b/trunk/masters-pmf/blk/blktrace_start.c
new file mode 100644 (file)
index 0000000..651a076
--- /dev/null
@@ -0,0 +1,59 @@
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "blktrace_api.h"
+
+int start(int fd)
+{
+       struct blk_user_trace_setup buts;
+
+       memset(&buts, 0, sizeof(buts));
+//     buts.buf_size = 512*1024;
+//     buts.buf_nr = 4;
+//     buts.act_mask = ~0;
+
+       if (ioctl(fd, BLKTRACESETUP, &buts) < 0) {
+               perror("BLKTRACESETUP");
+               return 1;
+       }
+
+       return 0;
+}
+
+int stop(int fd)
+{
+       ioctl(fd, BLKTRACESTOP);
+       if(ioctl(fd, BLKTRACETEARDOWN) < 0)
+               perror("BLKTRACETEARDOWN");
+
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       int fd;
+
+       if(argc < 3) {
+               fprintf(stderr, "usage: --start|--stop %s BLKDEV\n", argv[0]);
+               return 1;
+       }
+
+       fd = open(argv[2], O_RDONLY | O_NONBLOCK);
+       if (fd < 0) {
+               perror(argv[0]);
+               return 1;
+       }
+
+       if(!strcmp("--start", argv[1]))
+               start(fd);
+       else if(!strcmp("--stop", argv[1]))
+               stop(fd);
+
+       close(fd);
+
+       return 0;
+}
This page took 0.037425 seconds and 4 git commands to generate.