Whamcloud - gitweb
LU-4223 utils: fixing loop leaking in utils
[fs/lustre-release.git] / lustre / utils / obdctl.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  */
30 /*
31  * This file is part of Lustre, http://www.lustre.org/
32  * Lustre is a trademark of Sun Microsystems, Inc.
33  *
34  * lustre/utils/obdctl.c
35  *
36  * Author: Peter J. Braam <braam@clusterfs.com>
37  * Author: Phil Schwan <phil@clusterfs.com>
38  */
39
40 #include <stdlib.h>
41 #include <stdio.h>
42
43 #include "obdctl.h"
44 #include <libcfs/libcfsutil.h>
45
46 /* the functions that were in here are now in obd.c */
47
48 static int jt_quit(int argc, char **argv)
49 {
50         int rc = 0;
51         Parser_quit(argc, argv);
52
53         return rc;
54 }
55
56 command_t cmdlist[] = {
57         /* Metacommands */
58         {"--device", jt_opt_device, 0, "--device <devno> <command [args ...]>"},
59         {"--threads", jt_opt_threads, 0,
60          "--threads <threads> <devno> <command [args ...]>"},
61
62         /* Device configuration commands */
63         {"lov_setconfig", jt_obd_lov_setconfig, 0, "configure lov data on MDS "
64          "[usage: lovconfig lov-uuid stripecount, stripesize, pattern, UUID1, [UUID2, ...]"},
65         {"list", jt_obd_list, 0, "list the devices (no args)"},
66         {"newdev", jt_obd_newdev, 0, "set device to a new unused obd (no args)"},
67         {"device", jt_obd_device, 0, "set current device (args device_no name)"},
68         {"name2dev", jt_obd_name2dev, 0,
69          "set device by name [usage: name2dev devname]"},
70         {"attach", jt_obd_attach, 0, "name the type of device (args: type data"},
71         {"setup", jt_obd_setup, 0, "setup device (args: <blkdev> [data]"},
72         {"detach", jt_obd_detach, 0, "detach the current device (arg: )"},
73         {"cleanup", jt_obd_cleanup, 0, "cleanup the current device (arg: )"},
74
75         /* Session commands */
76         {"connect", jt_obd_connect, 0, "connect - get a connection to device"},
77         {"disconnect", jt_obd_disconnect, 0,
78          "disconnect - break connection to device"},
79
80         /* Session operations */
81         {"create", jt_obd_create, 0, "create <count> [mode [verbose]]"},
82         {"destroy", jt_obd_destroy, 0, "destroy <id> [count [verbose]]"},
83         {"getattr", jt_obd_getattr, 0, "getattr <id>"},
84         {"setattr", jt_obd_setattr, 0, "setattr <id> <mode>"},
85         {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
86         {"test_getattr", jt_obd_test_getattr, 0, "test_getattr <count> [verbose [[t]objid]]"},
87         {"test_setattr", jt_obd_test_setattr, 0, "test_setattr <count> [verbose [[t]objid]]"},
88         {"test_brw", jt_obd_test_brw, 0, "test_brw [t]<count> [write [verbose [pages [[t]objid]]]]"},
89         {"dump_ldlm", jt_obd_dump_ldlm, 0, "dump all lock manager state (no args)"},
90
91         /* User interface commands */
92         {"help", Parser_help, 0, "help"},
93         {"exit", jt_quit, 0, "quit"},
94         {"quit", jt_quit, 0, "quit"},
95         {0, 0, 0, NULL}
96 };
97
98
99 int main(int argc, char **argv)
100 {
101         int rc;
102
103         setlinebuf(stdout);
104
105         if (obd_initialize(argc, argv) < 0)
106                 exit(1);
107
108         Parser_init("obdctl > ", cmdlist);
109
110         if (argc > 1) {
111                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
112         } else {
113                 rc = Parser_commands();
114         }
115
116         obd_finalize(argc, argv);
117         return rc;
118 }