--- /dev/null
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <linux/types.h>
+#include <sys/ioctl.h>
+
+#include "../binject.h"
+
+#define BS 512
+#define DEPTH 1024
+
+static void cmd_set_offset(struct b_user_cmd *cmds, unsigned long *off)
+{
+ int i;
+
+ for (i = 0; i < DEPTH; i++) {
+#if 0
+ cmds[i].offset = lrand48();
+#else
+ cmds[i].offset = *off;
+#endif
+ *off += BS;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ void *buf;
+ struct b_user_cmd c[DEPTH], d[DEPTH];
+ void *r_buf;
+ unsigned long off;
+ int fd, i;
+
+ fd = open("/dev/binject0", O_RDWR);
+ if (fd < 0) {
+ perror("open dev");
+ return 1;
+ }
+
+ if (posix_memalign(&buf, 4096, DEPTH * BS)) {
+ perror("posix_memalign");
+ return 1;
+ }
+
+ for (i = 0; i < DEPTH; i++) {
+ binject_buc_set_magic(&c[i]);
+ c[i].type = B_TYPE_READ;
+ c[i].flags = B_FLAG_NOIDLE;
+ c[i].len = BS;
+ c[i].buf = (unsigned long) buf + i * BS;
+ }
+
+ c[DEPTH - 1].flags |= B_FLAG_UNPLUG;
+
+ off = 0;
+ do {
+ int write_size, read_size;
+
+ cmd_set_offset(c, &off);
+
+ write_size = sizeof(struct b_user_cmd) * DEPTH;
+
+ if (write(fd, c, write_size) != write_size) {
+ perror("write");
+ break;
+ }
+
+ read_size = write_size;
+ r_buf = d;
+ do {
+ int ret;
+
+ ret = read(fd, r_buf, read_size);
+ if (ret < 0) {
+ perror("read");
+ return 1;
+ } else {
+ read_size -= ret;
+ r_buf += ret;
+ }
+ } while (read_size);
+ } while (1);
+
+ return 0;
+}