Whamcloud - gitweb
Branch HEAD
[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 #include <stdlib.h>
26 #include <stdio.h>
27
28 #include "obdctl.h"
29 #include "parser.h"
30
31 /* the functions that were in here are now in obd.c */
32
33 static int jt_quit(int argc, char **argv)
34 {
35         int rc = 0;
36         Parser_quit(argc, argv);
37
38         return rc;
39 }
40
41 command_t cmdlist[] = {
42         /* Metacommands */
43         {"--device", jt_opt_device, 0, "--device <devno> <command [args ...]>"},
44         {"--threads", jt_opt_threads, 0,
45          "--threads <threads> <devno> <command [args ...]>"},
46
47         /* Device configuration commands */
48         {"lov_setconfig", jt_obd_lov_setconfig, 0, "configure lov data on MDS "
49          "[usage: lovconfig lov-uuid stripecount, stripesize, pattern, UUID1, [UUID2, ...]"},
50         {"list", jt_obd_list, 0, "list the devices (no args)"},
51         {"newdev", jt_obd_newdev, 0, "set device to a new unused obd (no args)"},
52         {"device", jt_obd_device, 0, "set current device (args device_no name)"},
53         {"name2dev", jt_obd_name2dev, 0,
54          "set device by name [usage: name2dev devname]"},
55         {"attach", jt_obd_attach, 0, "name the type of device (args: type data"},
56         {"setup", jt_obd_setup, 0, "setup device (args: <blkdev> [data]"},
57         {"detach", jt_obd_detach, 0, "detach the current device (arg: )"},
58         {"cleanup", jt_obd_cleanup, 0, "cleanup the current device (arg: )"},
59
60         /* Session commands */
61         {"connect", jt_obd_connect, 0, "connect - get a connection to device"},
62         {"disconnect", jt_obd_disconnect, 0,
63          "disconnect - break connection to device"},
64
65         /* Session operations */
66         {"create", jt_obd_create, 0, "create <count> [mode [verbose]]"},
67         {"destroy", jt_obd_destroy, 0, "destroy <id> [count [verbose]]"},
68         {"getattr", jt_obd_getattr, 0, "getattr <id>"},
69         {"setattr", jt_obd_setattr, 0, "setattr <id> <mode>"},
70         {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
71         {"test_getattr", jt_obd_test_getattr, 0, "test_getattr <count> [verbose [[t]objid]]"},
72         {"test_setattr", jt_obd_test_setattr, 0, "test_setattr <count> [verbose [[t]objid]]"},
73         {"test_brw", jt_obd_test_brw, 0, "test_brw [t]<count> [write [verbose [pages [[t]objid]]]]"},
74         {"dump_ldlm", jt_obd_dump_ldlm, 0, "dump all lock manager state (no args)"},
75
76         /* User interface commands */
77         {"help", Parser_help, 0, "help"},
78         {"exit", jt_quit, 0, "quit"},
79         {"quit", jt_quit, 0, "quit"},
80         {0, 0, 0, NULL}
81 };
82
83
84 int main(int argc, char **argv)
85 {
86         int rc;
87
88         setlinebuf(stdout);
89
90         if (obd_initialize(argc, argv) < 0)
91                 exit(1);
92
93         Parser_init("obdctl > ", cmdlist);
94
95         if (argc > 1) {
96                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
97         } else {
98                 rc = Parser_commands();
99         }
100
101         obd_finalize(argc, argv);
102         return rc;
103 }