Whamcloud - gitweb
catch extra args without dashes
[fs/lustre-release.git] / lustre / utils / obdctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *   Author: Peter J. Braam <braam@clusterfs.com>
6  *   Author: Phil Schwan <phil@clusterfs.com>
7  *
8  *   This file is part of Lustre, http://www.lustre.org.
9  *
10  *   Lustre is free software; you can redistribute it and/or
11  *   modify it under the terms of version 2 of the GNU General Public
12  *   License as published by the Free Software Foundation.
13  *
14  *   Lustre is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   along with Lustre; if not, write to the Free Software
21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  */
24
25
26 #include <stdlib.h>
27 #include <stdio.h>
28
29 #include "obdctl.h"
30 #include "parser.h"
31
32 /* the functions that were in here are now in obd.c */
33
34 static int jt_quit(int argc, char **argv)
35 {
36         int rc = 0;
37         Parser_quit(argc, argv);
38
39         return rc;
40 }
41
42 command_t cmdlist[] = {
43         /* Metacommands */
44         {"--device", jt_opt_device, 0, "--device <devno> <command [args ...]>"},
45         {"--threads", jt_opt_threads, 0,
46          "--threads <threads> <devno> <command [args ...]>"},
47
48         /* Device configuration commands */
49         {"lov_setconfig", jt_obd_lov_setconfig, 0, "configure lov data on MDS "
50          "[usage: lovconfig lov-uuid stripecount, stripesize, pattern, UUID1, [UUID2, ...]"},
51         {"list", jt_obd_list, 0, "list the devices (no args)"},
52         {"newdev", jt_obd_newdev, 0, "set device to a new unused obd (no args)"},
53         {"device", jt_obd_device, 0, "set current device (args device_no name)"},
54         {"name2dev", jt_obd_name2dev, 0,
55          "set device by name [usage: name2dev devname]"},
56         {"attach", jt_obd_attach, 0, "name the type of device (args: type data"},
57         {"setup", jt_obd_setup, 0, "setup device (args: <blkdev> [data]"},
58         {"detach", jt_obd_detach, 0, "detach the current device (arg: )"},
59         {"cleanup", jt_obd_cleanup, 0, "cleanup the current device (arg: )"},
60
61         /* Session commands */
62         {"connect", jt_obd_connect, 0, "connect - get a connection to device"},
63         {"disconnect", jt_obd_disconnect, 0,
64          "disconnect - break connection to device"},
65
66         /* Session operations */
67         {"create", jt_obd_create, 0, "create <count> [mode [verbose]]"},
68         {"destroy", jt_obd_destroy, 0, "destroy <id> [count [verbose]]"},
69         {"getattr", jt_obd_getattr, 0, "getattr <id>"},
70         {"setattr", jt_obd_setattr, 0, "setattr <id> <mode>"},
71         {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
72         {"test_getattr", jt_obd_test_getattr, 0, "test_getattr <count> [verbose [[t]objid]]"},
73         {"test_setattr", jt_obd_test_setattr, 0, "test_setattr <count> [verbose [[t]objid]]"},
74         {"test_brw", jt_obd_test_brw, 0, "test_brw [t]<count> [write [verbose [pages [[t]objid]]]]"},
75         {"dump_ldlm", jt_obd_dump_ldlm, 0, "dump all lock manager state (no args)"},
76
77         /* User interface commands */
78         {"help", Parser_help, 0, "help"},
79         {"exit", jt_quit, 0, "quit"},
80         {"quit", jt_quit, 0, "quit"},
81         {0, 0, 0, NULL}
82 };
83
84
85 int main(int argc, char **argv)
86 {
87         int rc;
88
89         setlinebuf(stdout);
90
91         if (obd_initialize(argc, argv) < 0)
92                 exit(1);
93
94         Parser_init("obdctl > ", cmdlist);
95
96         if (argc > 1) {
97                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
98         } else {
99                 rc = Parser_commands();
100         }
101
102         obd_finalize(argc, argv);
103         return rc;
104 }