Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / utils / lctl.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  *   Author: Robert Read <rread@clusterfs.com>
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
11  *   Lustre is free software; you can redistribute it and/or
12  *   modify it under the terms of version 2 of the GNU General Public
13  *   License as published by the Free Software Foundation.
14  *
15  *   Lustre is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with Lustre; if not, write to the Free Software
22  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  */
25
26
27
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <errno.h>
34 #include <portals/ptlctl.h>
35 #include "obdctl.h"
36 #include "parser.h"
37
38 static int jt_quit(int argc, char **argv) {
39         Parser_quit(argc, argv);
40         return 0;
41 }
42
43 static int jt_noop(int argc, char **argv) {
44         return 0;
45 }
46
47 static int jt_opt_ignore_errors(int argc, char **argv) {
48         Parser_ignore_errors(1);
49         return 0;
50 }
51
52 #include <linux/lustre_audit.h>
53
54 static int parse_audit_ops(char * str, __u64 * mask)
55 {
56         char * op = strtok(str, ",");
57         int rc = 0;
58         
59         while (op) {
60                 if (!strcmp(op, "all")) {
61                         *mask |= AUDIT_ALL_OPS;
62                         break;
63                 }
64                 else if (!strcmp(op,"none")) {
65                         *mask &= ~AUDIT_ALL_OPS;
66                 }
67                 else if (!strcmp(op,"create"))
68                         SET_AUDIT_OP((*mask), AUDIT_CREATE);
69                 else if (!strcmp(op,"link"))
70                         SET_AUDIT_OP((*mask), AUDIT_LINK);
71                 else if (!strcmp(op,"delete"))
72                         SET_AUDIT_OP((*mask), AUDIT_UNLINK);
73                 else if (!strcmp(op,"rename"))
74                         SET_AUDIT_OP((*mask), AUDIT_RENAME);
75                 else if (!strcmp(op,"read")) {
76                         SET_AUDIT_OP((*mask), AUDIT_READ);
77                         SET_AUDIT_OP((*mask), AUDIT_MMAP);
78                 }
79                 else if (!strcmp(op,"write"))
80                         SET_AUDIT_OP((*mask), AUDIT_WRITE);
81                 else if (!strcmp(op,"open"))
82                         SET_AUDIT_OP((*mask), AUDIT_OPEN);
83                 else if (!strcmp(op,"stat"))
84                         SET_AUDIT_OP((*mask), AUDIT_STAT);
85                 else if (!strcmp(op,"readdir"))
86                         SET_AUDIT_OP((*mask), AUDIT_READDIR);
87                 else if (!strcmp(op,"readlink"))
88                         SET_AUDIT_OP((*mask), AUDIT_READLINK);
89                 else if (!strcmp(op,"setattr"))
90                         SET_AUDIT_OP((*mask), AUDIT_SETATTR);
91                 else {
92                         fprintf(stderr, "invalid audit operation '%s'\n", op);
93                 }       
94
95                 op = strtok(NULL, ",");
96         }
97         
98         return rc;
99 }
100
101 #include <unistd.h>
102 #include <dirent.h>
103 #include <linux/unistd.h>
104
105 static int set_dir_audit(char * dir, __u64 mask)
106 {
107         int rc = 0;
108         char * buf;
109         DIR * sdr;
110         struct dirent * ent = (void*)buf;
111         
112         buf = malloc(strlen(dir) + NAME_MAX + 1);
113         
114         sdr = opendir(dir);
115         if (!sdr) {
116                 fprintf(stderr, "cannot open dir %s\n", dir);
117                 free(buf);
118                 return -1;
119         }
120         
121         while ((ent = readdir(sdr)) != NULL) {
122                 int fd;
123                 
124                 if (!strcmp(ent->d_name, ".") ||
125                     !strcmp(ent->d_name, ".."))
126                         continue;
127                 
128                 sprintf(buf, "%s/%s", dir, ent->d_name);
129                 
130                 fd = open(buf, O_RDONLY);
131                 if (fd < 0) {
132                         fprintf(stderr, "can't open: %s: %s\n", buf,
133                                 strerror(rc = errno));
134                         continue;
135                 }
136                 rc = ioctl(fd, LL_IOC_AUDIT, mask);
137                 close(fd);
138         }
139         closedir(sdr);
140         free(buf);
141         return rc;
142 }
143
144 static int set_audit(int argc, char **argv, int fs)
145 {
146         __u64 mask = 0;
147         struct stat st;
148         int rc, fd;
149
150         if (argc != 4)
151                 return CMD_HELP;
152         
153         /* audit can be for all operations or for failed only */
154         if (!strcmp(argv[1], "fail"))
155                 SET_AUDIT_OP(mask, AUDIT_FAIL);
156         else if (strcmp(argv[1], "all")) {
157                 fprintf(stderr, "%s: invalid audit type %s\n",
158                         jt_cmdname(argv[0]), argv[1]);
159                 return -EINVAL;
160         }
161         
162         rc = parse_audit_ops(argv[2], &mask);
163         if (rc < 0)
164                 return -EINVAL;
165         
166         //open file/dir
167         fd = open(argv[3], O_RDONLY);
168         if (fd < 0) {
169                 fprintf(stderr, "can't open: %s: %s\n", argv[3],
170                         strerror(rc = errno));
171                 return -1;
172         }
173         
174         rc = fstat(fd, &st);
175         if (rc) {
176                 close(fd);
177                 return rc;
178         }
179         //audit for fs?
180         if (fs)
181                 SET_AUDIT_OP(mask, AUDIT_FS);
182         else {
183                 //if dir then set audit for childs also
184                 if (S_ISDIR(st.st_mode)) {
185                         //rc = set_dir_audit(argv[3], mask | AUD_BIT(AUDIT_DIR));
186                 }
187         }
188         //set audit for file/dir itself
189         rc = ioctl(fd, LL_IOC_AUDIT, mask);
190         close(fd);
191         return rc;
192 }
193
194 static int jt_set_audit(int argc, char **argv)
195 {
196         return set_audit(argc, argv, 0);
197 }
198
199 static int jt_set_fsaudit(int argc, char **argv)
200 {
201         return set_audit(argc, argv, 1);
202 }
203
204 /*
205  * XXX Should not belong to here
206  */
207 static int flush_cred_ioctl(char *mp)
208 {
209         int fd, rc;
210
211         fd = open(mp, O_RDONLY);
212         if (fd == -1) {
213                 fprintf(stderr, "flush_cred_ioctl: error open %s: %s\n",
214                         mp, strerror(errno));
215                 return -1;
216         }
217
218         rc = ioctl(fd, LL_IOC_FLUSH_CRED);
219         if (rc == -1) {
220                 fprintf(stderr, "flush_cred_ioctl: error ioctl %s: %s\n",
221                         mp, strerror(errno));
222         }
223
224         close(fd);
225         return rc;
226 }
227
228 static int jt_flush_cred(int argc, char **argv)
229 {
230         FILE   *proc;
231         char    procline[PATH_MAX], *line;
232         int     i, rc = 0;
233
234         /* no args means search all lustre mountpoints */
235         if (argc < 2) {
236                 proc = fopen("/proc/mounts", "r");
237                 if (!proc) {
238                         fprintf(stderr, "%s: can't open /proc/mounts\n",
239                                 jt_cmdname(argv[0]));
240                         return -1;
241                 }
242
243                 while ((line = fgets(procline, PATH_MAX, proc)) != NULL) {
244                         char dev[PATH_MAX];
245                         char mp[PATH_MAX];
246                         char fs[PATH_MAX];
247
248                         if (sscanf(line, "%s %s %s", dev, mp, fs) != 3) {
249                                 fprintf(stderr, "%s: unexpected format in "
250                                                 "/proc/mounts\n",
251                                         jt_cmdname(argv[0]));
252                                 return -1;
253                         }
254
255                         if (strcmp(fs, "lustre") &&
256                             strcmp(fs, "lustre_lite"))
257                                 continue;
258
259                         if (flush_cred_ioctl(mp))
260                                 rc = -1;
261                 }
262         } else {
263                 /* follow the exact flush sequence as supplied */
264                 for (i = 1; i < argc; i++) {
265                         if (flush_cred_ioctl(argv[i]))
266                                 rc = -1;
267                 }
268         }
269
270         return rc;
271 }
272
273 command_t cmdlist[] = {
274         /* Metacommands */
275         {"--device", jt_opt_device, 0,
276          "run <command> after connecting to device <devno>\n"
277          "--device <devno> <command [args ...]>"},
278         {"--threads", jt_opt_threads, 0,
279          "run <threads> separate instances of <command> on device <devno>\n"
280          "--threads <threads> <verbose> <devno> <command [args ...]>"},
281         {"--ignore_errors", jt_opt_ignore_errors, 0,
282          "ignore errors that occur during script processing\n"
283          "--ignore_errors"},
284         {"ignore_errors", jt_opt_ignore_errors, 0,
285          "ignore errors that occur during script processing\n"
286          "ignore_errors"},
287         {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"},
288
289         /* Network configuration commands */
290         {"==== network config ====", jt_noop, 0, "network config"},
291         {"--net", jt_opt_net, 0, "run <command> after setting network to <net>\n"
292          "usage: --net <tcp/elan/myrinet> <command>"},
293         {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
294          "usage: network <tcp/elan/myrinet>"},
295         {"interface_list", jt_ptl_print_interfaces, 0, "print interface entries\n"
296          "usage: interface_list"},
297         {"add_interface", jt_ptl_add_interface, 0, "add interface entry\n"
298          "usage: add_interface ip [netmask]"},
299         {"del_interface", jt_ptl_del_interface, 0, "del interface entry\n"
300          "usage: del_interface [ip]"},
301         {"peer_list", jt_ptl_print_peers, 0, "print peer entries\n"
302          "usage: peer_list"},
303         {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n"
304          "usage: add_peer <nid> <host> <port>"},
305         {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n"
306          "usage: del_peer [<nid>] [<host>] [ks]"},
307         {"conn_list", jt_ptl_print_connections, 0, "print all the connected remote nid\n"
308          "usage: conn_list"},
309         {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
310          "usage: connect <host> <port> [iIOC]"},
311         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
312          "usage: disconnect [<nid>]"},
313         {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits\n"
314          "usage: active_tx"},
315         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
316          "The nid defaults to hostname for tcp networks and is automatically "
317          "setup for elan/myrinet networks.\n"
318          "usage: mynid [<nid>]"},
319         {"shownid", jt_ptl_shownid, 0, "print the local NID\n"
320          "usage: shownid"},
321         {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
322          "usage: add_uuid <uuid> <nid> <net_type>"},
323         {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
324          "usage: close_uuid <uuid> <net_type>"},
325         {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
326          "usage: del_uuid <uuid>"},
327         {"add_route", jt_ptl_add_route, 0,
328          "add an entry to the portals routing table\n"
329          "usage: add_route <gateway> <target> [<target>]"},
330         {"del_route", jt_ptl_del_route, 0,
331          "delete route via gateway to targets from the portals routing table\n"
332          "usage: del_route <gateway> [<target>] [<target>]"},
333         {"set_route", jt_ptl_notify_router, 0,
334          "enable/disable routes via gateway in the portals routing table\n"
335          "usage: set_route <gateway> <up/down> [<time>]"},
336         {"route_list", jt_ptl_print_routes, 0,
337          "print the portals routing table, same as show_route\n"
338          "usage: route_list"},
339         {"show_route", jt_ptl_print_routes, 0,
340          "print the portals routing table, same as route_list\n"
341          "usage: show_route"},
342         {"fail", jt_ptl_fail_nid, 0, "fail/restore communications.\n"
343          "Omitting the count means indefinitely, 0 means restore, "
344          "otherwise fail 'count' messages.\n"
345          "usage: fail nid|_all_ [count]"},
346
347         /* Device selection commands */
348         {"=== device selection ===", jt_noop, 0, "device selection"},
349         {"newdev", jt_lcfg_newdev, 0, "create a new device\n"
350          "usage: newdev"},
351         {"device", jt_obd_device, 0,
352          "set current device to <%name|$name|devno>\n"
353          "usage: device <%name|$name|devno>"},
354         {"cfg_device", jt_lcfg_device, 0,
355          "set current device being configured to <$name>\n"
356          "usage: cfg_device <name>"},
357         {"device_list", jt_obd_list, 0, "show all devices\n"
358          "usage: device_list"},
359         {"dl", jt_obd_list, 0, "show all devices\n"
360          "usage: dl"},
361         {"lustre_build_version", jt_get_version, 0,
362          "print the build version of lustre\n"
363          "usage: lustre_build_version"},
364
365         /* Device configuration commands */
366         {"==== device config =====", jt_noop, 0, "device config"},
367         {"attach", jt_lcfg_attach, 0,
368          "set the type of the current device (with <name> and <uuid>)\n"
369          "usage: attach type [name [uuid]]"},
370         {"setup", jt_lcfg_setup, 0,
371          "type specific device configuration information\n"
372          "usage: setup <args...>"},
373         {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
374          "usage: cleanup [force | failover]"},
375         {"detach", jt_obd_detach, 0,
376          "remove driver (and name and uuid) from current device\n"
377          "usage: detach"},
378         {"lov_setup", jt_lcfg_lov_setup, 0, "create a LOV device\n"
379          "usage: lov_setup lov-uuid stripe-count stripe-size offset pattern"},
380         {"lmv_setup", jt_lcfg_lmv_setup, 0,
381          "create an LMV device\n"
382          "usage: lmv_setup lmv-uuid UUID1 [UUID2 ...]"},
383         {"lov_modify_tgts", jt_lcfg_lov_modify_tgts, 0,
384          "add or delete an obd to/from a LOV device\n"
385          "usage: lov_modify_tgts add|del <lov-name> <uuid> <index> <gen>"},
386         {"lov_getconfig", jt_obd_lov_getconfig, 0,
387          "read lov configuration from an mds device\n"
388          "usage: lov_getconfig lov-uuid"},
389         {"lmv_modify_tgts", jt_lcfg_lmv_modify_tgts, 0,
390          "add an mdc to a LMV device\n"
391          "usage: lmv_modify_tgts add <lmv_name> <mdc_uuid>"},
392         {"record", jt_cfg_record, 0, "record commands that follow in log\n"
393          "usage: record cfg-uuid-name"},
394         {"endrecord", jt_cfg_endrecord, 0, "stop recording\n"
395          "usage: endrecord"},
396         {"parse", jt_cfg_parse, 0, "parse the log of recorded commands for this config\n"
397          "usage: parse config-uuid-name"},
398         {"dump_log", jt_cfg_dump_log, 0, "print log of recorded commands for this config to kernel debug log\n"
399          "usage: dump_log config-uuid-name"},
400         {"clear_log", jt_cfg_clear_log, 0, "delete current config log of recorded commands\n"
401          "usage: clear_log config-name"},
402
403         /* Device operations */
404         {"=== device operations ==", jt_noop, 0, "device operations"},
405         {"probe", jt_obd_connect, 0,
406          "build a connection handle to a device.  This command is used to "
407          "suspend configuration until lctl has ensured that the mds and osc "
408          "services are available.  This is to avoid mount failures in a "
409          "rebooting cluster.\n"
410          "usage: probe [timeout]"},
411         {"close", jt_obd_disconnect, 0,
412          "close the connection handle\n"
413          "usage: close"},
414         {"getattr", jt_obd_getattr, 0,
415          "get attribute for OST object <objid>\n"
416          "usage: getattr <objid>"},
417         {"setattr", jt_obd_setattr, 0,
418          "set mode attribute for OST object <objid>\n"
419          "usage: setattr <objid> <mode>"},
420          {"create", jt_obd_create, 0,
421          "create <num> OST objects (with <mode>)\n"
422          "usage: create [num [mode [verbose [lsm data]]]]"},
423         {"destroy", jt_obd_destroy, 0,
424          "destroy OST object <objid> [num [verbose]]\n"
425          "usage: destroy <num> objects, starting at objid <objid>"},
426         {"test_getattr", jt_obd_test_getattr, 0,
427          "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
428          "usage: test_getattr <num> [verbose [[t]objid]]"},
429         {"test_setattr", jt_obd_test_setattr, 0,
430          "do <num> setattrs (on OST object <objid> (objid+1 on each thread))\n"
431          "usage: test_setattr <num> [verbose [[t]objid]]"},
432         {"test_brw", jt_obd_test_brw, 0,
433          "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
434          "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
435         {"get_stripe", jt_obd_get_stripe, 0,
436          "show stripe info for an echo client object\n"
437          "usage: get_stripe objid\n"},
438         {"set_stripe", jt_obd_set_stripe, 0,
439          "set stripe info for an echo client object\n"
440          "usage: set_stripe objid[=width!count[@offset][:id:id...]\n"},
441         {"unset_stripe", jt_obd_unset_stripe, 0,
442          "unset stripe info for an echo client object\n"
443          "usage: unset_stripe objid\n"},
444         {"test_ldlm", jt_obd_test_ldlm, 0,
445          "perform lock manager test\n"
446          "usage: test_ldlm"},
447         {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
448          "start lock manager stress test\n"
449          "usage: ldlm_regress_start [numthreads [refheld [numres [numext]]]]"},
450         {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
451          "stop lock manager stress test (no args)\n"},
452         {"dump_ldlm", jt_obd_dump_ldlm, 0,
453          "dump all lock manager state (no args)"},
454         {"disable_recovery", jt_obd_disable_recovery, 0, "disable recovery on an import\n"},
455         {"enable_recovery", jt_obd_enable_recovery, 0, "enable recovery on an import\n"},
456         {"activate", jt_obd_activate, 0, "activate an import\n"},
457         {"deactivate", jt_obd_deactivate, 0, "deactivate an import\n"},
458         {"recover", jt_obd_recover, 0, "usage: recover [<connection UUID>]"},
459         {"lookup", jt_obd_mdc_lookup, 0, "usage: lookup <directory> <file>"},
460         {"notransno", jt_obd_no_transno, 0,
461          "disable sending of committed-transno updates\n"},
462         {"readonly", jt_obd_set_readonly, 0,
463          "disable writes to the underlying device\n"},
464         {"abort_recovery", jt_obd_abort_recovery, 0,
465          "abort recovery on MDS device\n"},
466         {"root_squash", jt_obd_root_squash, 0,
467          "squash root to 'uid:gid' except client 'nid'\n"
468          "usage: root_squash [uid:gid [nid]]\n"},
469         {"start", jt_obd_start, 0,
470          "setup mds/ost from the llog file\n"
471          "usage: start <profilename>"},
472         {"mount_option", jt_lcfg_mount_option, 0, 
473          "usage: mount_option profile osc_name [mdc_name] [gsc_name] \n"},
474         {"del_mount_option", jt_lcfg_del_mount_option, 0,
475          "usage: del_mount_option profile\n"},
476         {"set_timeout", jt_lcfg_set_timeout, 0,
477          "usage: set_timeout <secs>\n"},
478         {"set_lustre_upcall", jt_lcfg_set_lustre_upcall, 0,
479          "usage: set_lustre_upcall </full/path/to/upcall> \n"},
480         {"add_conn ", jt_lcfg_add_conn, 0,
481          "usage: add_conn <conn_uuid> [priority]\n"},
482         {"del_conn ", jt_lcfg_del_conn, 0,
483          "usage: del_conn <conn_uuid> \n"},
484         {"set_security", jt_lcfg_set_security, 0,
485          "usage: set_security key value\n"},
486         {"audit", jt_set_audit, 0,
487          "usage: audit type operations filename\n"},
488         {"fs_audit", jt_set_fsaudit, 0,
489          "usage: fs_audit type operations mountpoint\n"},
490         {"lsync", jt_obd_reint_sync, 0,
491          "usage: lsync\n"},  
492         {"cache_on", jt_obd_cache_on, 0,
493          "usage: lsync\n"},  
494         {"cache_off", jt_obd_cache_off, 0,
495          "usage: lsync\n"},  
496 /*
497         {"obd_flush_cred", jt_obd_flush_cred, 0,
498          "usage: obd_flush_cred [all]\n"},
499 */
500         /*snap operations*/
501         {"snap_add", jt_obd_snap_add, 0, 
502          "usage: snap_add <dev_name> <snap_name>\n"}, 
503         /* Llog operations */ 
504         {"llog_catlist", jt_llog_catlist, 0, 
505          "list all catalog logs on current device.\n"
506          "usage: llog_catlist"},
507         {"llog_info", jt_llog_info, 0,
508          "print log header information.\n"
509          "usage: llog_info <$logname|#oid#ogr#ogen>\n"
510          "       oid, ogr and ogen are hexadecimal."},
511         {"llog_print", jt_llog_print, 0,
512          "print log content information.\n"
513          "usage: llog_print <$logname|#oid#ogr#ogen> [from] [to]\n"
514          "       oid, ogr and ogen are hexadecimal.\n"
515          "       print all records from index 1 by default."},
516         {"llog_check", jt_llog_check, 0,
517          "print log content information.\n"
518          "usage: llog_check <$logname|#oid#ogr#ogen> [from] [to]\n"
519          "       oid, ogr and ogen are hexadecimal.\n"
520          "       check all records from index 1 by default."},
521          {"llog_cancel", jt_llog_cancel, 0,
522          "cancel one record in log.\n"
523          "usage: llog_cancel <catalog id|catalog name> <log id> <index>"},
524         {"llog_remove", jt_llog_remove, 0,
525          "remove one log from catalog, erase it from disk.\n"
526          "usage: llog_remove <catalog id|catalog name> <log id>"},
527         
528         /* Misc commands */
529         {"flush_cred", jt_flush_cred, 0,
530          "flush the client side credential.\n"
531          "usage: flush_cred [mountpoint]..."},
532         {"set_crypt", jt_set_lkey_type, 0,
533          "set lustre key management type, only support gks and mks\n"
534          "usage: set_crypt [dir] [gks|mks]...."},
535         
536         /* Debug commands */
537         {"======== debug =========", jt_noop, 0, "debug"},
538         {"debug_daemon", jt_dbg_debug_daemon, 0,
539          "debug daemon control and dump to a file\n"
540          "usage: debug_daemon {start file [#MB]|stop}"},
541         {"debug_kernel", jt_dbg_debug_kernel, 0,
542          "get debug buffer and dump to a file, same as dk\n"
543          "usage: debug_kernel [file] [raw]"},
544         {"dk", jt_dbg_debug_kernel, 0,
545          "get debug buffer and dump to a file, same as debug_kernel\n"
546          "usage: dk [file] [raw]"},
547         {"debug_file", jt_dbg_debug_file, 0,
548          "read debug buffer from input and dump to output, same as df\n"
549          "usage: debug_file <input> [output] [raw]"},
550         {"df", jt_dbg_debug_file, 0,
551          "read debug buffer from input and dump to output, same as debug_file\n"
552          "usage: df <input> [output] [raw]"},
553         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
554          "usage: clear"},
555         {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
556          "usage: mark <text>"},
557         {"filter", jt_dbg_filter, 0, "filter message type\n"
558          "usage: filter <subsystem id/debug mask>"},
559         {"show", jt_dbg_show, 0, "Show specific type of messages\n"
560          "usage: show <subsystem id/debug mask>"},
561         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
562          "usage: debug_list <subs/types>"},
563         {"modules", jt_dbg_modules, 0,
564          "provide gdb-friendly module information\n"
565          "usage: modules <path>"},
566         {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
567          "usage: panic"},
568         {"lwt", jt_ptl_lwt, 0,
569          "light-weight tracing\n"
570          "usage: lwt start\n"
571          "       lwt stop [file]"},
572         {"memhog", jt_ptl_memhog, 0,
573          "memory pressure testing\n"
574          "usage: memhog <page count> [<gfp flags>]"},
575                 
576         /* User interface commands */
577         {"======= control ========", jt_noop, 0, "control commands"},
578         {"help", Parser_help, 0, "help"},
579         {"exit", jt_quit, 0, "quit"},
580         {"quit", jt_quit, 0, "quit"},
581         { 0, 0, 0, NULL }
582 };
583
584 int lctl_main(int argc, char **argv)
585 {
586         int rc;
587
588         setlinebuf(stdout);
589
590         ptl_initialize(argc, argv);
591         if (obd_initialize(argc, argv) < 0)
592                 exit(2);
593         if (dbg_initialize(argc, argv) < 0)
594                 exit(3);
595
596         Parser_init("lctl > ", cmdlist);
597
598         if (argc > 1) {
599                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
600         } else {
601                 rc = Parser_commands();
602         }
603
604         obd_finalize(argc, argv);
605         return rc;
606 }
607
608 #if !LIBLUSTRE_TEST
609 int main (int argc, char **argv)
610 {
611         return (lctl_main (argc, argv));
612 }
613 #endif