1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 * Author: Peter J. Braam <braam@clusterfs.com>
39 * Author: Phil Schwan <phil@clusterfs.com>
40 * Author: Robert Read <rread@clusterfs.com>
56 #include <sys/types.h>
65 #include <lnet/api-support.h>
66 #include <lnet/lnetctl.h>
68 #include <liblustre.h>
69 #include <lustre/lustre_idl.h>
70 #include <lustre/liblustreapi.h>
71 #include <lustre/lustre_user.h>
73 #include <libcfs/libcfsutil.h>
76 unsigned int libcfs_subsystem_debug = 0;
79 static int lfs_setstripe(int argc, char **argv);
80 static int lfs_find(int argc, char **argv);
81 static int lfs_getstripe(int argc, char **argv);
82 static int lfs_osts(int argc, char **argv);
83 static int lfs_df(int argc, char **argv);
84 static int lfs_check(int argc, char **argv);
85 static int lfs_catinfo(int argc, char **argv);
86 #ifdef HAVE_QUOTA_SUPPORT
87 static int lfs_quotachown(int argc, char **argv);
88 static int lfs_quotacheck(int argc, char **argv);
89 static int lfs_quotaon(int argc, char **argv);
90 static int lfs_quotaoff(int argc, char **argv);
91 static int lfs_setquota(int argc, char **argv);
92 static int lfs_quota(int argc, char **argv);
94 static int lfs_flushctx(int argc, char **argv);
95 static int lfs_join(int argc, char **argv);
96 static int lfs_lsetfacl(int argc, char **argv);
97 static int lfs_lgetfacl(int argc, char **argv);
98 static int lfs_rsetfacl(int argc, char **argv);
99 static int lfs_rgetfacl(int argc, char **argv);
100 static int lfs_cp(int argc, char **argv);
101 static int lfs_ls(int argc, char **argv);
102 static int lfs_poollist(int argc, char **argv);
104 /* all avaialable commands */
105 command_t cmdlist[] = {
106 {"setstripe", lfs_setstripe, 0,
107 "Create a new file with a specific striping pattern or\n"
108 "set the default striping pattern on an existing directory or\n"
109 "delete the default striping pattern from an existing directory\n"
110 "usage: setstripe [--size|-s stripe_size] [--offset|-o start_ost]\n"
111 " [--count|-c stripe_count] [--pool|-p pool_name]\n"
114 " setstripe -d <dir> (to delete default striping)\n"
115 "\tstripe_size: Number of bytes on each OST (0 filesystem default)\n"
116 "\t Can be specified with k, m or g (in KB, MB and GB\n"
118 "\tstart_ost: OST index of first stripe (-1 filesystem default)\n"
119 "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n"
120 "\tpool_name: Name of OST pool"},
121 {"getstripe", lfs_getstripe, 0,
122 "To list the striping info for a given file or files in a\n"
123 "directory or recursively for all files in a directory tree.\n"
124 "usage: getstripe [--obd|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
125 " [--recursive | -r] <dir|file> ..."},
126 {"poollist", lfs_poollist, 0,
127 "List pools or pool OSTs\n"
128 "usage: poollist <fsname>[.<poolname>] | <pathname>\n"},
129 {"find", lfs_find, 0,
130 "To find files that match given parameters recursively in a directory tree.\n"
131 "usage: find <dir|file> ... \n"
132 " [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n"
133 " [--maxdepth|-D N] [[!] --name|-n <pattern>] [--print0|-P]\n"
134 " [--print|-p] [--obd|-O <uuid[s]>] [[!] --size|-s [+-]N[bkMGTP]]\n"
135 " [[!] --type|-t <filetype>] [[!] --gid|-g N] [[!] --group|-G <name>]\n"
136 " [[!] --uid|-u N] [[!] --user|-U <name>]\n"
137 " [[!] --pool <name>]\n"
138 "\t !: used before an option indicates 'NOT' the requested attribute\n"
139 "\t -: used before an value indicates 'AT MOST' the requested value\n"
140 "\t +: used before an option indicates 'AT LEAST' the requested value\n"},
141 {"check", lfs_check, 0,
142 "Display the status of MDS or OSTs (as specified in the command)\n"
143 "or all the servers (MDS and OSTs).\n"
144 "usage: check <osts|mds|servers>"},
145 {"catinfo", lfs_catinfo, 0,
146 "Show information of specified type logs.\n"
147 "usage: catinfo {keyword} [node name]\n"
148 "\tkeywords are one of followings: config, deletions.\n"
149 "\tnode name must be provided when use keyword config."},
150 {"join", lfs_join, 0,
151 "join two lustre files into one - join A, B, will be like cat B >> A & del B\n"
152 "usage: join <filename_A> <filename_B>\n"},
153 {"osts", lfs_osts, 0, "osts"},
155 "report filesystem disk space usage or inodes usage"
157 "Usage: df [-i] [-h] [path]"},
158 #ifdef HAVE_QUOTA_SUPPORT
159 {"quotachown",lfs_quotachown, 0,
160 "Change files' owner or group on the specified filesystem.\n"
161 "usage: quotachown [-i] <filesystem>\n"
162 "\t-i: ignore error if file is not exist\n"},
163 {"quotacheck", lfs_quotacheck, 0,
164 "Scan the specified filesystem for disk usage, and create,\n"
165 "or update quota files.\n"
166 "usage: quotacheck [ -ug ] <filesystem>"},
167 {"quotaon", lfs_quotaon, 0, "Turn filesystem quotas on.\n"
168 "usage: quotaon [ -ugf ] <filesystem>"},
169 {"quotaoff", lfs_quotaoff, 0, "Turn filesystem quotas off.\n"
170 "usage: quotaoff [ -ug ] <filesystem>"},
171 {"setquota", lfs_setquota, 0, "Set filesystem quotas.\n"
172 "usage: setquota [ -u | -g ] <name> <block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> <filesystem>\n"
173 " setquota -t [ -u | -g ] <block-grace> <inode-grace> <filesystem>"},
174 {"quota", lfs_quota, 0, "Display disk usage and limits.\n"
175 "usage: quota [ -o obd_uuid ] [{-u|-g <name>}|-t] <filesystem>"},
177 {"flushctx", lfs_flushctx, 0, "Flush security context for current user.\n"
178 "usage: flushctx [-k] [mountpoint...]"},
179 {"lsetfacl", lfs_lsetfacl, 0,
180 "Remote user setfacl for user/group on the same remote client.\n"
181 "usage: lsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
182 {"lgetfacl", lfs_lgetfacl, 0,
183 "Remote user getfacl for user/group on the same remote client.\n"
184 "usage: lgetfacl [-dRLPvh] file ..."},
185 {"rsetfacl", lfs_rsetfacl, 0,
186 "Remote user setfacl for user/group on other clients.\n"
187 "usage: rsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
188 {"rgetfacl", lfs_rgetfacl, 0,
189 "Remote user getfacl for user/group on other clients.\n"
190 "usage: rgetfacl [-dRLPvh] file ..."},
192 "Remote user copy files and directories.\n"
193 "usage: cp [OPTION]... [-T] SOURCE DEST\n\tcp [OPTION]... SOURCE... DIRECTORY\n\tcp [OPTION]... -t DIRECTORY SOURCE..."},
195 "Remote user list directory contents.\n"
196 "usage: ls [OPTION]... [FILE]..."},
197 {"help", Parser_help, 0, "help"},
198 {"exit", Parser_quit, 0, "quit"},
199 {"quit", Parser_quit, 0, "quit"},
203 static int isnumber(const char *str)
207 if (str[0] != '-' && !isdigit(str[0]))
210 for (ptr = str + 1; *ptr != '\0'; ptr++) {
219 static int lfs_setstripe(int argc, char **argv)
223 unsigned long long st_size;
224 int st_offset, st_count;
228 char *stripe_size_arg = NULL;
229 char *stripe_off_arg = NULL;
230 char *stripe_count_arg = NULL;
231 char *pool_name_arg = NULL;
232 unsigned long long size_units;
234 struct option long_opts[] = {
235 {"size", required_argument, 0, 's'},
236 {"count", required_argument, 0, 'c'},
237 {"index", required_argument, 0, 'i'},
238 {"offset", required_argument, 0, 'o'},
239 {"pool", required_argument, 0, 'p'},
240 {"delete", no_argument, 0, 'd'},
248 #if LUSTRE_VERSION < OBD_OCD_VERSION(2,1,0,0)
249 if (argc == 5 && argv[1][0] != '-' &&
250 isnumber(argv[2]) && isnumber(argv[3]) && isnumber(argv[4])) {
251 fprintf(stderr, "warning: deprecated usage of setstripe "
252 "positional parameters. Use -c, -i, -s instead.\n");
253 /* for compatibility with the existing positional parameter
256 stripe_size_arg = argv[2];
257 stripe_off_arg = argv[3];
258 stripe_count_arg = argv[4];
262 #warning "remove obsolete positional parameter code"
266 while ((c = getopt_long(argc, argv, "c:di:o:s:p:",
267 long_opts, NULL)) >= 0) {
273 stripe_count_arg = optarg;
276 /* delete the default striping pattern */
281 stripe_off_arg = optarg;
284 stripe_size_arg = optarg;
287 pool_name_arg = optarg;
292 fprintf(stderr, "error: %s: option '%s' "
294 argv[0], argv[optind - 1]);
299 fname = argv[optind];
302 (stripe_size_arg != NULL || stripe_off_arg != NULL ||
303 stripe_count_arg != NULL || pool_name_arg != NULL)) {
304 fprintf(stderr, "error: %s: cannot specify -d with "
305 "-s, -c -o or -p options\n",
311 if (optind == argc) {
312 fprintf(stderr, "error: %s: missing filename|dirname\n",
317 /* get the stripe size */
318 if (stripe_size_arg != NULL) {
319 result = parse_size(stripe_size_arg, &st_size, &size_units);
321 fprintf(stderr, "error: %s: bad size '%s'\n",
322 argv[0], stripe_size_arg);
326 /* get the stripe offset */
327 if (stripe_off_arg != NULL) {
328 st_offset = strtoul(stripe_off_arg, &end, 0);
330 fprintf(stderr, "error: %s: bad stripe offset '%s'\n",
331 argv[0], stripe_off_arg);
335 /* get the stripe count */
336 if (stripe_count_arg != NULL) {
337 st_count = strtoul(stripe_count_arg, &end, 0);
339 fprintf(stderr, "error: %s: bad stripe count '%s'\n",
340 argv[0], stripe_count_arg);
346 result = llapi_file_create_pool(fname, st_size, st_offset,
347 st_count, 0, pool_name_arg);
349 fprintf(stderr,"error: %s: create stripe file '%s' "
350 "failed\n", argv[0], fname);
353 fname = argv[++optind];
354 } while (fname != NULL);
359 static int lfs_poollist(int argc, char **argv)
364 return llapi_poollist(argv[1]);
367 static int set_time(time_t *time, time_t *set, char *str)
374 else if (str[0] == '-')
380 t = strtol(str, NULL, 0);
381 if (*time < t * 24 * 60 * 60) {
384 fprintf(stderr, "Wrong time '%s' is specified.\n", str);
388 *set = *time - t * 24 * 60 * 60;
392 static int name2id(unsigned int *id, char *name, int type)
394 if (type == USRQUOTA) {
395 struct passwd *entry;
397 if (!(entry = getpwnam(name))) {
407 if (!(entry = getgrnam(name))) {
419 static int id2name(char **name, unsigned int id, int type)
421 if (type == USRQUOTA) {
422 struct passwd *entry;
424 if (!(entry = getpwuid(id))) {
430 *name = entry->pw_name;
434 if (!(entry = getgrgid(id))) {
440 *name = entry->gr_name;
446 #define FIND_POOL_OPT 3
447 static int lfs_find(int argc, char **argv)
452 struct find_param param = { .maxdepth = -1 };
454 struct option long_opts[] = {
455 /* New find options. */
456 {"atime", required_argument, 0, 'A'},
457 {"ctime", required_argument, 0, 'C'},
458 {"mtime", required_argument, 0, 'M'},
459 {"maxdepth", required_argument, 0, 'D'},
460 {"gid", required_argument, 0, 'g'},
461 {"group", required_argument, 0, 'G'},
462 {"uid", required_argument, 0, 'u'},
463 {"user", required_argument, 0, 'U'},
464 {"name", required_argument, 0, 'n'},
465 /* no short option for pool, p/P already used */
466 {"pool", required_argument, 0, FIND_POOL_OPT},
467 /* --obd is considered as a new option. */
468 {"obd", required_argument, 0, 'O'},
469 {"ost", required_argument, 0, 'O'},
470 {"print", no_argument, 0, 'P'},
471 {"print0", no_argument, 0, 'p'},
472 /* Old find options. */
473 {"quiet", no_argument, 0, 'q'},
474 {"recursive", no_argument, 0, 'r'},
475 {"size", required_argument, 0, 's'},
476 {"type", required_argument, 0, 't'},
477 {"verbose", no_argument, 0, 'v'},
491 /* when getopt_long_only() hits '!' it returns 1 and puts "!" in optarg */
492 while ((c = getopt_long_only(argc, argv, "-A:C:D:g:G:M:n:PpO:qrs:t:u:U:v",
493 long_opts, NULL)) >= 0) {
498 /* '!' is part of option */
499 /* when getopt_long_only() finds a string which is not
500 * an option nor a known option argument it returns 1
501 * in that case if we already have found pathstart and pathend
502 * (i.e. we have the list of pathnames),
503 * the only supported value is "!"
505 isoption = (c != 1) || (strcmp(optarg, "!") == 0);
506 if (!isoption && pathend != -1) {
507 fprintf(stderr, "err: %s: filename|dirname must either "
508 "precede options or follow options\n",
512 if (!isoption && pathstart == -1)
513 pathstart = optind - 1;
514 if (isoption && pathstart != -1 && pathend == -1) {
515 pathend = optind - 2;
516 if ((c == 1 && strcmp(optarg, "!") == 0) ||
517 c == 'P' || c == 'p' || c == 'O' ||
518 c == 'q' || c == 'r' || c == 'v')
519 pathend = optind - 1;
526 /* unknown; opt is "!" or path component,
527 * checking done above.
529 if (strcmp(optarg, "!") == 0)
533 xtime = ¶m.atime;
534 xsign = ¶m.asign;
537 xtime = ¶m.ctime;
538 xsign = ¶m.csign;
542 xtime = ¶m.mtime;
543 xsign = ¶m.msign;
547 if (optarg[0] == '-')
549 else if (optarg[0] == '+')
558 ret = set_time(&t, xtime, optarg);
566 param.maxdepth = strtol(optarg, 0, 0);
570 param.gid = strtol(optarg, &endptr, 10);
571 if (optarg == endptr) {
572 fprintf(stderr, "Bad gid: %s\n", optarg);
575 param.exclude_gid = !!neg_opt;
580 param.gid = strtol(optarg, &endptr, 10);
581 if (optarg == endptr) {
582 ret = name2id(¶m.gid, optarg, GRPQUOTA);
584 fprintf(stderr, "Group/GID: %s cannot "
585 "be found.\n", optarg);
589 param.exclude_gid = !!neg_opt;
594 param.uid = strtol(optarg, &endptr, 10);
595 if (optarg == endptr) {
596 fprintf(stderr, "Bad uid: %s\n", optarg);
599 param.exclude_uid = !!neg_opt;
604 param.uid = strtol(optarg, &endptr, 10);
605 if (optarg == endptr) {
606 ret = name2id(¶m.uid, optarg, USRQUOTA);
608 fprintf(stderr, "User/UID: %s cannot "
609 "be found.\n", optarg);
613 param.exclude_uid = !!neg_opt;
618 if (strlen(optarg) > LOV_MAXPOOLNAME) {
620 "Pool name %s is too long"
621 " (max is %d)\n", optarg,
625 /* we do check for empty pool because empty pool
626 * is used to find V1 lov attributes */
627 strncpy(param.poolname, optarg, LOV_MAXPOOLNAME);
628 param.poolname[LOV_MAXPOOLNAME] = '\0';
629 param.exclude_pool = !!neg_opt;
630 param.check_pool = 1;
634 param.pattern = (char *)optarg;
635 param.exclude_pattern = !!neg_opt;
638 char *buf, *token, *next, *p;
641 len = strlen((char *)optarg);
645 strcpy(buf, (char *)optarg);
647 if (param.num_alloc_obds == 0) {
648 param.obduuid = malloc(FIND_MAX_OSTS *
649 sizeof(struct obd_uuid));
650 if (param.obduuid == NULL)
652 param.num_alloc_obds = INIT_ALLOC_NUM_OSTS;
655 for (token = buf; token && *token; token = next) {
656 p = strchr(token, ',');
662 strcpy((char *)¶m.obduuid[param.num_obds++].uuid,
686 param.exclude_type = !!neg_opt;
688 case 'b': param.type = S_IFBLK; break;
689 case 'c': param.type = S_IFCHR; break;
690 case 'd': param.type = S_IFDIR; break;
691 case 'f': param.type = S_IFREG; break;
692 case 'l': param.type = S_IFLNK; break;
693 case 'p': param.type = S_IFIFO; break;
694 case 's': param.type = S_IFSOCK; break;
695 #ifdef S_IFDOOR /* Solaris only */
696 case 'D': param.type = S_IFDOOR; break;
698 default: fprintf(stderr, "error: %s: bad type '%s'\n",
705 if (optarg[0] == '-')
707 else if (optarg[0] == '+')
716 if (optarg[0] == '+')
717 param.size_sign = -1;
718 else if (optarg[0] == '-')
719 param.size_sign = +1;
723 ret = parse_size(optarg, ¶m.size,¶m.size_units);
725 fprintf(stderr,"error: bad size '%s'\n",
738 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
739 argv[0], argv[optind - 1]);
744 if (pathstart == -1) {
745 fprintf(stderr, "error: %s: no filename|pathname\n",
748 } else if (pathend == -1) {
756 static int deprecated_warning;
757 if (!deprecated_warning) {
758 fprintf(stderr, "lfs find: -q, -r, -v options "
759 "deprecated. Use 'lfs getstripe' instead.\n");
760 deprecated_warning = 1;
762 if (!param.recursive && param.maxdepth == -1)
768 ret = llapi_find(argv[pathstart], ¶m);
770 ret = llapi_getstripe(argv[pathstart], ¶m);
771 } while (++pathstart < pathend && !ret);
774 fprintf(stderr, "error: %s failed for %s.\n",
775 argv[0], argv[optind - 1]);
777 if (param.obduuid && param.num_alloc_obds)
783 static int lfs_getstripe(int argc, char **argv)
785 struct option long_opts[] = {
787 {"quiet", 0, 0, 'q'},
788 {"recursive", 0, 0, 'r'},
789 {"verbose", 0, 0, 'v'},
792 char short_opts[] = "hO:qrv";
794 struct find_param param = { 0 };
797 while ((c = getopt_long(argc, argv, short_opts,
798 long_opts, NULL)) != -1) {
803 "error: %s: only one obduuid allowed",
807 param.obduuid = (struct obd_uuid *)optarg;
823 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
824 argv[0], argv[optind - 1]);
832 param.maxdepth = param.recursive ? -1 : 1;
835 rc = llapi_getstripe(argv[optind], ¶m);
836 } while (++optind < argc && !rc);
839 fprintf(stderr, "error: %s failed for %s.\n",
840 argv[0], argv[optind - 1]);
844 static int lfs_osts(int argc, char **argv)
847 struct mntent *mnt = NULL;
848 struct find_param param;
854 fp = setmntent(MOUNTED, "r");
857 fprintf(stderr, "%s: setmntent(%s): %s:", argv[0], MOUNTED,
861 while (feof(fp) == 0 && ferror(fp) ==0) {
862 memset(¶m, 0, sizeof(param));
863 if (llapi_is_lustre_mnt(mnt)) {
864 rc = llapi_getstripe(mnt->mnt_dir, ¶m);
867 "error: %s: failed on %s\n",
868 argv[0], mnt->mnt_dir);
878 #define COOK(value) \
881 while (value > 1024) { \
895 static int path2mnt(char *path, FILE *fp, char *mntdir, int dir_len)
897 char rpath[PATH_MAX] = {'\0'};
899 int rc, len, out_len = 0;
901 if (!realpath(path, rpath)) {
903 fprintf(stderr, "error: lfs df: invalid path '%s': %s\n",
904 path, strerror(-rc));
910 while (feof(fp) == 0 && ferror(fp) == 0) {
911 if (llapi_is_lustre_mnt(mnt)) {
912 len = strlen(mnt->mnt_dir);
914 !strncmp(rpath, mnt->mnt_dir, len)) {
916 memset(mntdir, 0, dir_len);
917 strncpy(mntdir, mnt->mnt_dir, dir_len);
926 fprintf(stderr, "error: lfs df: %s isn't mounted on lustre\n", path);
930 static int showdf(char *mntdir, struct obd_statfs *stat,
931 char *uuid, int ishow, int cooked,
932 char *type, int index, int rc)
934 long long avail, used, total;
936 char *suffix = "KMGTPEZY";
937 /* Note if we have >2^64 bytes/fs these buffers will need to be grown */
938 char tbuf[20], ubuf[20], abuf[20], rbuf[20];
946 avail = stat->os_ffree;
947 used = stat->os_files - stat->os_ffree;
948 total = stat->os_files;
950 int shift = cooked ? 0 : 10;
952 avail = (stat->os_bavail * stat->os_bsize) >> shift;
953 used = ((stat->os_blocks - stat->os_bfree) *
954 stat->os_bsize) >> shift;
955 total = (stat->os_blocks * stat->os_bsize) >> shift;
959 ratio = (double)used / (double)total;
965 cook_val = (double)total;
968 sprintf(tbuf, HDF"%c", cook_val, suffix[i - 1]);
970 sprintf(tbuf, CDF, total);
972 cook_val = (double)used;
975 sprintf(ubuf, HDF"%c", cook_val, suffix[i - 1]);
977 sprintf(ubuf, CDF, used);
979 cook_val = (double)avail;
982 sprintf(abuf, HDF"%c", cook_val, suffix[i - 1]);
984 sprintf(abuf, CDF, avail);
986 sprintf(tbuf, CDF, total);
987 sprintf(ubuf, CDF, used);
988 sprintf(abuf, CDF, avail);
991 sprintf(rbuf, RDF, (int)(ratio * 100));
992 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s",
993 uuid, tbuf, ubuf, abuf, rbuf, mntdir);
995 printf("[%s:%d]\n", type, index);
1001 printf(UUF": inactive device\n", uuid);
1004 printf(UUF": %s\n", uuid, strerror(-rc));
1011 static int mntdf(char *mntdir, int ishow, int cooked)
1013 struct obd_statfs stat_buf, sum = { .os_bsize = 1 };
1014 struct obd_uuid uuid_buf;
1019 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s\n",
1020 "UUID", "Inodes", "IUsed", "IFree",
1021 "IUse%", "Mounted on");
1023 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s\n",
1024 "UUID", cooked ? "bytes" : "1K-blocks",
1025 "Used", "Available", "Use%", "Mounted on");
1027 for (index = 0; ; index++) {
1028 memset(&stat_buf, 0, sizeof(struct obd_statfs));
1029 memset(&uuid_buf, 0, sizeof(struct obd_uuid));
1030 rc = llapi_obd_statfs(mntdir, LL_STATFS_MDC, index,
1031 &stat_buf, &uuid_buf);
1038 if (rc == -ENOTCONN || rc == -ETIMEDOUT || rc == -EIO ||
1039 rc == -ENODATA || rc == 0) {
1040 showdf(mntdir, &stat_buf, uuid_buf.uuid, ishow, cooked,
1044 "error: llapi_obd_statfs(%s): %s (%d)\n",
1045 uuid_buf.uuid, strerror(-rc), rc);
1049 sum.os_ffree += stat_buf.os_ffree;
1050 sum.os_files += stat_buf.os_files;
1054 for (index = 0; ; index++) {
1055 memset(&stat_buf, 0, sizeof(struct obd_statfs));
1056 memset(&uuid_buf, 0, sizeof(struct obd_uuid));
1057 rc = llapi_obd_statfs(mntdir, LL_STATFS_LOV, index,
1058 &stat_buf, &uuid_buf);
1065 if (rc == -ENOTCONN || rc == -ETIMEDOUT || rc == -EIO ||
1066 rc == -ENODATA || rc == 0) {
1067 showdf(mntdir, &stat_buf, uuid_buf.uuid, ishow, cooked,
1071 "error: llapi_obd_statfs failed: %s (%d)\n",
1076 sum.os_blocks += stat_buf.os_blocks * stat_buf.os_bsize;
1077 sum.os_bfree += stat_buf.os_bfree * stat_buf.os_bsize;
1078 sum.os_bavail += stat_buf.os_bavail * stat_buf.os_bsize;
1083 showdf(mntdir, &sum, "filesystem summary:", ishow, cooked, NULL, 0,0);
1088 static int lfs_df(int argc, char **argv)
1092 struct mntent *mnt = NULL;
1093 char *mntdir = NULL;
1094 int ishow = 0, cooked = 0;
1098 while ((c = getopt(argc, argv, "ih")) != -1) {
1111 path = argv[optind];
1113 fp = setmntent(MOUNTED, "r");
1116 fprintf(stderr, "error: %s: open %s failed( %s )\n",
1117 argv[0], MOUNTED, strerror(errno));
1121 if ((mntdir = malloc(PATH_MAX)) == NULL) {
1122 fprintf(stderr, "error: cannot allocate %d bytes\n",
1126 memset(mntdir, 0, PATH_MAX);
1129 rc = path2mnt(path, fp, mntdir, PATH_MAX);
1136 rc = mntdf(mntdir, ishow, cooked);
1140 mnt = getmntent(fp);
1141 while (feof(fp) == 0 && ferror(fp) == 0) {
1142 if (llapi_is_lustre_mnt(mnt)) {
1143 rc = mntdf(mnt->mnt_dir, ishow, cooked);
1148 mnt = getmntent(fp);
1157 static int lfs_check(int argc, char **argv)
1161 struct mntent *mnt = NULL;
1170 obd_types[0] = obd_type1;
1171 obd_types[1] = obd_type2;
1173 if (strcmp(argv[1], "osts") == 0) {
1174 strcpy(obd_types[0], "osc");
1175 } else if (strcmp(argv[1], "mds") == 0) {
1176 strcpy(obd_types[0], "mdc");
1177 } else if (strcmp(argv[1], "servers") == 0) {
1179 strcpy(obd_types[0], "osc");
1180 strcpy(obd_types[1], "mdc");
1182 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
1187 fp = setmntent(MOUNTED, "r");
1189 fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
1192 mnt = getmntent(fp);
1193 while (feof(fp) == 0 && ferror(fp) ==0) {
1194 if (llapi_is_lustre_mnt(mnt))
1196 mnt = getmntent(fp);
1202 fprintf(stderr, "No suitable Lustre mount found\n");
1206 rc = llapi_target_check(num_types, obd_types, mnt->mnt_dir);
1209 fprintf(stderr, "error: %s: %s status failed\n",
1216 static int lfs_catinfo(int argc, char **argv)
1219 struct mntent *mnt = NULL;
1222 if (argc < 2 || (!strcmp(argv[1],"config") && argc < 3))
1225 if (strcmp(argv[1], "config") && strcmp(argv[1], "deletions"))
1228 fp = setmntent(MOUNTED, "r");
1230 fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
1233 mnt = getmntent(fp);
1234 while (feof(fp) == 0 && ferror(fp) == 0) {
1235 if (llapi_is_lustre_mnt(mnt))
1237 mnt = getmntent(fp);
1244 rc = llapi_catinfo(mnt->mnt_dir, argv[1], argv[2]);
1246 rc = llapi_catinfo(mnt->mnt_dir, argv[1], NULL);
1248 fprintf(stderr, "no lustre_lite mounted.\n");
1255 int lfs_join(int argc, char **argv)
1257 char *name_head, *name_tail;
1263 name_head = argv[1];
1264 fd = open(name_head, O_WRONLY);
1266 fprintf(stderr, "Can not open name_head %s rc=%d\n",
1270 size = lseek(fd, 0, SEEK_END);
1271 if (size % JOIN_FILE_ALIGN) {
1272 fprintf(stderr,"head file %s size %llu must be mutiple of %d\n",
1273 name_head, (long long)size, JOIN_FILE_ALIGN);
1277 name_tail = argv[2];
1278 rc = ioctl(fd, LL_IOC_JOIN, name_tail);
1282 fprintf(stderr, "Lustre joining files: %s, %s, failed\n",
1288 #ifdef HAVE_QUOTA_SUPPORT
1289 static int lfs_quotachown(int argc, char **argv)
1296 while ((c = getopt(argc, argv, "i")) != -1) {
1302 fprintf(stderr, "error: %s: option '-%c' "
1303 "unrecognized\n", argv[0], c);
1309 rc = llapi_quotachown(argv[optind], flag);
1311 fprintf(stderr,"error: change file owner/group failed.\n");
1316 static int lfs_quotacheck(int argc, char **argv)
1318 int c, check_type = 0;
1320 struct if_quotacheck qchk;
1321 struct if_quotactl qctl;
1322 char *obd_type = qchk.obd_type;
1323 char *obd_uuid = qchk.obd_uuid.uuid;
1326 memset(&qchk, 0, sizeof(qchk));
1329 while ((c = getopt(argc, argv, "ug")) != -1) {
1338 fprintf(stderr, "error: %s: option '-%c' "
1339 "unrecognized\n", argv[0], c);
1346 else /* do quotacheck for both user & group quota by default */
1354 memset(&qctl, 0, sizeof(qctl));
1355 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1356 qctl.qc_id = QFMT_LDISKFS;
1357 qctl.qc_type = check_type;
1358 rc = llapi_quotactl(mnt, &qctl);
1360 fprintf(stderr, "quota off failed: %s\n", strerror(errno));
1364 rc = llapi_quotacheck(mnt, check_type);
1366 fprintf(stderr, "quotacheck failed: %s\n", strerror(errno));
1370 rc = llapi_poll_quotacheck(mnt, &qchk);
1373 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1374 fprintf(stderr, "quota check failed: %s\n", strerror(errno));
1378 memset(&qctl, 0, sizeof(qctl));
1379 qctl.qc_cmd = LUSTRE_Q_QUOTAON;
1380 qctl.qc_id = QFMT_LDISKFS;
1381 qctl.qc_type = check_type;
1382 rc = llapi_quotactl(mnt, &qctl);
1385 fprintf(stderr, "%s %s ",
1386 qctl.obd_type, qctl.obd_uuid.uuid);
1387 fprintf(stderr, "%s turn on quota failed: %s\n",
1388 argv[0], strerror(errno));
1395 static int lfs_quotaon(int argc, char **argv)
1399 struct if_quotactl qctl;
1400 char *obd_type = qctl.obd_type;
1401 char *obd_uuid = qctl.obd_uuid.uuid;
1404 memset(&qctl, 0, sizeof(qctl));
1405 qctl.qc_cmd = LUSTRE_Q_QUOTAON;
1406 qctl.qc_id = QFMT_LDISKFS;
1409 while ((c = getopt(argc, argv, "ugf")) != -1) {
1412 qctl.qc_type |= 0x01;
1415 qctl.qc_type |= 0x02;
1418 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1421 fprintf(stderr, "error: %s: option '-%c' "
1422 "unrecognized\n", argv[0], c);
1429 else /* by default, enable quota for both user & group */
1430 qctl.qc_type = 0x02;
1437 rc = llapi_quotactl(mnt, &qctl);
1440 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1441 fprintf(stderr, "%s failed: %s\n", argv[0], strerror(errno));
1448 static int lfs_quotaoff(int argc, char **argv)
1452 struct if_quotactl qctl;
1453 char *obd_type = qctl.obd_type;
1454 char *obd_uuid = qctl.obd_uuid.uuid;
1457 memset(&qctl, 0, sizeof(qctl));
1458 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1461 while ((c = getopt(argc, argv, "ug")) != -1) {
1464 qctl.qc_type |= 0x01;
1467 qctl.qc_type |= 0x02;
1470 fprintf(stderr, "error: %s: option '-%c' "
1471 "unrecognized\n", argv[0], c);
1478 else /* by default, disable quota for both user & group */
1479 qctl.qc_type = 0x02;
1486 rc = llapi_quotactl(mnt, &qctl);
1489 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1490 fprintf(stderr, "quotaoff failed: %s\n", strerror(errno));
1497 #define ARG2INT(nr, str, msg) \
1500 nr = strtol(str, &endp, 0); \
1502 fprintf(stderr, "error: bad %s: %s\n", msg, str); \
1507 #define ADD_OVERFLOW(a,b) ((a + b) < a) ? (a = ULONG_MAX) : (a = a + b)
1509 /* Convert format time string "XXwXXdXXhXXmXXs" into seconds value
1510 * returns the value or ULONG_MAX on integer overflow or incorrect format
1512 * 1. the order of specifiers is arbitrary (may be: 5w3s or 3s5w)
1513 * 2. specifiers may be encountered multiple times (2s3s is 5 seconds)
1514 * 3. empty integer value is interpreted as 0
1517 static unsigned long str2sec(const char* timestr) {
1518 const char spec[] = "smhdw";
1519 const unsigned long mult[] = {1, 60, 60*60, 24*60*60, 7*24*60*60};
1520 unsigned long val = 0;
1523 if (strpbrk(timestr, spec) == NULL) {
1524 /* no specifiers inside the time string,
1525 should treat it as an integer value */
1526 val = strtoul(timestr, &tail, 10);
1527 return *tail ? ULONG_MAX : val;
1530 /* format string is XXwXXdXXhXXmXXs */
1536 v = strtoul(timestr, &tail, 10);
1537 if (v == ULONG_MAX || *tail == '\0')
1538 /* value too large (ULONG_MAX or more)
1539 or missing specifier */
1542 ptr = strchr(spec, *tail);
1544 /* unknown specifier */
1549 /* check if product will overflow the type */
1550 if (!(v < ULONG_MAX / mult[ind]))
1553 ADD_OVERFLOW(val, mult[ind] * v);
1554 if (val == ULONG_MAX)
1566 int lfs_setquota(int argc, char **argv)
1570 struct if_quotactl qctl;
1571 char *obd_type = qctl.obd_type;
1572 char *obd_uuid = qctl.obd_uuid.uuid;
1575 memset(&qctl, 0, sizeof(qctl));
1576 qctl.qc_cmd = LUSTRE_Q_SETQUOTA;
1579 while ((c = getopt(argc, argv, "ugt")) != -1) {
1582 qctl.qc_type |= 0x01;
1585 qctl.qc_type |= 0x02;
1588 qctl.qc_cmd = LUSTRE_Q_SETINFO;
1591 fprintf(stderr, "error: %s: option '-%c' "
1592 "unrecognized\n", argv[0], c);
1600 if (qctl.qc_type == UGQUOTA) {
1601 fprintf(stderr, "error: user and group quotas can't be set "
1606 if (qctl.qc_cmd == LUSTRE_Q_SETQUOTA) {
1607 struct obd_dqblk *dqb = &qctl.qc_dqblk;
1609 if (optind + 6 != argc)
1612 rc = name2id(&qctl.qc_id, argv[optind++], qctl.qc_type);
1614 fprintf(stderr, "error: find id for name %s failed: %s\n",
1615 argv[optind - 1], strerror(errno));
1619 ARG2INT(dqb->dqb_bsoftlimit, argv[optind++], "block-softlimit");
1620 ARG2INT(dqb->dqb_bhardlimit, argv[optind++], "block-hardlimit");
1621 ARG2INT(dqb->dqb_isoftlimit, argv[optind++], "inode-softlimit");
1622 ARG2INT(dqb->dqb_ihardlimit, argv[optind++], "inode-hardlimit");
1624 dqb->dqb_valid = QIF_LIMITS;
1626 struct obd_dqinfo *dqi = &qctl.qc_dqinfo;
1628 if (optind + 3 != argc)
1631 if ((dqi->dqi_bgrace = str2sec(argv[optind++])) == ULONG_MAX) {
1632 fprintf(stderr, "error: bad %s: %s\n", "block-grace", argv[optind - 1]);
1635 if ((dqi->dqi_igrace = str2sec(argv[optind++])) == ULONG_MAX) {
1636 fprintf(stderr, "error: bad %s: %s\n", "inode-grace", argv[optind - 1]);
1643 rc = llapi_quotactl(mnt, &qctl);
1646 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1647 fprintf(stderr, "setquota failed: %s\n", strerror(errno));
1654 static inline char *type2name(int check_type)
1656 if (check_type == USRQUOTA)
1658 else if (check_type == GRPQUOTA)
1665 /* Converts seconds value into format string
1666 * result is returned in buf
1668 * 1. result is in descenting order: 1w2d3h4m5s
1669 * 2. zero fields are not filled (except for p. 3): 5d1s
1670 * 3. zero seconds value is presented as "0s"
1672 static void sec2str(time_t seconds, char *buf)
1674 const char spec[] = "smhdw";
1675 const unsigned long mult[] = {1, 60, 60*60, 24*60*60, 7*24*60*60};
1680 for (i = sizeof(mult) / sizeof(mult[0]) - 1 ; i >= 0; i--) {
1681 c = seconds / mult[i];
1683 if (c > 0 || (i == 0 && buf == tail))
1684 tail += snprintf(tail, 40-(tail-buf), "%lu%c", c, spec[i]);
1691 static void diff2str(time_t seconds, char *buf, time_t now)
1697 if (seconds <= now) {
1698 strcpy(buf, "none");
1701 sec2str(seconds - now, buf);
1704 static void print_quota_title(char *name, struct if_quotactl *qctl)
1706 printf("Disk quotas for %s %s (%cid %u):\n",
1707 type2name(qctl->qc_type), name,
1708 *type2name(qctl->qc_type), qctl->qc_id);
1709 printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n",
1711 "kbytes", "quota", "limit", "grace",
1712 "files", "quota", "limit", "grace");
1715 static void print_quota(char *mnt, struct if_quotactl *qctl, int ost_only)
1721 if (qctl->qc_cmd == LUSTRE_Q_GETQUOTA || qctl->qc_cmd == Q_GETOQUOTA) {
1722 int bover = 0, iover = 0;
1723 struct obd_dqblk *dqb = &qctl->qc_dqblk;
1725 if (dqb->dqb_bhardlimit &&
1726 toqb(dqb->dqb_curspace) > dqb->dqb_bhardlimit) {
1728 } else if (dqb->dqb_bsoftlimit &&
1729 toqb(dqb->dqb_curspace) > dqb->dqb_bsoftlimit) {
1730 if (dqb->dqb_btime > now) {
1737 if (dqb->dqb_ihardlimit &&
1738 dqb->dqb_curinodes > dqb->dqb_ihardlimit) {
1740 } else if (dqb->dqb_isoftlimit &&
1741 dqb->dqb_curinodes > dqb->dqb_isoftlimit) {
1742 if (dqb->dqb_btime > now) {
1749 #if 0 /* XXX: always print quotas even when no usages */
1750 if (dqb->dqb_curspace || dqb->dqb_curinodes)
1756 if (strlen(mnt) > 15)
1757 printf("%s\n%15s", mnt, "");
1759 printf("%15s", mnt);
1762 diff2str(dqb->dqb_btime, timebuf, now);
1764 sprintf(numbuf[0], LPU64, toqb(dqb->dqb_curspace));
1765 sprintf(numbuf[1], LPU64, dqb->dqb_bsoftlimit);
1766 sprintf(numbuf[2], LPU64, dqb->dqb_bhardlimit);
1767 printf(" %7s%c %6s %7s %7s",
1768 numbuf[0], bover ? '*' : ' ', numbuf[1],
1769 numbuf[2], bover > 1 ? timebuf : "");
1772 diff2str(dqb->dqb_itime, timebuf, now);
1774 sprintf(numbuf[0], LPU64, dqb->dqb_curinodes);
1775 sprintf(numbuf[1], LPU64, dqb->dqb_isoftlimit);
1776 sprintf(numbuf[2], LPU64, dqb->dqb_ihardlimit);
1778 printf(" %7s%c %6s %7s %7s",
1779 numbuf[0], iover ? '*' : ' ', numbuf[1],
1780 numbuf[2], iover > 1 ? timebuf : "");
1783 } else if (qctl->qc_cmd == LUSTRE_Q_GETINFO ||
1784 qctl->qc_cmd == Q_GETOINFO) {
1788 sec2str(qctl->qc_dqinfo.dqi_bgrace, bgtimebuf);
1789 sec2str(qctl->qc_dqinfo.dqi_igrace, igtimebuf);
1790 printf("Block grace time: %s; Inode grace time: %s\n",
1791 bgtimebuf, igtimebuf);
1795 static void print_mds_quota(char *mnt, struct if_quotactl *qctl)
1799 /* XXX: this is a flag to mark that only mds quota is wanted */
1800 qctl->qc_dqblk.dqb_valid = 1;
1801 rc = llapi_quotactl(mnt, qctl);
1803 fprintf(stderr, "quotactl failed: %s\n", strerror(errno));
1806 qctl->qc_dqblk.dqb_valid = 0;
1808 print_quota(qctl->obd_uuid.uuid, qctl, 0);
1811 static void print_lov_quota(char *mnt, struct if_quotactl *qctl)
1814 struct obd_uuid *uuids = NULL, *uuidp;
1815 int obdcount = 1024;
1820 fprintf(stderr, "open %s failed: %s\n", mnt, strerror(errno));
1824 uuids = (struct obd_uuid *)malloc(INIT_ALLOC_NUM_OSTS *
1825 sizeof(struct obd_uuid));
1830 rc = llapi_lov_get_uuids(dirfd(dir), uuids, &obdcount);
1832 struct obd_uuid *uuids_temp;
1834 if (rc == -EOVERFLOW) {
1835 uuids_temp = realloc(uuids, obdcount *
1836 sizeof(struct obd_uuid));
1837 if (uuids_temp != NULL)
1838 goto retry_get_uuids;
1843 fprintf(stderr, "get ost uuid failed: %s\n", strerror(rc));
1847 for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) {
1848 memcpy(&qctl->obd_uuid, uuidp, sizeof(*uuidp));
1850 /* XXX clear this flag to get quota from osts */
1851 qctl->qc_dqblk.dqb_valid = 0;
1852 rc = llapi_quotactl(mnt, qctl);
1854 fprintf(stderr, "%s quotactl failed: %s\n",
1855 uuidp->uuid, strerror(errno));
1859 print_quota(uuidp->uuid, qctl, 1);
1867 static int lfs_quota(int argc, char **argv)
1870 char *name = NULL, *mnt;
1871 struct if_quotactl qctl = { .qc_cmd = LUSTRE_Q_GETQUOTA,
1873 char *obd_type = qctl.obd_type;
1874 char *obd_uuid = qctl.obd_uuid.uuid;
1878 while ((c = getopt(argc, argv, "ugto:")) != -1) {
1881 qctl.qc_type = 0x01;
1884 qctl.qc_type = 0x02;
1887 qctl.qc_cmd = LUSTRE_Q_GETINFO;
1890 strncpy(obd_uuid, optarg, sizeof(qctl.obd_uuid));
1893 fprintf(stderr, "error: %s: option '-%c' "
1894 "unrecognized\n", argv[0], c);
1903 if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
1904 if (optind + 2 != argc) {
1905 fprintf(stderr, "error: missing quota argument(s)\n");
1909 name = argv[optind++];
1910 rc = name2id(&qctl.qc_id, name, qctl.qc_type);
1912 fprintf(stderr,"error: can't find id for name %s: %s\n",
1913 name, strerror(errno));
1916 print_quota_title(name, &qctl);
1917 } else if (optind + 1 != argc) {
1918 fprintf(stderr, "error: missing quota info argument(s)\n");
1924 rc = llapi_quotactl(mnt, &qctl);
1927 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1928 fprintf(stderr, "quota failed: %s\n", strerror(errno));
1933 rc = id2name(&name, getuid(), qctl.qc_type);
1940 print_quota(mnt, &qctl, 0);
1942 if (!*obd_uuid && qctl.qc_cmd != LUSTRE_Q_GETINFO) {
1943 print_mds_quota(mnt, &qctl);
1944 print_lov_quota(mnt, &qctl);
1949 #endif /* HAVE_QUOTA_SUPPORT */
1951 static int flushctx_ioctl(char *mp)
1955 fd = open(mp, O_RDONLY);
1957 fprintf(stderr, "flushctx: error open %s: %s\n",
1958 mp, strerror(errno));
1962 rc = ioctl(fd, LL_IOC_FLUSHCTX);
1964 fprintf(stderr, "flushctx: error ioctl %s: %s\n",
1965 mp, strerror(errno));
1971 static int lfs_flushctx(int argc, char **argv)
1973 int kdestroy = 0, c;
1975 char procline[PATH_MAX], *line;
1979 while ((c = getopt(argc, argv, "k")) != -1) {
1985 fprintf(stderr, "error: %s: option '-%c' "
1986 "unrecognized\n", argv[0], c);
1992 system("kdestroy > /dev/null");
1994 if (optind >= argc) {
1995 /* flush for all mounted lustre fs. */
1996 proc = fopen("/proc/mounts", "r");
1998 fprintf(stderr, "error: %s: can't open /proc/mounts\n",
2003 while ((line = fgets(procline, PATH_MAX, proc)) != NULL) {
2008 if (sscanf(line, "%s %s %s", dev, mp, fs) != 3) {
2009 fprintf(stderr, "%s: unexpected format in "
2015 if (strcmp(fs, "lustre") != 0)
2017 /* we use '@' to determine it's a client. are there
2018 * any other better way?
2020 if (strchr(dev, '@') == NULL)
2023 if (flushctx_ioctl(mp))
2027 /* flush fs as specified */
2028 while (optind < argc) {
2029 if (flushctx_ioctl(argv[optind++]))
2037 static int lfs_lsetfacl(int argc, char **argv)
2040 return(llapi_lsetfacl(argc, argv));
2043 static int lfs_lgetfacl(int argc, char **argv)
2046 return(llapi_lgetfacl(argc, argv));
2049 static int lfs_rsetfacl(int argc, char **argv)
2052 return(llapi_rsetfacl(argc, argv));
2055 static int lfs_rgetfacl(int argc, char **argv)
2058 return(llapi_rgetfacl(argc, argv));
2061 static int lfs_cp(int argc, char **argv)
2063 return(llapi_cp(argc, argv));
2066 static int lfs_ls(int argc, char **argv)
2068 return(llapi_ls(argc, argv));
2071 int main(int argc, char **argv)
2077 ptl_initialize(argc, argv);
2078 if (obd_initialize(argc, argv) < 0)
2080 if (dbg_initialize(argc, argv) < 0)
2083 Parser_init("lfs > ", cmdlist);
2086 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
2088 rc = Parser_commands();
2091 obd_finalize(argc, argv);