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);
103 static int lfs_path2fid(int argc, char **argv);
105 /* all avaialable commands */
106 command_t cmdlist[] = {
107 {"setstripe", lfs_setstripe, 0,
108 "Create a new file with a specific striping pattern or\n"
109 "set the default striping pattern on an existing directory or\n"
110 "delete the default striping pattern from an existing directory\n"
111 "usage: setstripe [--size|-s stripe_size] [--offset|-o start_ost]\n"
112 " [--count|-c stripe_count] [--pool|-p pool_name]\n"
115 " setstripe -d <dir> (to delete default striping)\n"
116 "\tstripe_size: Number of bytes on each OST (0 filesystem default)\n"
117 "\t Can be specified with k, m or g (in KB, MB and GB\n"
119 "\tstart_ost: OST index of first stripe (-1 filesystem default)\n"
120 "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n"
121 "\tpool_name: Name of OST pool"},
122 {"getstripe", lfs_getstripe, 0,
123 "To list the striping info for a given file or files in a\n"
124 "directory or recursively for all files in a directory tree.\n"
125 "usage: getstripe [--obd|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
126 " [--recursive | -r] <dir|file> ..."},
127 {"poollist", lfs_poollist, 0,
128 "List pools or pool OSTs\n"
129 "usage: poollist <fsname>[.<poolname>] | <pathname>\n"},
130 {"find", lfs_find, 0,
131 "To find files that match given parameters recursively in a directory tree.\n"
132 "usage: find <dir|file> ... \n"
133 " [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n"
134 " [--maxdepth|-D N] [[!] --name|-n <pattern>] [--print0|-P]\n"
135 " [--print|-p] [--obd|-O <uuid[s]>] [[!] --size|-s [+-]N[bkMGTP]]\n"
136 " [[!] --type|-t <filetype>] [[!] --gid|-g N] [[!] --group|-G <name>]\n"
137 " [[!] --uid|-u N] [[!] --user|-U <name>]\n"
138 " [[!] --pool <name>]\n"
139 "\t !: used before an option indicates 'NOT' the requested attribute\n"
140 "\t -: used before an value indicates 'AT MOST' the requested value\n"
141 "\t +: used before an option indicates 'AT LEAST' the requested value\n"},
142 {"check", lfs_check, 0,
143 "Display the status of MDS or OSTs (as specified in the command)\n"
144 "or all the servers (MDS and OSTs).\n"
145 "usage: check <osts|mds|servers>"},
146 {"catinfo", lfs_catinfo, 0,
147 "Show information of specified type logs.\n"
148 "usage: catinfo {keyword} [node name]\n"
149 "\tkeywords are one of followings: config, deletions.\n"
150 "\tnode name must be provided when use keyword config."},
151 {"join", lfs_join, 0,
152 "join two lustre files into one - join A, B, will be like cat B >> A & del B\n"
153 "usage: join <filename_A> <filename_B>\n"},
154 {"osts", lfs_osts, 0, "osts"},
156 "report filesystem disk space usage or inodes usage"
158 "Usage: df [-i] [-h] [path]"},
159 #ifdef HAVE_QUOTA_SUPPORT
160 {"quotachown",lfs_quotachown, 0,
161 "Change files' owner or group on the specified filesystem.\n"
162 "usage: quotachown [-i] <filesystem>\n"
163 "\t-i: ignore error if file is not exist\n"},
164 {"quotacheck", lfs_quotacheck, 0,
165 "Scan the specified filesystem for disk usage, and create,\n"
166 "or update quota files.\n"
167 "usage: quotacheck [ -ug ] <filesystem>"},
168 {"quotaon", lfs_quotaon, 0, "Turn filesystem quotas on.\n"
169 "usage: quotaon [ -ugf ] <filesystem>"},
170 {"quotaoff", lfs_quotaoff, 0, "Turn filesystem quotas off.\n"
171 "usage: quotaoff [ -ug ] <filesystem>"},
172 {"setquota", lfs_setquota, 0, "Set filesystem quotas.\n"
173 "usage: setquota [ -u | -g ] <name> <block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> <filesystem>\n"
174 " setquota -t [ -u | -g ] <block-grace> <inode-grace> <filesystem>"},
175 {"quota", lfs_quota, 0, "Display disk usage and limits.\n"
176 "usage: quota [ -o obd_uuid ] [{-u|-g <name>}|-t] <filesystem>"},
178 {"flushctx", lfs_flushctx, 0, "Flush security context for current user.\n"
179 "usage: flushctx [-k] [mountpoint...]"},
180 {"lsetfacl", lfs_lsetfacl, 0,
181 "Remote user setfacl for user/group on the same remote client.\n"
182 "usage: lsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
183 {"lgetfacl", lfs_lgetfacl, 0,
184 "Remote user getfacl for user/group on the same remote client.\n"
185 "usage: lgetfacl [-dRLPvh] file ..."},
186 {"rsetfacl", lfs_rsetfacl, 0,
187 "Remote user setfacl for user/group on other clients.\n"
188 "usage: rsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
189 {"rgetfacl", lfs_rgetfacl, 0,
190 "Remote user getfacl for user/group on other clients.\n"
191 "usage: rgetfacl [-dRLPvh] file ..."},
193 "Remote user copy files and directories.\n"
194 "usage: cp [OPTION]... [-T] SOURCE DEST\n\tcp [OPTION]... SOURCE... DIRECTORY\n\tcp [OPTION]... -t DIRECTORY SOURCE..."},
196 "Remote user list directory contents.\n"
197 "usage: ls [OPTION]... [FILE]..."},
198 {"path2fid", lfs_path2fid, 0, "Display the fid for a given path.\n"
199 "usage: path2fid <path>"},
200 {"help", Parser_help, 0, "help"},
201 {"exit", Parser_quit, 0, "quit"},
202 {"quit", Parser_quit, 0, "quit"},
206 static int isnumber(const char *str)
210 if (str[0] != '-' && !isdigit(str[0]))
213 for (ptr = str + 1; *ptr != '\0'; ptr++) {
222 static int lfs_setstripe(int argc, char **argv)
226 unsigned long long st_size;
227 int st_offset, st_count;
231 char *stripe_size_arg = NULL;
232 char *stripe_off_arg = NULL;
233 char *stripe_count_arg = NULL;
234 char *pool_name_arg = NULL;
235 unsigned long long size_units;
237 struct option long_opts[] = {
238 {"size", required_argument, 0, 's'},
239 {"count", required_argument, 0, 'c'},
240 {"index", required_argument, 0, 'i'},
241 {"offset", required_argument, 0, 'o'},
242 {"pool", required_argument, 0, 'p'},
243 {"delete", no_argument, 0, 'd'},
251 #if LUSTRE_VERSION < OBD_OCD_VERSION(2,1,0,0)
252 if (argc == 5 && argv[1][0] != '-' &&
253 isnumber(argv[2]) && isnumber(argv[3]) && isnumber(argv[4])) {
254 fprintf(stderr, "warning: deprecated usage of setstripe "
255 "positional parameters. Use -c, -i, -s instead.\n");
256 /* for compatibility with the existing positional parameter
259 stripe_size_arg = argv[2];
260 stripe_off_arg = argv[3];
261 stripe_count_arg = argv[4];
265 #warning "remove obsolete positional parameter code"
269 while ((c = getopt_long(argc, argv, "c:di:o:s:p:",
270 long_opts, NULL)) >= 0) {
276 stripe_count_arg = optarg;
279 /* delete the default striping pattern */
284 stripe_off_arg = optarg;
287 stripe_size_arg = optarg;
290 pool_name_arg = optarg;
295 fprintf(stderr, "error: %s: option '%s' "
297 argv[0], argv[optind - 1]);
302 fname = argv[optind];
305 (stripe_size_arg != NULL || stripe_off_arg != NULL ||
306 stripe_count_arg != NULL || pool_name_arg != NULL)) {
307 fprintf(stderr, "error: %s: cannot specify -d with "
308 "-s, -c -o or -p options\n",
314 if (optind == argc) {
315 fprintf(stderr, "error: %s: missing filename|dirname\n",
320 /* get the stripe size */
321 if (stripe_size_arg != NULL) {
322 result = parse_size(stripe_size_arg, &st_size, &size_units);
324 fprintf(stderr, "error: %s: bad size '%s'\n",
325 argv[0], stripe_size_arg);
329 /* get the stripe offset */
330 if (stripe_off_arg != NULL) {
331 st_offset = strtoul(stripe_off_arg, &end, 0);
333 fprintf(stderr, "error: %s: bad stripe offset '%s'\n",
334 argv[0], stripe_off_arg);
338 /* get the stripe count */
339 if (stripe_count_arg != NULL) {
340 st_count = strtoul(stripe_count_arg, &end, 0);
342 fprintf(stderr, "error: %s: bad stripe count '%s'\n",
343 argv[0], stripe_count_arg);
349 result = llapi_file_create_pool(fname, st_size, st_offset,
350 st_count, 0, pool_name_arg);
352 fprintf(stderr,"error: %s: create stripe file '%s' "
353 "failed\n", argv[0], fname);
356 fname = argv[++optind];
357 } while (fname != NULL);
362 static int lfs_poollist(int argc, char **argv)
367 return llapi_poollist(argv[1]);
370 static int set_time(time_t *time, time_t *set, char *str)
377 else if (str[0] == '-')
383 t = strtol(str, NULL, 0);
384 if (*time < t * 24 * 60 * 60) {
387 fprintf(stderr, "Wrong time '%s' is specified.\n", str);
391 *set = *time - t * 24 * 60 * 60;
395 static int name2id(unsigned int *id, char *name, int type)
397 if (type == USRQUOTA) {
398 struct passwd *entry;
400 if (!(entry = getpwnam(name))) {
410 if (!(entry = getgrnam(name))) {
422 static int id2name(char **name, unsigned int id, int type)
424 if (type == USRQUOTA) {
425 struct passwd *entry;
427 if (!(entry = getpwuid(id))) {
433 *name = entry->pw_name;
437 if (!(entry = getgrgid(id))) {
443 *name = entry->gr_name;
449 #define FIND_POOL_OPT 3
450 static int lfs_find(int argc, char **argv)
455 struct find_param param = { .maxdepth = -1 };
457 struct option long_opts[] = {
458 /* New find options. */
459 {"atime", required_argument, 0, 'A'},
460 {"ctime", required_argument, 0, 'C'},
461 {"mtime", required_argument, 0, 'M'},
462 {"maxdepth", required_argument, 0, 'D'},
463 {"gid", required_argument, 0, 'g'},
464 {"group", required_argument, 0, 'G'},
465 {"uid", required_argument, 0, 'u'},
466 {"user", required_argument, 0, 'U'},
467 {"name", required_argument, 0, 'n'},
468 /* no short option for pool, p/P already used */
469 {"pool", required_argument, 0, FIND_POOL_OPT},
470 /* --obd is considered as a new option. */
471 {"obd", required_argument, 0, 'O'},
472 {"ost", required_argument, 0, 'O'},
473 {"print", no_argument, 0, 'P'},
474 {"print0", no_argument, 0, 'p'},
475 /* Old find options. */
476 {"quiet", no_argument, 0, 'q'},
477 {"recursive", no_argument, 0, 'r'},
478 {"size", required_argument, 0, 's'},
479 {"type", required_argument, 0, 't'},
480 {"verbose", no_argument, 0, 'v'},
494 /* when getopt_long_only() hits '!' it returns 1 and puts "!" in optarg */
495 while ((c = getopt_long_only(argc, argv, "-A:C:D:g:G:M:n:PpO:qrs:t:u:U:v",
496 long_opts, NULL)) >= 0) {
501 /* '!' is part of option */
502 /* when getopt_long_only() finds a string which is not
503 * an option nor a known option argument it returns 1
504 * in that case if we already have found pathstart and pathend
505 * (i.e. we have the list of pathnames),
506 * the only supported value is "!"
508 isoption = (c != 1) || (strcmp(optarg, "!") == 0);
509 if (!isoption && pathend != -1) {
510 fprintf(stderr, "err: %s: filename|dirname must either "
511 "precede options or follow options\n",
515 if (!isoption && pathstart == -1)
516 pathstart = optind - 1;
517 if (isoption && pathstart != -1 && pathend == -1) {
518 pathend = optind - 2;
519 if ((c == 1 && strcmp(optarg, "!") == 0) ||
520 c == 'P' || c == 'p' || c == 'O' ||
521 c == 'q' || c == 'r' || c == 'v')
522 pathend = optind - 1;
529 /* unknown; opt is "!" or path component,
530 * checking done above.
532 if (strcmp(optarg, "!") == 0)
536 xtime = ¶m.atime;
537 xsign = ¶m.asign;
540 xtime = ¶m.ctime;
541 xsign = ¶m.csign;
545 xtime = ¶m.mtime;
546 xsign = ¶m.msign;
550 if (optarg[0] == '-')
552 else if (optarg[0] == '+')
561 ret = set_time(&t, xtime, optarg);
569 param.maxdepth = strtol(optarg, 0, 0);
573 param.gid = strtol(optarg, &endptr, 10);
574 if (optarg == endptr) {
575 fprintf(stderr, "Bad gid: %s\n", optarg);
578 param.exclude_gid = !!neg_opt;
583 param.gid = strtol(optarg, &endptr, 10);
584 if (optarg == endptr) {
585 ret = name2id(¶m.gid, optarg, GRPQUOTA);
587 fprintf(stderr, "Group/GID: %s cannot "
588 "be found.\n", optarg);
592 param.exclude_gid = !!neg_opt;
597 param.uid = strtol(optarg, &endptr, 10);
598 if (optarg == endptr) {
599 fprintf(stderr, "Bad uid: %s\n", optarg);
602 param.exclude_uid = !!neg_opt;
607 param.uid = strtol(optarg, &endptr, 10);
608 if (optarg == endptr) {
609 ret = name2id(¶m.uid, optarg, USRQUOTA);
611 fprintf(stderr, "User/UID: %s cannot "
612 "be found.\n", optarg);
616 param.exclude_uid = !!neg_opt;
621 if (strlen(optarg) > LOV_MAXPOOLNAME) {
623 "Pool name %s is too long"
624 " (max is %d)\n", optarg,
628 /* we do check for empty pool because empty pool
629 * is used to find V1 lov attributes */
630 strncpy(param.poolname, optarg, LOV_MAXPOOLNAME);
631 param.poolname[LOV_MAXPOOLNAME] = '\0';
632 param.exclude_pool = !!neg_opt;
633 param.check_pool = 1;
637 param.pattern = (char *)optarg;
638 param.exclude_pattern = !!neg_opt;
641 char *buf, *token, *next, *p;
644 len = strlen((char *)optarg);
648 strcpy(buf, (char *)optarg);
650 if (param.num_alloc_obds == 0) {
651 param.obduuid = malloc(FIND_MAX_OSTS *
652 sizeof(struct obd_uuid));
653 if (param.obduuid == NULL)
655 param.num_alloc_obds = INIT_ALLOC_NUM_OSTS;
658 for (token = buf; token && *token; token = next) {
659 p = strchr(token, ',');
665 strcpy((char *)¶m.obduuid[param.num_obds++].uuid,
689 param.exclude_type = !!neg_opt;
691 case 'b': param.type = S_IFBLK; break;
692 case 'c': param.type = S_IFCHR; break;
693 case 'd': param.type = S_IFDIR; break;
694 case 'f': param.type = S_IFREG; break;
695 case 'l': param.type = S_IFLNK; break;
696 case 'p': param.type = S_IFIFO; break;
697 case 's': param.type = S_IFSOCK; break;
698 #ifdef S_IFDOOR /* Solaris only */
699 case 'D': param.type = S_IFDOOR; break;
701 default: fprintf(stderr, "error: %s: bad type '%s'\n",
708 if (optarg[0] == '-')
710 else if (optarg[0] == '+')
719 if (optarg[0] == '+')
720 param.size_sign = -1;
721 else if (optarg[0] == '-')
722 param.size_sign = +1;
726 ret = parse_size(optarg, ¶m.size,¶m.size_units);
728 fprintf(stderr,"error: bad size '%s'\n",
741 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
742 argv[0], argv[optind - 1]);
747 if (pathstart == -1) {
748 fprintf(stderr, "error: %s: no filename|pathname\n",
751 } else if (pathend == -1) {
759 static int deprecated_warning;
760 if (!deprecated_warning) {
761 fprintf(stderr, "lfs find: -q, -r, -v options "
762 "deprecated. Use 'lfs getstripe' instead.\n");
763 deprecated_warning = 1;
765 if (!param.recursive && param.maxdepth == -1)
771 ret = llapi_find(argv[pathstart], ¶m);
773 ret = llapi_getstripe(argv[pathstart], ¶m);
774 } while (++pathstart < pathend && !ret);
777 fprintf(stderr, "error: %s failed for %s.\n",
778 argv[0], argv[optind - 1]);
780 if (param.obduuid && param.num_alloc_obds)
786 static int lfs_getstripe(int argc, char **argv)
788 struct option long_opts[] = {
790 {"quiet", 0, 0, 'q'},
791 {"recursive", 0, 0, 'r'},
792 {"verbose", 0, 0, 'v'},
795 char short_opts[] = "hO:qrv";
797 struct find_param param = { 0 };
800 while ((c = getopt_long(argc, argv, short_opts,
801 long_opts, NULL)) != -1) {
806 "error: %s: only one obduuid allowed",
810 param.obduuid = (struct obd_uuid *)optarg;
826 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
827 argv[0], argv[optind - 1]);
835 param.maxdepth = param.recursive ? -1 : 1;
838 rc = llapi_getstripe(argv[optind], ¶m);
839 } while (++optind < argc && !rc);
842 fprintf(stderr, "error: %s failed for %s.\n",
843 argv[0], argv[optind - 1]);
847 static int lfs_osts(int argc, char **argv)
850 struct mntent *mnt = NULL;
851 struct find_param param;
857 fp = setmntent(MOUNTED, "r");
860 fprintf(stderr, "%s: setmntent(%s): %s:", argv[0], MOUNTED,
864 while (feof(fp) == 0 && ferror(fp) ==0) {
865 memset(¶m, 0, sizeof(param));
866 if (llapi_is_lustre_mnt(mnt)) {
867 rc = llapi_getstripe(mnt->mnt_dir, ¶m);
870 "error: %s: failed on %s\n",
871 argv[0], mnt->mnt_dir);
881 static int lfs_path2fid(int argc, char **argv)
884 unsigned long long seq;
885 unsigned long oid, ver;
892 rc = llapi_path2fid(path, &seq, &oid, &ver);
894 fprintf(stderr, "error: can't get fid for %s\n", path);
898 printf("%llu:%lu", seq, oid);
907 #define COOK(value) \
910 while (value > 1024) { \
924 static int path2mnt(char *path, FILE *fp, char *mntdir, int dir_len)
926 char rpath[PATH_MAX] = {'\0'};
928 int rc, len, out_len = 0;
930 if (!realpath(path, rpath)) {
932 fprintf(stderr, "error: lfs df: invalid path '%s': %s\n",
933 path, strerror(-rc));
939 while (feof(fp) == 0 && ferror(fp) == 0) {
940 if (llapi_is_lustre_mnt(mnt)) {
941 len = strlen(mnt->mnt_dir);
943 !strncmp(rpath, mnt->mnt_dir, len)) {
945 memset(mntdir, 0, dir_len);
946 strncpy(mntdir, mnt->mnt_dir, dir_len);
955 fprintf(stderr, "error: lfs df: %s isn't mounted on lustre\n", path);
959 static int showdf(char *mntdir, struct obd_statfs *stat,
960 char *uuid, int ishow, int cooked,
961 char *type, int index, int rc)
963 long long avail, used, total;
965 char *suffix = "KMGTPEZY";
966 /* Note if we have >2^64 bytes/fs these buffers will need to be grown */
967 char tbuf[20], ubuf[20], abuf[20], rbuf[20];
975 avail = stat->os_ffree;
976 used = stat->os_files - stat->os_ffree;
977 total = stat->os_files;
979 int shift = cooked ? 0 : 10;
981 avail = (stat->os_bavail * stat->os_bsize) >> shift;
982 used = ((stat->os_blocks - stat->os_bfree) *
983 stat->os_bsize) >> shift;
984 total = (stat->os_blocks * stat->os_bsize) >> shift;
988 ratio = (double)used / (double)total;
994 cook_val = (double)total;
997 sprintf(tbuf, HDF"%c", cook_val, suffix[i - 1]);
999 sprintf(tbuf, CDF, total);
1001 cook_val = (double)used;
1004 sprintf(ubuf, HDF"%c", cook_val, suffix[i - 1]);
1006 sprintf(ubuf, CDF, used);
1008 cook_val = (double)avail;
1011 sprintf(abuf, HDF"%c", cook_val, suffix[i - 1]);
1013 sprintf(abuf, CDF, avail);
1015 sprintf(tbuf, CDF, total);
1016 sprintf(ubuf, CDF, used);
1017 sprintf(abuf, CDF, avail);
1020 sprintf(rbuf, RDF, (int)(ratio * 100));
1021 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s",
1022 uuid, tbuf, ubuf, abuf, rbuf, mntdir);
1024 printf("[%s:%d]\n", type, index);
1030 printf(UUF": inactive device\n", uuid);
1033 printf(UUF": %s\n", uuid, strerror(-rc));
1040 static int mntdf(char *mntdir, int ishow, int cooked)
1042 struct obd_statfs stat_buf, sum = { .os_bsize = 1 };
1043 struct obd_uuid uuid_buf;
1048 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s\n",
1049 "UUID", "Inodes", "IUsed", "IFree",
1050 "IUse%", "Mounted on");
1052 printf(UUF" "CSF" "CSF" "CSF" "RSF" %-s\n",
1053 "UUID", cooked ? "bytes" : "1K-blocks",
1054 "Used", "Available", "Use%", "Mounted on");
1056 for (index = 0; ; index++) {
1057 memset(&stat_buf, 0, sizeof(struct obd_statfs));
1058 memset(&uuid_buf, 0, sizeof(struct obd_uuid));
1059 rc = llapi_obd_statfs(mntdir, LL_STATFS_MDC, index,
1060 &stat_buf, &uuid_buf);
1067 if (rc == -ENOTCONN || rc == -ETIMEDOUT || rc == -EIO ||
1068 rc == -ENODATA || rc == 0) {
1069 showdf(mntdir, &stat_buf, uuid_buf.uuid, ishow, cooked,
1073 "error: llapi_obd_statfs(%s): %s (%d)\n",
1074 uuid_buf.uuid, strerror(-rc), rc);
1078 sum.os_ffree += stat_buf.os_ffree;
1079 sum.os_files += stat_buf.os_files;
1083 for (index = 0; ; index++) {
1084 memset(&stat_buf, 0, sizeof(struct obd_statfs));
1085 memset(&uuid_buf, 0, sizeof(struct obd_uuid));
1086 rc = llapi_obd_statfs(mntdir, LL_STATFS_LOV, index,
1087 &stat_buf, &uuid_buf);
1094 if (rc == -ENOTCONN || rc == -ETIMEDOUT || rc == -EIO ||
1095 rc == -ENODATA || rc == 0) {
1096 showdf(mntdir, &stat_buf, uuid_buf.uuid, ishow, cooked,
1100 "error: llapi_obd_statfs failed: %s (%d)\n",
1105 sum.os_blocks += stat_buf.os_blocks * stat_buf.os_bsize;
1106 sum.os_bfree += stat_buf.os_bfree * stat_buf.os_bsize;
1107 sum.os_bavail += stat_buf.os_bavail * stat_buf.os_bsize;
1112 showdf(mntdir, &sum, "filesystem summary:", ishow, cooked, NULL, 0,0);
1117 static int lfs_df(int argc, char **argv)
1121 struct mntent *mnt = NULL;
1122 char *mntdir = NULL;
1123 int ishow = 0, cooked = 0;
1127 while ((c = getopt(argc, argv, "ih")) != -1) {
1140 path = argv[optind];
1142 fp = setmntent(MOUNTED, "r");
1145 fprintf(stderr, "error: %s: open %s failed( %s )\n",
1146 argv[0], MOUNTED, strerror(errno));
1150 if ((mntdir = malloc(PATH_MAX)) == NULL) {
1151 fprintf(stderr, "error: cannot allocate %d bytes\n",
1155 memset(mntdir, 0, PATH_MAX);
1158 rc = path2mnt(path, fp, mntdir, PATH_MAX);
1165 rc = mntdf(mntdir, ishow, cooked);
1169 mnt = getmntent(fp);
1170 while (feof(fp) == 0 && ferror(fp) == 0) {
1171 if (llapi_is_lustre_mnt(mnt)) {
1172 rc = mntdf(mnt->mnt_dir, ishow, cooked);
1177 mnt = getmntent(fp);
1186 static int lfs_check(int argc, char **argv)
1190 struct mntent *mnt = NULL;
1199 obd_types[0] = obd_type1;
1200 obd_types[1] = obd_type2;
1202 if (strcmp(argv[1], "osts") == 0) {
1203 strcpy(obd_types[0], "osc");
1204 } else if (strcmp(argv[1], "mds") == 0) {
1205 strcpy(obd_types[0], "mdc");
1206 } else if (strcmp(argv[1], "servers") == 0) {
1208 strcpy(obd_types[0], "osc");
1209 strcpy(obd_types[1], "mdc");
1211 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
1216 fp = setmntent(MOUNTED, "r");
1218 fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
1221 mnt = getmntent(fp);
1222 while (feof(fp) == 0 && ferror(fp) ==0) {
1223 if (llapi_is_lustre_mnt(mnt))
1225 mnt = getmntent(fp);
1231 fprintf(stderr, "No suitable Lustre mount found\n");
1235 rc = llapi_target_check(num_types, obd_types, mnt->mnt_dir);
1238 fprintf(stderr, "error: %s: %s status failed\n",
1245 static int lfs_catinfo(int argc, char **argv)
1248 struct mntent *mnt = NULL;
1251 if (argc < 2 || (!strcmp(argv[1],"config") && argc < 3))
1254 if (strcmp(argv[1], "config") && strcmp(argv[1], "deletions"))
1257 fp = setmntent(MOUNTED, "r");
1259 fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
1262 mnt = getmntent(fp);
1263 while (feof(fp) == 0 && ferror(fp) == 0) {
1264 if (llapi_is_lustre_mnt(mnt))
1266 mnt = getmntent(fp);
1273 rc = llapi_catinfo(mnt->mnt_dir, argv[1], argv[2]);
1275 rc = llapi_catinfo(mnt->mnt_dir, argv[1], NULL);
1277 fprintf(stderr, "no lustre_lite mounted.\n");
1284 int lfs_join(int argc, char **argv)
1286 char *name_head, *name_tail;
1292 name_head = argv[1];
1293 fd = open(name_head, O_WRONLY);
1295 fprintf(stderr, "Can not open name_head %s rc=%d\n",
1299 size = lseek(fd, 0, SEEK_END);
1300 if (size % JOIN_FILE_ALIGN) {
1301 fprintf(stderr,"head file %s size %llu must be mutiple of %d\n",
1302 name_head, (long long)size, JOIN_FILE_ALIGN);
1306 name_tail = argv[2];
1307 rc = ioctl(fd, LL_IOC_JOIN, name_tail);
1311 fprintf(stderr, "Lustre joining files: %s, %s, failed\n",
1317 #ifdef HAVE_QUOTA_SUPPORT
1318 static int lfs_quotachown(int argc, char **argv)
1325 while ((c = getopt(argc, argv, "i")) != -1) {
1331 fprintf(stderr, "error: %s: option '-%c' "
1332 "unrecognized\n", argv[0], c);
1338 rc = llapi_quotachown(argv[optind], flag);
1340 fprintf(stderr,"error: change file owner/group failed.\n");
1345 static int lfs_quotacheck(int argc, char **argv)
1347 int c, check_type = 0;
1349 struct if_quotacheck qchk;
1350 struct if_quotactl qctl;
1351 char *obd_type = qchk.obd_type;
1352 char *obd_uuid = qchk.obd_uuid.uuid;
1355 memset(&qchk, 0, sizeof(qchk));
1358 while ((c = getopt(argc, argv, "ug")) != -1) {
1367 fprintf(stderr, "error: %s: option '-%c' "
1368 "unrecognized\n", argv[0], c);
1375 else /* do quotacheck for both user & group quota by default */
1383 memset(&qctl, 0, sizeof(qctl));
1384 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1385 qctl.qc_id = QFMT_LDISKFS;
1386 qctl.qc_type = check_type;
1387 rc = llapi_quotactl(mnt, &qctl);
1389 fprintf(stderr, "quota off failed: %s\n", strerror(errno));
1393 rc = llapi_quotacheck(mnt, check_type);
1395 fprintf(stderr, "quotacheck failed: %s\n", strerror(errno));
1399 rc = llapi_poll_quotacheck(mnt, &qchk);
1402 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1403 fprintf(stderr, "quota check failed: %s\n", strerror(errno));
1407 memset(&qctl, 0, sizeof(qctl));
1408 qctl.qc_cmd = LUSTRE_Q_QUOTAON;
1409 qctl.qc_id = QFMT_LDISKFS;
1410 qctl.qc_type = check_type;
1411 rc = llapi_quotactl(mnt, &qctl);
1414 fprintf(stderr, "%s %s ",
1415 qctl.obd_type, qctl.obd_uuid.uuid);
1416 fprintf(stderr, "%s turn on quota failed: %s\n",
1417 argv[0], strerror(errno));
1424 static int lfs_quotaon(int argc, char **argv)
1428 struct if_quotactl qctl;
1429 char *obd_type = qctl.obd_type;
1430 char *obd_uuid = qctl.obd_uuid.uuid;
1433 memset(&qctl, 0, sizeof(qctl));
1434 qctl.qc_cmd = LUSTRE_Q_QUOTAON;
1435 qctl.qc_id = QFMT_LDISKFS;
1438 while ((c = getopt(argc, argv, "ugf")) != -1) {
1441 qctl.qc_type |= 0x01;
1444 qctl.qc_type |= 0x02;
1447 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1450 fprintf(stderr, "error: %s: option '-%c' "
1451 "unrecognized\n", argv[0], c);
1458 else /* by default, enable quota for both user & group */
1459 qctl.qc_type = 0x02;
1466 rc = llapi_quotactl(mnt, &qctl);
1469 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1470 fprintf(stderr, "%s failed: %s\n", argv[0], strerror(errno));
1477 static int lfs_quotaoff(int argc, char **argv)
1481 struct if_quotactl qctl;
1482 char *obd_type = qctl.obd_type;
1483 char *obd_uuid = qctl.obd_uuid.uuid;
1486 memset(&qctl, 0, sizeof(qctl));
1487 qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
1490 while ((c = getopt(argc, argv, "ug")) != -1) {
1493 qctl.qc_type |= 0x01;
1496 qctl.qc_type |= 0x02;
1499 fprintf(stderr, "error: %s: option '-%c' "
1500 "unrecognized\n", argv[0], c);
1507 else /* by default, disable quota for both user & group */
1508 qctl.qc_type = 0x02;
1515 rc = llapi_quotactl(mnt, &qctl);
1518 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1519 fprintf(stderr, "quotaoff failed: %s\n", strerror(errno));
1526 #define ARG2INT(nr, str, msg) \
1529 nr = strtol(str, &endp, 0); \
1531 fprintf(stderr, "error: bad %s: %s\n", msg, str); \
1536 #define ADD_OVERFLOW(a,b) ((a + b) < a) ? (a = ULONG_MAX) : (a = a + b)
1538 /* Convert format time string "XXwXXdXXhXXmXXs" into seconds value
1539 * returns the value or ULONG_MAX on integer overflow or incorrect format
1541 * 1. the order of specifiers is arbitrary (may be: 5w3s or 3s5w)
1542 * 2. specifiers may be encountered multiple times (2s3s is 5 seconds)
1543 * 3. empty integer value is interpreted as 0
1546 static unsigned long str2sec(const char* timestr) {
1547 const char spec[] = "smhdw";
1548 const unsigned long mult[] = {1, 60, 60*60, 24*60*60, 7*24*60*60};
1549 unsigned long val = 0;
1552 if (strpbrk(timestr, spec) == NULL) {
1553 /* no specifiers inside the time string,
1554 should treat it as an integer value */
1555 val = strtoul(timestr, &tail, 10);
1556 return *tail ? ULONG_MAX : val;
1559 /* format string is XXwXXdXXhXXmXXs */
1565 v = strtoul(timestr, &tail, 10);
1566 if (v == ULONG_MAX || *tail == '\0')
1567 /* value too large (ULONG_MAX or more)
1568 or missing specifier */
1571 ptr = strchr(spec, *tail);
1573 /* unknown specifier */
1578 /* check if product will overflow the type */
1579 if (!(v < ULONG_MAX / mult[ind]))
1582 ADD_OVERFLOW(val, mult[ind] * v);
1583 if (val == ULONG_MAX)
1595 int lfs_setquota(int argc, char **argv)
1599 struct if_quotactl qctl;
1600 char *obd_type = qctl.obd_type;
1601 char *obd_uuid = qctl.obd_uuid.uuid;
1604 memset(&qctl, 0, sizeof(qctl));
1605 qctl.qc_cmd = LUSTRE_Q_SETQUOTA;
1608 while ((c = getopt(argc, argv, "ugt")) != -1) {
1611 qctl.qc_type |= 0x01;
1614 qctl.qc_type |= 0x02;
1617 qctl.qc_cmd = LUSTRE_Q_SETINFO;
1620 fprintf(stderr, "error: %s: option '-%c' "
1621 "unrecognized\n", argv[0], c);
1629 if (qctl.qc_type == UGQUOTA) {
1630 fprintf(stderr, "error: user and group quotas can't be set "
1635 if (qctl.qc_cmd == LUSTRE_Q_SETQUOTA) {
1636 struct obd_dqblk *dqb = &qctl.qc_dqblk;
1638 if (optind + 6 != argc)
1641 rc = name2id(&qctl.qc_id, argv[optind++], qctl.qc_type);
1643 fprintf(stderr, "error: find id for name %s failed: %s\n",
1644 argv[optind - 1], strerror(errno));
1648 ARG2INT(dqb->dqb_bsoftlimit, argv[optind++], "block-softlimit");
1649 ARG2INT(dqb->dqb_bhardlimit, argv[optind++], "block-hardlimit");
1650 ARG2INT(dqb->dqb_isoftlimit, argv[optind++], "inode-softlimit");
1651 ARG2INT(dqb->dqb_ihardlimit, argv[optind++], "inode-hardlimit");
1653 dqb->dqb_valid = QIF_LIMITS;
1655 struct obd_dqinfo *dqi = &qctl.qc_dqinfo;
1657 if (optind + 3 != argc)
1660 if ((dqi->dqi_bgrace = str2sec(argv[optind++])) == ULONG_MAX) {
1661 fprintf(stderr, "error: bad %s: %s\n", "block-grace", argv[optind - 1]);
1664 if ((dqi->dqi_igrace = str2sec(argv[optind++])) == ULONG_MAX) {
1665 fprintf(stderr, "error: bad %s: %s\n", "inode-grace", argv[optind - 1]);
1672 rc = llapi_quotactl(mnt, &qctl);
1675 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1676 fprintf(stderr, "setquota failed: %s\n", strerror(errno));
1683 static inline char *type2name(int check_type)
1685 if (check_type == USRQUOTA)
1687 else if (check_type == GRPQUOTA)
1694 /* Converts seconds value into format string
1695 * result is returned in buf
1697 * 1. result is in descenting order: 1w2d3h4m5s
1698 * 2. zero fields are not filled (except for p. 3): 5d1s
1699 * 3. zero seconds value is presented as "0s"
1701 static void sec2str(time_t seconds, char *buf)
1703 const char spec[] = "smhdw";
1704 const unsigned long mult[] = {1, 60, 60*60, 24*60*60, 7*24*60*60};
1709 for (i = sizeof(mult) / sizeof(mult[0]) - 1 ; i >= 0; i--) {
1710 c = seconds / mult[i];
1712 if (c > 0 || (i == 0 && buf == tail))
1713 tail += snprintf(tail, 40-(tail-buf), "%lu%c", c, spec[i]);
1720 static void diff2str(time_t seconds, char *buf, time_t now)
1726 if (seconds <= now) {
1727 strcpy(buf, "none");
1730 sec2str(seconds - now, buf);
1733 static void print_quota_title(char *name, struct if_quotactl *qctl)
1735 printf("Disk quotas for %s %s (%cid %u):\n",
1736 type2name(qctl->qc_type), name,
1737 *type2name(qctl->qc_type), qctl->qc_id);
1738 printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n",
1740 "kbytes", "quota", "limit", "grace",
1741 "files", "quota", "limit", "grace");
1744 static void print_quota(char *mnt, struct if_quotactl *qctl, int ost_only)
1750 if (qctl->qc_cmd == LUSTRE_Q_GETQUOTA || qctl->qc_cmd == Q_GETOQUOTA) {
1751 int bover = 0, iover = 0;
1752 struct obd_dqblk *dqb = &qctl->qc_dqblk;
1754 if (dqb->dqb_bhardlimit &&
1755 toqb(dqb->dqb_curspace) > dqb->dqb_bhardlimit) {
1757 } else if (dqb->dqb_bsoftlimit &&
1758 toqb(dqb->dqb_curspace) > dqb->dqb_bsoftlimit) {
1759 if (dqb->dqb_btime > now) {
1766 if (dqb->dqb_ihardlimit &&
1767 dqb->dqb_curinodes > dqb->dqb_ihardlimit) {
1769 } else if (dqb->dqb_isoftlimit &&
1770 dqb->dqb_curinodes > dqb->dqb_isoftlimit) {
1771 if (dqb->dqb_btime > now) {
1778 #if 0 /* XXX: always print quotas even when no usages */
1779 if (dqb->dqb_curspace || dqb->dqb_curinodes)
1785 if (strlen(mnt) > 15)
1786 printf("%s\n%15s", mnt, "");
1788 printf("%15s", mnt);
1791 diff2str(dqb->dqb_btime, timebuf, now);
1793 sprintf(numbuf[0], LPU64, toqb(dqb->dqb_curspace));
1794 sprintf(numbuf[1], LPU64, dqb->dqb_bsoftlimit);
1795 sprintf(numbuf[2], LPU64, dqb->dqb_bhardlimit);
1796 printf(" %7s%c %6s %7s %7s",
1797 numbuf[0], bover ? '*' : ' ', numbuf[1],
1798 numbuf[2], bover > 1 ? timebuf : "");
1801 diff2str(dqb->dqb_itime, timebuf, now);
1803 sprintf(numbuf[0], LPU64, dqb->dqb_curinodes);
1804 sprintf(numbuf[1], LPU64, dqb->dqb_isoftlimit);
1805 sprintf(numbuf[2], LPU64, dqb->dqb_ihardlimit);
1807 printf(" %7s%c %6s %7s %7s",
1808 numbuf[0], iover ? '*' : ' ', numbuf[1],
1809 numbuf[2], iover > 1 ? timebuf : "");
1812 } else if (qctl->qc_cmd == LUSTRE_Q_GETINFO ||
1813 qctl->qc_cmd == Q_GETOINFO) {
1817 sec2str(qctl->qc_dqinfo.dqi_bgrace, bgtimebuf);
1818 sec2str(qctl->qc_dqinfo.dqi_igrace, igtimebuf);
1819 printf("Block grace time: %s; Inode grace time: %s\n",
1820 bgtimebuf, igtimebuf);
1824 static void print_mds_quota(char *mnt, struct if_quotactl *qctl)
1828 /* XXX: this is a flag to mark that only mds quota is wanted */
1829 qctl->qc_dqblk.dqb_valid = 1;
1830 rc = llapi_quotactl(mnt, qctl);
1832 fprintf(stderr, "quotactl failed: %s\n", strerror(errno));
1835 qctl->qc_dqblk.dqb_valid = 0;
1837 print_quota(qctl->obd_uuid.uuid, qctl, 0);
1840 static void print_lov_quota(char *mnt, struct if_quotactl *qctl)
1843 struct obd_uuid *uuids = NULL, *uuidp;
1844 int obdcount = 1024;
1849 fprintf(stderr, "open %s failed: %s\n", mnt, strerror(errno));
1853 uuids = (struct obd_uuid *)malloc(INIT_ALLOC_NUM_OSTS *
1854 sizeof(struct obd_uuid));
1859 rc = llapi_lov_get_uuids(dirfd(dir), uuids, &obdcount);
1861 struct obd_uuid *uuids_temp;
1863 if (rc == -EOVERFLOW) {
1864 uuids_temp = realloc(uuids, obdcount *
1865 sizeof(struct obd_uuid));
1866 if (uuids_temp != NULL)
1867 goto retry_get_uuids;
1872 fprintf(stderr, "get ost uuid failed: %s\n", strerror(rc));
1876 for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) {
1877 memcpy(&qctl->obd_uuid, uuidp, sizeof(*uuidp));
1879 /* XXX clear this flag to get quota from osts */
1880 qctl->qc_dqblk.dqb_valid = 0;
1881 rc = llapi_quotactl(mnt, qctl);
1883 fprintf(stderr, "%s quotactl failed: %s\n",
1884 uuidp->uuid, strerror(errno));
1888 print_quota(uuidp->uuid, qctl, 1);
1896 static int lfs_quota(int argc, char **argv)
1899 char *name = NULL, *mnt;
1900 struct if_quotactl qctl = { .qc_cmd = LUSTRE_Q_GETQUOTA,
1902 char *obd_type = qctl.obd_type;
1903 char *obd_uuid = qctl.obd_uuid.uuid;
1907 while ((c = getopt(argc, argv, "ugto:")) != -1) {
1910 qctl.qc_type = 0x01;
1913 qctl.qc_type = 0x02;
1916 qctl.qc_cmd = LUSTRE_Q_GETINFO;
1919 strncpy(obd_uuid, optarg, sizeof(qctl.obd_uuid));
1922 fprintf(stderr, "error: %s: option '-%c' "
1923 "unrecognized\n", argv[0], c);
1932 if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
1933 if (optind + 2 != argc) {
1934 fprintf(stderr, "error: missing quota argument(s)\n");
1938 name = argv[optind++];
1939 rc = name2id(&qctl.qc_id, name, qctl.qc_type);
1941 fprintf(stderr,"error: can't find id for name %s: %s\n",
1942 name, strerror(errno));
1945 print_quota_title(name, &qctl);
1946 } else if (optind + 1 != argc) {
1947 fprintf(stderr, "error: missing quota info argument(s)\n");
1953 rc = llapi_quotactl(mnt, &qctl);
1956 fprintf(stderr, "%s %s ", obd_type, obd_uuid);
1957 fprintf(stderr, "quota failed: %s\n", strerror(errno));
1962 rc = id2name(&name, getuid(), qctl.qc_type);
1969 print_quota(mnt, &qctl, 0);
1971 if (!*obd_uuid && qctl.qc_cmd != LUSTRE_Q_GETINFO) {
1972 print_mds_quota(mnt, &qctl);
1973 print_lov_quota(mnt, &qctl);
1978 #endif /* HAVE_QUOTA_SUPPORT */
1980 static int flushctx_ioctl(char *mp)
1984 fd = open(mp, O_RDONLY);
1986 fprintf(stderr, "flushctx: error open %s: %s\n",
1987 mp, strerror(errno));
1991 rc = ioctl(fd, LL_IOC_FLUSHCTX);
1993 fprintf(stderr, "flushctx: error ioctl %s: %s\n",
1994 mp, strerror(errno));
2000 static int lfs_flushctx(int argc, char **argv)
2002 int kdestroy = 0, c;
2004 char procline[PATH_MAX], *line;
2008 while ((c = getopt(argc, argv, "k")) != -1) {
2014 fprintf(stderr, "error: %s: option '-%c' "
2015 "unrecognized\n", argv[0], c);
2021 system("kdestroy > /dev/null");
2023 if (optind >= argc) {
2024 /* flush for all mounted lustre fs. */
2025 proc = fopen("/proc/mounts", "r");
2027 fprintf(stderr, "error: %s: can't open /proc/mounts\n",
2032 while ((line = fgets(procline, PATH_MAX, proc)) != NULL) {
2037 if (sscanf(line, "%s %s %s", dev, mp, fs) != 3) {
2038 fprintf(stderr, "%s: unexpected format in "
2044 if (strcmp(fs, "lustre") != 0)
2046 /* we use '@' to determine it's a client. are there
2047 * any other better way?
2049 if (strchr(dev, '@') == NULL)
2052 if (flushctx_ioctl(mp))
2056 /* flush fs as specified */
2057 while (optind < argc) {
2058 if (flushctx_ioctl(argv[optind++]))
2066 static int lfs_lsetfacl(int argc, char **argv)
2069 return(llapi_lsetfacl(argc, argv));
2072 static int lfs_lgetfacl(int argc, char **argv)
2075 return(llapi_lgetfacl(argc, argv));
2078 static int lfs_rsetfacl(int argc, char **argv)
2081 return(llapi_rsetfacl(argc, argv));
2084 static int lfs_rgetfacl(int argc, char **argv)
2087 return(llapi_rgetfacl(argc, argv));
2090 static int lfs_cp(int argc, char **argv)
2092 return(llapi_cp(argc, argv));
2095 static int lfs_ls(int argc, char **argv)
2097 return(llapi_ls(argc, argv));
2100 int main(int argc, char **argv)
2106 ptl_initialize(argc, argv);
2107 if (obd_initialize(argc, argv) < 0)
2109 if (dbg_initialize(argc, argv) < 0)
2112 Parser_init("lfs > ", cmdlist);
2115 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
2117 rc = Parser_commands();
2120 obd_finalize(argc, argv);