7 #include <asm/statfs.h>
10 #define OBD_IOC_CREATE _IOR('f', 3, long)
11 #define OBD_IOC_SETUP _IOW('f', 4, long)
12 #define OBD_IOC_SYNC _IOR('f', 16, long)
13 #define OBD_IOC_DESTROY _IOW('f', 6, long)
14 #define OBD_IOC_STATFS _IORW('f', 15, long)
16 #define LOOP_DEVICE "/dev/loop0"
17 #define OBD_DEVICE "/dev/obd"
19 int main (int argc, char * argv[])
27 printf("syntax: %s command [argument]\n", argv[0]);
28 printf("Where command is one of \"setup\", \"create\", \"destroy\", or \"sync\".\n");
31 if (stat(LOOP_DEVICE, &stat_buf)) {
32 printf("Couldn't stat(" LOOP_DEVICE ").\n");
35 printf("Device: %u\n", (unsigned int) stat_buf.st_rdev);
37 fd = open (OBD_DEVICE, O_RDONLY);
39 printf("Couldn't open " OBD_DEVICE ".\n");
43 if (!strcmp(argv[1], "setup")) {
44 rc = ioctl(fd, OBD_IOC_SETUP, &stat_buf.st_rdev);
45 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
46 } else if (!strcmp(argv[1], "create")) {
50 printf("create requires a nonzero argument.\n");
56 printf("create requires a nonzero argument.\n");
59 printf("creating %d objects...\n", iter);
61 for (i = 0; i < iter; i++) {
62 if ((rc = ioctl(fd, OBD_IOC_CREATE, &err))) {
63 fprintf(stderr, "Error; aborting.\n");
66 if ((rc = ioctl(fd, OBD_IOC_DESTROY, &err))) {
67 fprintf(stderr, "Error; aborting.\n");
71 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
73 } else if (!strcmp(argv[1], "sync")) {
74 rc = ioctl(fd, OBD_IOC_SYNC, &err);
75 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
77 } else if (!strcmp(argv[1], "destroy")) {
81 printf("destroy requires a nonzero inode number.\n");
87 printf("destroy requires a nonzero inode number.\n");
91 rc = ioctl(fd, OBD_IOC_DESTROY, &ino);
92 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
94 printf("Invalid command, run with no arguments for help.\n");