Whamcloud - gitweb
LU-6245 libcfs: create userland and kernel string operations
[fs/lustre-release.git] / lustre / utils / lctl.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, 2014, Intel Corporation.
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/lctl.c
37  *
38  * Author: Peter J. Braam <braam@clusterfs.com>
39  * Author: Phil Schwan <phil@clusterfs.com>
40  * Author: Robert Read <rread@clusterfs.com>
41  */
42
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include <lnet/lnetctl.h>
46 #include "obdctl.h"
47 #include <libcfs/libcfsutil.h>
48 #include <lustre/lustre_idl.h>
49
50 static int jt_noop(int argc, char **argv) {
51         return 0;
52 }
53
54 static int jt_opt_ignore_errors(int argc, char **argv) {
55         Parser_ignore_errors(1);
56         return 0;
57 }
58
59 command_t cmdlist[] = {
60         /* Metacommands */
61         {"===== metacommands =======", jt_noop, 0, "metacommands"},
62         {"--device", jt_opt_device, 0,
63          "run <command> after connecting to device <devno>\n"
64          "--device <devno> <command [args ...]>"},
65         {"--ignore_errors", jt_opt_ignore_errors, 0,
66          "ignore errors that occur during script processing\n"
67          "--ignore_errors"},
68         {"ignore_errors", jt_opt_ignore_errors, 0,
69          "ignore errors that occur during script processing\n"
70          "ignore_errors"},
71
72         /* User interface commands */
73         {"======== control =========", jt_noop, 0, "control commands"},
74         {"help", Parser_help, 0, "help"},
75         {"lustre_build_version", jt_get_version, 0,
76          "print the build version of lustre\n"
77          "usage: lustre_build_version"},
78         {"exit", Parser_quit, 0, "quit"},
79         {"quit", Parser_quit, 0, "quit"},
80         {"--version", Parser_version, 0,
81          "output build version of the utility and exit"},
82
83         /* Network configuration commands */
84         {"===== network config =====", jt_noop, 0, "network config"},
85         {"--net", jt_opt_net, 0,"run <command> after setting network to <net>\n"
86          "usage: --net <tcp/elan/o2ib/...> <command>"},
87         {"network", jt_ptl_network, 0, "configure LNET"
88          "usage: network up|down"},
89         {"net", jt_ptl_network, 0, "configure LNET"
90          "usage: net up|down"},
91         {"list_nids", jt_ptl_list_nids, 0, "list local NIDs"
92          "usage: list_nids [all]"},
93         {"which_nid", jt_ptl_which_nid, 0, "choose a NID"
94          "usage: which_nid NID [NID...]"},
95         {"replace_nids", jt_replace_nids, 0,
96          "replace primary NIDs for a device\n"
97          "usage: replace_nids <device> <nid1>[,nid2,nid3]"},
98         {"interface_list", jt_ptl_print_interfaces,0,"print interface entries\n"
99          "usage: interface_list"},
100         {"peer_list", jt_ptl_print_peers, 0, "print peer entries\n"
101          "usage: peer_list"},
102         {"conn_list", jt_ptl_print_connections, 0,
103          "print all the connected remote nid\n"
104          "usage: conn_list"},
105         {"route_list", jt_ptl_print_routes, 0,
106          "print the portals routing table, same as show_route\n"
107          "usage: route_list"},
108         {"show_route", jt_ptl_print_routes, 0,
109          "print the portals routing table, same as route_list\n"
110          "usage: show_route"},
111         {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n"
112          "usage: ping nid [timeout] [pid]"},
113         {"net_drop_add", jt_ptl_drop_add, 0, "Add LNet drop rule\n"
114          "usage: net_drop_add <-s | --source NID>\n"
115          "                    <-d | --dest NID>\n"
116          "                    <<-r | --rate DROP_RATE> |\n"
117          "                     <-i | --interval SECONDS>>\n"
118          "                    [<-p | --portal> PORTAL...]\n"
119          "                    [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"},
120         {"net_drop_del", jt_ptl_drop_del, 0, "remove LNet drop rule\n"
121          "usage: net_drop_del <[-a | --all] |\n"
122          "                    <-s | --source NID>\n"
123          "                    <-d | --dest NID>>\n"},
124         {"net_drop_reset", jt_ptl_drop_reset, 0, "reset drop rule stats\n"
125          "usage: net_drop_reset"},
126         {"net_drop_list", jt_ptl_drop_list, 0, "list LNet drop rules\n"
127          "usage: net_drop_list"},
128         {"net_delay_add", jt_ptl_delay_add, 0, "Add LNet delay rule\n"
129          "usage: net_delay_add <-s | --source NID>\n"
130          "                     <-d | --dest NID>\n"
131          "                     <<-r | --rate DROP_RATE> |\n"
132          "                      <-i | --interval SECONDS>>\n"
133          "                     <-l | --latency SECONDS>\n"
134          "                     [<-p | --portal> PORTAL...]\n"
135          "                     [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"},
136         {"net_delay_del", jt_ptl_delay_del, 0, "remove LNet delay rule\n"
137          "usage: net_delay_del <[-a | --all] |\n"
138          "                     <-s | --source NID>\n"
139          "                     <-d | --dest NID>>\n"},
140         {"net_delay_reset", jt_ptl_delay_reset, 0, "reset delay rule stats\n"
141          "usage: net_delay_reset"},
142         {"net_delay_list", jt_ptl_delay_list, 0, "list LNet delay rules\n"
143          "usage: net_delay_list"},
144
145         /* Device selection commands */
146         {"==== obd device selection ====", jt_noop, 0, "device selection"},
147         {"device", jt_obd_device, 0,
148          "set current device to <name|devno>\n"
149          "usage: device <%name|$name|devno>"},
150         {"device_list", jt_obd_list, 0, "show all devices\n"
151          "usage: device_list"},
152         {"dl", jt_obd_list, 0, "show all devices\n"
153          "usage: dl [-t]"},
154
155         /* Device operations */
156         {"==== obd device operations ====", jt_noop, 0, "device operations"},
157         {"activate", jt_obd_activate, 0, "activate an import\n"},
158         {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
159          "This command should be used on failed OSC devices in an MDT LOV.\n"},
160         {"abort_recovery", jt_obd_abort_recovery, 0,
161          "abort recovery on a restarting MDT or OST device\n"},
162         {"set_timeout", jt_lcfg_set_timeout, 0,
163          "usage: conf_param obd_timeout=<secs>\n"},
164 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
165         {"conf_param", jt_lcfg_mgsparam, 0,"set a permanent config parameter.\n"
166          "This command must be run on the MGS node\n"
167          "usage: conf_param [-d] <target.keyword=val>\n"
168          "  -d  Remove the permanent setting."},
169 #endif
170         {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n"
171          "usage: local_param <target.keyword=val>\n"},
172         {"get_param", jt_lcfg_getparam, 0, "get the Lustre or LNET parameter\n"
173          "usage: get_param [-n|-N|-F] <param_path1 param_path2 ...>\n"
174          "Get the value of Lustre or LNET parameter from the specified path.\n"
175          "The path can contain shell-style filename patterns.\n"
176          "  -n  Print only the value and not parameter name.\n"
177          "  -N  Print only matched parameter names and not the values.\n"
178          "      (Especially useful when using patterns.)\n"
179          "  -F  When -N specified, add '/', '@' or '=' for directories,\n"
180          "      symlinks and writeable files, respectively."},
181         {"set_param", jt_lcfg_setparam, 0, "set the Lustre or LNET parameter\n"
182          "usage: set_param [-n] [-P] [-d]"
183          "<param_path1=value1 param_path2=value2 ...>\n"
184          "Set the value of the Lustre or LNET parameter at the specified path.\n"
185          "  -n  Disable printing of the key name when printing values.\n"
186          "  -P  Set the parameter permanently, filesystem-wide.\n"
187          "  -d  Remove the permanent setting (only with -P option).\n"},
188         {"list_param", jt_lcfg_listparam, 0,
189          "list the Lustre or LNET parameter name\n"
190          "usage: list_param [-F|-R] <param_path1 param_path2 ...>\n"
191          "List the name of Lustre or LNET parameter from the specified path.\n"
192          "  -F  Add '/', '@' or '=' for dirs, symlinks and writeable files,\n"
193                 "respectively.\n"
194          "  -R  Recursively list all parameters under the specified path.\n"},
195
196         /* Debug commands */
197         {"==== debugging control ====", jt_noop, 0, "debug"},
198         {"debug_daemon", jt_dbg_debug_daemon, 0,
199          "debug daemon control and dump to a file\n"
200          "usage: debug_daemon {start file [#MB]|stop}"},
201         {"debug_kernel", jt_dbg_debug_kernel, 0,
202          "get debug buffer and dump to a file, same as dk\n"
203          "usage: debug_kernel [file] [raw]"},
204         {"dk", jt_dbg_debug_kernel, 0,
205          "get debug buffer and dump to a file, same as debug_kernel\n"
206          "usage: dk [file] [raw]"},
207         {"debug_file", jt_dbg_debug_file, 0,
208          "convert a binary debug file dumped by the kernel to ASCII text\n"
209          "usage: debug_file <input> [output]"},
210         {"df", jt_dbg_debug_file, 0,
211          "read debug buffer from input and dump to output, same as debug_file\n"
212          "usage: df <input> [output]"},
213         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
214          "usage: clear"},
215         {"mark", jt_dbg_mark_debug_buf, 0,
216          "insert marker text in kernel debug buffer\n"
217          "usage: mark <text>"},
218         {"filter", jt_dbg_filter, 0, "filter message type\n"
219          "usage: filter <subsystem id/debug mask>"},
220         {"show", jt_dbg_show, 0, "Show specific type of messages\n"
221          "usage: show <subsystem id/debug mask>"},
222         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
223          "usage: debug_list <subs/types>"},
224         {"modules", jt_dbg_modules, 0,
225          "provide gdb-friendly module information\n"
226          "usage: modules <path>"},
227
228         /* virtual block operations */
229         {"==== virtual block device ====", jt_noop, 0, "virtual block device"},
230         {"blockdev_attach", jt_blockdev_attach, 0,
231          "attach a lustre regular file to a virtual block device\n"
232          "usage: blockdev_attach <file_name> <device_name>"},
233         {"blockdev_detach", jt_blockdev_detach, 0,
234          "detach a lustre regular file from a virtual block device\n"
235          "usage: blockdev_detach <device_name>"},
236         {"blockdev_info", jt_blockdev_info, 0,
237          "get the device info of a attached file\n"
238          "usage: blockdev_info <device_name>"},
239
240         /* Pool commands */
241         {"===  Pools ==", jt_noop, 0, "pool management"},
242         {"pool_new", jt_pool_cmd, 0,
243          "add a new pool\n"
244          "usage: pool_new <fsname>.<poolname>"},
245         {"pool_add", jt_pool_cmd, 0,
246          "add the named OSTs to the pool\n"
247          "usage: pool_add <fsname>.<poolname> <ostname indexed list>"},
248         {"pool_remove", jt_pool_cmd, 0,
249          "remove the named OST from the pool\n"
250          "usage: pool_remove <fsname>.<poolname> <ostname indexed list>"},
251         {"pool_destroy", jt_pool_cmd, 0,
252          "destroy a pool\n"
253          "usage: pool_destroy <fsname>.<poolname>"},
254         {"pool_list", jt_pool_cmd, 0,
255          "list pools and pools members\n"
256          "usage: pool_list  <fsname>[.<poolname>] | <pathname>"},
257
258         /* Nodemap commands */
259         {"=== Nodemap ===", jt_noop, 0, "nodemap management"},
260         {"nodemap_activate", jt_nodemap_activate, 0,
261          "activate nodemap idmapping functions\n"
262          "usage: nodemap_activate"},
263         {"nodemap_add", jt_nodemap_add, 0,
264          "add a new nodemap\n"
265          "usage: nodemap_add <nodemap_name>"},
266         {"nodemap_del", jt_nodemap_del, 0,
267          "remove a nodemap\n"
268          "usage: nodemap_del <nodemap_name>"},
269         {"nodemap_add_range", jt_nodemap_add_range, 0,
270          "add a range to a nodemap\n"
271          "usage: nodemap_add_range <NID range>"},
272         {"nodemap_del_range", jt_nodemap_del_range, 0,
273          "add a range to a nodemap\n"
274          "usage: nodemap_del_range <NID range>"},
275         {"nodemap_modify", jt_nodemap_modify, 0,
276          "modify a nodemap parameters"
277          "usage: nodemap_modify nodemap_name param value"},
278         {"nodemap_add_idmap", jt_nodemap_add_idmap, 0,
279          "add a UID or GID mapping to a nodemap"},
280         {"nodemap_del_idmap", jt_nodemap_del_idmap, 0,
281          "delete a UID or GID mapping from a nodemap"},
282         {"nodemap_test_nid", jt_nodemap_test_nid, 0,
283          "usage: nodemap_test_nid <nid>"},
284         {"nodemap_test_id", jt_nodemap_test_id, 0,
285          "Usage: nodemap_test_id --nid <nid> --idtype [uid|gid] --id <id>"},
286
287         /* Changelog commands */
288         {"===  Changelogs ==", jt_noop, 0, "changelog user management"},
289         {"changelog_register", jt_changelog_register, 0,
290          "register a new persistent changelog user, returns id\n"
291          "usage:\tdevice <mdtname>\n\tchangelog_register [-n]"},
292         {"changelog_deregister", jt_changelog_deregister, 0,
293          "deregister an existing changelog user\n"
294          "usage:\tdevice <mdtname>\n\tchangelog_deregister <id>"},
295
296         /* Device configuration commands */
297         {"== device setup (these are not normally used post 1.4) ==",
298                 jt_noop, 0, "device config"},
299         {"attach", jt_lcfg_attach, 0,
300          "set the type, name, and uuid of the current device\n"
301          "usage: attach type name uuid"},
302         {"detach", jt_obd_detach, 0,
303          "remove driver (and name and uuid) from current device\n"
304          "usage: detach"},
305         {"setup", jt_lcfg_setup, 0,
306          "type specific device configuration information\n"
307          "usage: setup <args...>"},
308         {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
309          "usage: cleanup [force | failover]"},
310         {"dump_cfg", jt_cfg_dump_log, 0,
311          "print log of recorded commands for this config to kernel debug log\n"
312          "usage: dump_cfg config-uuid-name"},
313
314         /* Test only commands */
315         {"==== testing (DANGEROUS) ====", jt_noop, 0, "testing (DANGEROUS)"},
316         {"--threads", jt_opt_threads, 0,
317          "run <threads> separate instances of <command> on device <devno>\n"
318          "--threads <threads> <verbose> <devno> <command [args ...]>"},
319         {"lookup", jt_obd_mdc_lookup, 0, "report file mode info\n"
320          "usage: lookup <directory> <file>"},
321         {"readonly", jt_obd_set_readonly, 0,
322          "disable writes to the underlying device\n"},
323         {"notransno", jt_obd_no_transno, 0,
324          "disable sending of committed-transno updates\n"},
325         {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
326          "usage: add_uuid <uuid> <nid>"},
327         {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
328          "usage: del_uuid <uuid>"},
329         {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n"
330          "usage: add_peer <nid> <host> <port>"},
331         {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n"
332          "usage: del_peer [<nid>] [<ipaddr|pid>]"},
333         {"add_conn ", jt_lcfg_add_conn, 0,
334          "usage: add_conn <conn_uuid> [priority]\n"},
335         {"del_conn ", jt_lcfg_del_conn, 0,
336          "usage: del_conn <conn_uuid> \n"},
337         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
338          "usage: disconnect [<nid>]"},
339         {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid\n"
340          "usage: push [<nid>]"},
341         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
342          "The nid defaults to hostname for tcp networks and is automatically "
343          "setup for elan/myrinet networks.\n"
344          "usage: mynid [<nid>]"},
345         {"fail", jt_ptl_fail_nid, 0, "fail/restore communications.\n"
346          "Omitting the count means indefinitely, 0 means restore, "
347          "otherwise fail 'count' messages.\n"
348          "usage: fail nid|_all_ [count]"},
349
350         /*Test commands for echo client*/
351         {"test_create", jt_obd_test_create, 0,
352          "create files on MDT by echo client\n"
353          "usage: test_create [-d parent_basedir] <-D parent_count> "
354          "[-b child_base_id] <-c stripe_count> <-n count> <-t time>\n"},
355         {"test_mkdir", jt_obd_test_mkdir, 0,
356          "mkdir on MDT by echo client\n"
357          "usage: test_mkdir [-d parent_basedir] <-D parent_count>"
358          "[-b child_base_id] [-n count] <-t time>\n"},
359         {"test_destroy", jt_obd_test_destroy, 0,
360          "Destroy files on MDT by echo client\n"
361          "usage: test_destroy [-d parent_basedir] <-D parent_count>"
362          "[-b child_base_id] [-n count] <-t time>\n"},
363         {"test_rmdir", jt_obd_test_rmdir, 0,
364          "rmdir on MDT by echo client\n"
365          "usage: test_rmdir [-d parent_basedir] <-D parent_count>"
366          "[-b child_base_id] [-n count] <-t time>\n"},
367         {"test_lookup", jt_obd_test_lookup, 0,
368          "lookup files on MDT by echo client\n"
369          "usage: test_lookup [-d parent_basedir] <-D parent_count>"
370          "[-b child_base_id] [-n count] <-t time>\n"},
371         {"test_setxattr", jt_obd_test_setxattr, 0,
372          "Set EA for files/directory on MDT by echo client\n"
373          "usage: test_setxattr [-d parent_baseid] <-D parent_count>"
374          "[-b child_base_id] [-n count] <-t time>\n"},
375         {"test_md_getattr", jt_obd_test_md_getattr, 0,
376          "getattr files on MDT by echo client\n"
377          "usage: test_md_getattr [-d parent_basedir] <-D parent_count>"
378          "[-b child_base_id] [-n count] <-t time>\n"},
379         {"getattr", jt_obd_getattr, 0,
380          "get attribute for OST object <objid>\n"
381          "usage: getattr <objid>"},
382         {"setattr", jt_obd_setattr, 0,
383          "set mode attribute for OST object <objid>\n"
384          "usage: setattr <objid> <mode>"},
385         {"create", jt_obd_create, 0,
386          "create <num> OST objects (with <mode>)\n"
387          "usage: create [num [mode [verbose [lsm data]]]]"},
388         {"destroy", jt_obd_destroy, 0,
389          "destroy OST object <objid> [num [verbose]]\n"
390          "usage: destroy <num> objects, starting at objid <objid>"},
391         {"test_getattr", jt_obd_test_getattr, 0,
392          "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
393          "usage: test_getattr <num> [verbose [[t]objid]]"},
394         {"test_setattr", jt_obd_test_setattr, 0,
395          "do <num> setattrs (on OST object <objid> (objid+1 on each thread))\n"
396          "usage: test_setattr <num> [verbose [[t]objid]]"},
397         {"test_brw", jt_obd_test_brw, 0,
398          "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
399          "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
400         {"memhog", jt_ptl_memhog, 0,
401          "memory pressure testing\n"
402          "usage: memhog <page count> [<gfp flags>]"},
403         {"getobjversion", jt_get_obj_version, 0,
404          "get the version of an object on servers\n"
405          "usage: getobjversion <fid>\n"
406          "       getobjversion -i <id> -g <group>"},
407
408         /* LFSCK commands */
409         {"==== LFSCK ====", jt_noop, 0, "LFSCK"},
410         {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n"
411          "usage: lfsck_start <-M | --device [MDT,OST]_device>\n"
412          "                   [-A | --all] [-c | --create_ostobj [on | off]]\n"
413          "                   [-C | --create_mdtobj [on | off]]\n"
414          "                   [-e | --error {continue | abort}] [-h | --help]\n"
415          "                   [-n | --dryrun [on | off]] [-o | --orphan]\n"
416          "                   [-r | --reset] [-s | --speed speed_limit]\n"
417          "                   [-t | --type lfsck_type[,lfsck_type...]]\n"
418          "                   [-w | --window_size size]"},
419         {"lfsck_stop", jt_lfsck_stop, 0, "stop lfsck(s)\n"
420          "usage: lfsck_stop <-M | --device [MDT,OST]_device>\n"
421          "                  [-A | --all] [-h | --help]"},
422
423         {"==== obsolete (DANGEROUS) ====", jt_noop, 0, "obsolete (DANGEROUS)"},
424         /* some test scripts still use these */
425         {"cfg_device", jt_obd_device, 0,
426          "set current device to <name>\n"
427          "usage: device <name>"},
428         {"recover", jt_obd_recover, 0,
429          "try to restore a lost connection immediately\n"
430          "usage: recover [MDC/OSC device]"},
431         /* saving for sanity 44a */
432         {"lov_getconfig", jt_obd_lov_getconfig, 0,
433          "read lov configuration from an mds device\n"
434          "usage: lov_getconfig <mountpoint>"},
435         /* Llog operations */
436         {"llog_catlist", jt_llog_catlist, 0,
437          "list all catalog logs on current device.\n"
438          "usage: llog_catlist"},
439         {"llog_info", jt_llog_info, 0,
440          "print log header information.\n"
441          "usage: llog_info <$logname|#oid#ogr#ogen>\n"
442          "       oid, ogr and ogen are hexadecimal."},
443         {"llog_print", jt_llog_print, 0,
444          "print log content information.\n"
445          "usage: llog_print <$logname|#oid#ogr#ogen> [from] [to]\n"
446          "       oid, ogr and ogen are hexadecimal.\n"
447          "       print all records from index 1 by default."},
448         {"llog_check", jt_llog_check, 0,
449          "print log content information.\n"
450          "usage: llog_check <$logname|#oid#ogr#ogen> [from] [to]\n"
451          "       oid, ogr and ogen are hexadecimal.\n"
452          "       check all records from index 1 by default."},
453          {"llog_cancel", jt_llog_cancel, 0,
454          "cancel one record in log.\n"
455          "This command supports both positional and optional arguments\n"
456          "usage (positional args): "
457          "llog_cancel <catalog id|catalog name> [log id] <index>\n"
458          "usage (optional args): "
459          "llog_cancel --catalog <catalog id|catalog name> --log_id <log_id> "
460          "--log_idx <index>"},
461         {"llog_remove", jt_llog_remove, 0,
462          "remove one log from catalog or plain log, erase it from disk.\n"
463          "usage: llog_remove <catalog id|catalog name> <log id>"},
464         /* network operations */
465         {"add_interface", jt_ptl_add_interface, 0, "add interface entry\n"
466          "usage: add_interface ip [netmask]"},
467         {"del_interface", jt_ptl_del_interface, 0, "del interface entry\n"
468          "usage: del_interface [ip]"},
469         {"add_route", jt_ptl_add_route, 0,
470          "add an entry to the portals routing table\n"
471          "usage: add_route <gateway> [<hops> [<priority>]]"},
472         {"del_route", jt_ptl_del_route, 0,
473          "delete route via gateway to targets from the portals routing table\n"
474          "usage: del_route <gateway> [<target>] [<target>]"},
475         {"set_route", jt_ptl_notify_router, 0,
476          "enable/disable routes via gateway in the portals routing table\n"
477          "usage: set_route <gateway> <up/down> [<time>]"},
478
479         { 0, 0, 0, NULL }
480 };
481
482 int lctl_main(int argc, char **argv)
483 {
484         int rc;
485
486         setlinebuf(stdout);
487
488         ptl_initialize(argc, argv);
489         if (obd_initialize(argc, argv) < 0)
490                 exit(2);
491         if (dbg_initialize(argc, argv) < 0)
492                 exit(3);
493
494         Parser_init("lctl > ", cmdlist);
495
496         if (argc > 1) {
497                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
498         } else {
499                 rc = Parser_commands();
500         }
501
502         obd_finalize(argc, argv);
503         return rc < 0 ? -rc : rc;
504 }
505
506 #ifndef LIBLUSTRE_TEST
507 int main (int argc, char **argv)
508 {
509         return (lctl_main (argc, argv));
510 }
511 #endif