2 * Copyright (C) 2001 Cluster File Systems, Inc.
4 * This code is issued under the GNU General Public License.
5 * See the file COPYING in this distribution
12 #include <sys/ioctl.h>
14 #include <asm/statfs.h>
17 #define OBD_IOC_CREATE _IOR('f', 3, long)
18 #define OBD_IOC_SETUP _IOW('f', 4, long)
19 #define OBD_IOC_SYNC _IOR('f', 16, long)
20 #define OBD_IOC_DESTROY _IOW('f', 6, long)
21 #define OBD_IOC_STATFS _IORW('f', 15, long)
23 #define LOOP_DEVICE "/dev/loop0"
24 #define OBD_DEVICE "/dev/obd"
26 int main (int argc, char * argv[])
34 printf("syntax: %s command [argument]\n", argv[0]);
35 printf("Where command is one of \"setup\", \"create\", \"destroy\", or \"sync\".\n");
38 if (stat(LOOP_DEVICE, &stat_buf)) {
39 printf("Couldn't stat(" LOOP_DEVICE ").\n");
42 printf("Device: %u\n", (unsigned int) stat_buf.st_rdev);
44 fd = open (OBD_DEVICE, O_RDONLY);
46 printf("Couldn't open " OBD_DEVICE ".\n");
50 if (!strcmp(argv[1], "setup")) {
51 rc = ioctl(fd, OBD_IOC_SETUP, &stat_buf.st_rdev);
52 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
53 } else if (!strcmp(argv[1], "create")) {
57 printf("create requires a nonzero argument.\n");
63 printf("create requires a nonzero argument.\n");
66 printf("creating %d objects...\n", iter);
68 for (i = 0; i < iter; i++) {
69 if ((rc = ioctl(fd, OBD_IOC_CREATE, &err))) {
70 fprintf(stderr, "Error; aborting.\n");
73 if ((rc = ioctl(fd, OBD_IOC_DESTROY, &err))) {
74 fprintf(stderr, "Error; aborting.\n");
78 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
80 } else if (!strcmp(argv[1], "sync")) {
81 rc = ioctl(fd, OBD_IOC_SYNC, &err);
82 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
84 } else if (!strcmp(argv[1], "destroy")) {
88 printf("destroy requires a nonzero inode number.\n");
94 printf("destroy requires a nonzero inode number.\n");
98 rc = ioctl(fd, OBD_IOC_DESTROY, &ino);
99 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
101 printf("Invalid command, run with no arguments for help.\n");