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