-static int jt_attach(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int rc;
-
- IOCINIT(data);
-
- if ( argc != 2 && argc != 3 ) {
- fprintf(stderr, "Usage: %s type [data]\n", argv[0]);
- return 1;
- }
-
- data.ioc_inllen1 = strlen(argv[1]) + 1;
- data.ioc_inlbuf1 = argv[1];
- if ( argc == 3 ) {
- data.ioc_inllen2 = strlen(argv[2]) + 1;
- data.ioc_inlbuf2 = argv[2];
- }
-
- printf("attach len %d addr %p type %s data %s\n", data.ioc_len, buf,
- MKSTR(data.ioc_inlbuf1), MKSTR(data.ioc_inlbuf2));
-
- if (obd_ioctl_pack(&data, &buf, max)) {
- printf("invalid ioctl\n");
- return 1;
- }
- printf("attach len %d addr %p raw %p type %s data %s and %s\n", data.ioc_len, buf, rawbuf,
- MKSTR(data.ioc_inlbuf1), MKSTR(data.ioc_inlbuf2), &buf[516]);
-
- rc = ioctl(fd, OBD_IOC_ATTACH , buf);
- if (rc < 0) {
- printf("Attach: %x %s\n", OBD_IOC_ATTACH, strerror(errno));
- return 1;
- }
- return 0;
-}
-
-static int jt_setup(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int rc;
-
- IOCINIT(data);
-
- if ( argc > 3 ) {
- fprintf(stderr, "Usage: %s [device] [fstype]\n", argv[0]);
- return 1;
- }
-
- if (argc > 1) {
- data.ioc_inllen1 = strlen(argv[1]) + 1;
- data.ioc_inlbuf1 = argv[1];
- data.ioc_dev = strtoul(argv[1], NULL, 0);
- } else {
- data.ioc_dev = -1;
- }
- if ( argc == 3 ) {
- data.ioc_inllen2 = strlen(argv[2]) + 1;
- data.ioc_inlbuf2 = argv[2];
- }
-
- printf("setup len %d addr %p device %s type %s\n", data.ioc_len, buf,
- MKSTR(data.ioc_inlbuf1), MKSTR(data.ioc_inlbuf2));
-
- if (obd_ioctl_pack(&data, &buf, max)) {
- printf("invalid ioctl\n");
- return 1;
- }
- printf("setup len %d addr %p raw %p device %s type %s\n",
- data.ioc_len, buf, rawbuf,
- MKSTR(data.ioc_inlbuf1), MKSTR(data.ioc_inlbuf2));
-
- rc = ioctl(fd, OBD_IOC_SETUP , buf);
- if (rc < 0) {
- printf("setup: %x %s\n", OBD_IOC_SETUP, strerror(errno));
- return 1;
- }
- return 0;
-}
-
-
-static int jt_create(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int num = 1;
- int silent = 0;
- int i;
- int rc;
-
- IOCINIT(data);
- if (argc > 1) {
- num = strtoul(argv[1], NULL, 0);
- } else {
- printf("usage %s num [mode] [silent]\n", argv[0]);
- }
-
- if (argc > 2) {
- data.ioc_obdo1.o_mode = strtoul(argv[2], NULL, 0);
- } else {
- data.ioc_obdo1.o_mode = 0100644;
- }
- data.ioc_obdo1.o_valid = OBD_MD_FLMODE;
-
- if (argc > 3) {
- silent = strtoul(argv[3], NULL, 0);
- }
-
- printf("Creating %d obdos\n", num);
-
- for (i = 0 ; i<num ; i++) {
- rc = ioctl(fd, OBD_IOC_CREATE , &data);
- if (rc < 0) {
- printf("Create: %x %s\n", OBD_IOC_CREATE,
- strerror(errno));
- return 1;
- }
- printf("created obdo %Ld\n", data.ioc_obdo1.o_id);
- }
- return 0;
-}
-
-static int jt_setattr(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int rc;
-
- IOCINIT(data);
- if (argc < 2) {
- printf("usage: %s id mode\n", argv[0]);
- return -1;
- }
-
- data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0);
- data.ioc_obdo1.o_mode = strtoul(argv[2], NULL, 0);
- data.ioc_obdo1.o_valid = OBD_MD_FLMODE;
-
- rc = ioctl(fd, OBD_IOC_SETATTR , &data);
- if (rc < 0) {
- printf("setattr: %x %s\n", OBD_IOC_SETATTR, strerror(errno));
- }
- return rc;
-}
-
-static int jt_destroy(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int rc;
-
- IOCINIT(data);
- if (argc < 1) {
- printf("usage %s id\n", argv[0]);
- }
-
- data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0);
-
- rc = ioctl(fd, OBD_IOC_DESTROY , &data);
- if (rc < 0) {
- printf("setattr: %x %s\n", OBD_IOC_DESTROY, strerror(errno));
- }
- return rc;
-}
-
-static int jt_multi_getattr(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int count, i;
- int rc;
-
- IOCINIT(data);
- if (argc == 2) {
- count = strtoul(argv[1], NULL, 0);
- data.ioc_obdo1.o_valid = 0xffffffff;
- data.ioc_obdo1.o_id = 2;
- printf("getting %d attrs (testing only)\n", count);
- } else {
- printf("usage %s id\n", argv[0]);
- return 0;
- }
-
- for (i = 0 ; i < count; i++) {
- rc = ioctl(fd, OBD_IOC_GETATTR , &data);
- if (rc) {
- printf("Error: %s on i=%d\n", strerror(rc), i);
- break;
- } else {
- printf("attr number %d\n", i);
- }
- }
- return 0;
-}
-
-static int jt_getattr(int argc, char **argv)
-{
- struct obd_ioctl_data data;
- int rc;
-
- IOCINIT(data);
- if (argc == 2) {
- data.ioc_obdo1.o_id = strtoul(argv[1], NULL, 0);
- data.ioc_obdo1.o_valid = 0xffffffff;
- printf("getting attr for %Ld\n", data.ioc_obdo1.o_id);
- } else {
- printf("usage %s id\n", argv[0]);
- return 0;
- }
-
- rc = ioctl(fd, OBD_IOC_GETATTR , &data);
- if (rc) {
- printf("Error: %s\n", strerror(rc));
- } else {
- printf("attr obdo %Ld, mode %o\n", data.ioc_obdo1.o_id,
- data.ioc_obdo1.o_mode);
- }
- return 0;
-}
-
-command_t list[] = {
- {"device", jt_device, 0, "set current device (args device no)"},
- {"attach", jt_attach, 0, "name the typed of device (args: type data"},
- {"setup", jt_setup, 0, "setup device (args: blkdev, data"},
- {"detach", jt_detach, 0, "detach the current device (arg: )"},
- {"cleanup", jt_cleanup, 0, "cleanup the current device (arg: )"},
- {"create", jt_create, 0, "create [count [mode [silent]]]"},
- {"destroy", jt_destroy, 0, "destroy id"},
- {"test_getattr", jt_multi_getattr, 0, "test_getattr count [silent]"},
- {"getattr", jt_getattr, 0, "getattr id"},
- {"setattr", jt_setattr, 0, "setattr id mode"},
- {"connect", jt_connect, 0, "connect - get a connection to device"},
- {"disconnect", jt_disconnect, 0, "disconnect - break connection to device"},
+command_t cmdlist[] = {
+ /* Metacommands */
+ {"--device", jt_opt_device, 0, "--device <devno> <command [args ...]>"},
+ {"--threads", jt_opt_threads, 0,
+ "--threads <threads> <devno> <command [args ...]>"},
+
+ /* Device configuration commands */
+ {"lovconfig", jt_obd_lov_config, 0, "configure lov data on MDS "
+ "[usage: lovconfig lov-uuid stripecount, stripesize, pattern, UUID1, [UUID2, ...]"},
+ {"list", jt_obd_list, 0, "list the devices (no args)"},
+ {"newdev", jt_obd_newdev, 0, "set device to a new unused obd (no args)"},
+ {"device", jt_obd_device, 0, "set current device (args device_no name)"},
+ {"name2dev", jt_obd_name2dev, 0,
+ "set device by name [usage: name2dev devname]"},
+ {"attach", jt_obd_attach, 0, "name the type of device (args: type data"},
+ {"setup", jt_obd_setup, 0, "setup device (args: <blkdev> [data]"},
+ {"detach", jt_obd_detach, 0, "detach the current device (arg: )"},
+ {"cleanup", jt_obd_cleanup, 0, "cleanup the current device (arg: )"},
+
+ /* Session commands */
+ {"connect", jt_obd_connect, 0, "connect - get a connection to device"},
+ {"disconnect", jt_obd_disconnect, 0,
+ "disconnect - break connection to device"},
+
+ /* Session operations */
+ {"create", jt_obd_create, 0, "create [count [mode [verbose]]]"},
+ {"destroy", jt_obd_destroy, 0, "destroy <id>"},
+ {"getattr", jt_obd_getattr, 0, "getattr <id>"},
+ {"setattr", jt_obd_setattr, 0, "setattr <id> <mode>"},
+ {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
+ {"test_getattr", jt_obd_test_getattr, 0, "test_getattr <count> [verbose [objid]]"},
+ {"test_brw", jt_obd_test_brw, 0, "test_brw <count> [write [verbose [pages [objid]]]]"},
+ {"test_ldlm", jt_obd_test_ldlm, 0, "test lock manager (no args)"},
+ {"dump_ldlm", jt_obd_dump_ldlm, 0, "dump all lock manager state (no args)"},
+
+ /* User interface commands */