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