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