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>
16 #include <linux/lustre_idl.h>
18 #define LOOP_DEVICE "/dev/loop0"
19 #define OBD_DEVICE "/dev/obd"
21 int main (int argc, char * argv[])
29 printf("syntax: %s command [argument]\n", argv[0]);
30 printf("Where command is one of \"setup\", \"create\", \"destroy\", or \"sync\".\n");
33 if (stat(LOOP_DEVICE, &stat_buf)) {
34 printf("Couldn't stat(" LOOP_DEVICE ").\n");
37 printf("Device: %u\n", (unsigned int) stat_buf.st_rdev);
39 fd = open (OBD_DEVICE, O_RDONLY);
41 printf("Couldn't open " OBD_DEVICE ".\n");
45 if (!strcmp(argv[1], "setup")) {
46 rc = ioctl(fd, OBD_IOC_SETUP, &stat_buf.st_rdev);
47 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
48 } else if (!strcmp(argv[1], "create")) {
52 printf("create requires a nonzero argument.\n");
58 printf("create requires a nonzero argument.\n");
61 printf("creating %d objects...\n", iter);
63 for (i = 0; i < iter; i++) {
64 if ((rc = ioctl(fd, OBD_IOC_CREATE, &err))) {
65 fprintf(stderr, "Error; aborting.\n");
68 if ((rc = ioctl(fd, OBD_IOC_DESTROY, &err))) {
69 fprintf(stderr, "Error; aborting.\n");
73 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
75 } else if (!strcmp(argv[1], "sync")) {
76 rc = ioctl(fd, OBD_IOC_SYNC, &err);
77 fprintf(stderr, "rc = %d, errno = %d, err = %d\n",
79 } else if (!strcmp(argv[1], "destroy")) {
83 printf("destroy requires a nonzero inode number.\n");
89 printf("destroy requires a nonzero inode number.\n");
93 rc = ioctl(fd, OBD_IOC_DESTROY, &ino);
94 fprintf(stderr, "rc = %d, errno = %d\n", rc, errno);
96 printf("Invalid command, run with no arguments for help.\n");