Whamcloud - gitweb
Land b_smallfix onto HEAD (20040423_1603)
[fs/lustre-release.git] / lustre / utils / lfs.c
index 8f20c8e..2fcf5ad 100644 (file)
 #include <getopt.h>
 #include <string.h>
 #include <mntent.h>
-#include <portals/api-support.h>
 #include <portals/ptlctl.h>
 
 #include <liblustre.h>
 #include <linux/lustre_idl.h>
+#include <lustre/liblustreapi.h>
+#include <lustre/lustre_user.h>
 
 #include "parser.h"
 #include "obdctl.h"
 
-extern int op_create_file(char *name, long stripe_size, int stripe_offset,
-                int stripe_count);
-extern int op_find(char *path, struct obd_uuid *obduuid, int recursive,
-                int verbose, int quiet);
-extern int op_check(int type_num, char **obd_type_p, char *dir);
-extern int op_catinfo(char *dir, char *keyword, char *node_name);
-
 /* all functions */
 static int lfs_setstripe(int argc, char **argv);
 static int lfs_find(int argc, char **argv);
@@ -56,25 +50,28 @@ static int lfs_catinfo(int argc, char **argv);
 /* all avaialable commands */
 command_t cmdlist[] = {
         {"setstripe", lfs_setstripe, 0,
-         "blah...\n"
-         "usage: setstripe <filename> <stripe size> <stripe start> <stripe count>\n"
+         "Create a new file with a specific striping pattern or\n"
+         "Set the default striping pattern on an existing directory\n"
+         "usage: setstripe <filename|dirname> <stripe size> <stripe start> <stripe count>\n"
          "\tstripe size:  Number of bytes in each stripe (0 default)\n"
          "\tstripe start: OST index of first stripe (-1 default)\n"
-         "\tstripe count: Number of OSTs to stripe over (0 default)"},
+         "\tstripe count: Number of OSTs to stripe over (0 default, -1 all)"},
         {"find", lfs_find, 0,
-         "blah...\n"
+         "To list the extended attributes for a given filename or files in a\n"
+         "directory or recursively for all files in a directory tree.\n"
          "usage: find [--obd <uuid>] [--quiet | --verbose] [--recursive] <dir|file> ..."},
         {"getstripe", lfs_getstripe, 0,
-         "blah...\n"
+         "To list the striping pattern for given filename.\n"
          "usage:getstripe <filename>"},
-        {"check", lfs_check, 0, 
-         "blah...\n"
+        {"check", lfs_check, 0,
+         "Display the status of MDS or OSTs (as specified in the command)\n"
+         "or all the servers (MDS and OSTs).\n"
          "usage: check <osts|mds|servers>"},
         {"catinfo", lfs_catinfo, 0,
          "Show information of specified type logs.\n"
-         "usage: catinfo <keyword> [node name]"
-         "keywords are one of followings: config, deletions.\n"
-         "client node name must be provided when use keyword config."},
+         "usage: catinfo {keyword} [node name]\n"
+         "\tkeywords are one of followings: config, deletions.\n"
+         "\tnode name must be provided when use keyword config."},
         {"osts", lfs_osts, 0, "osts"},
         {"help", Parser_help, 0, "help"},
         {"exit", Parser_quit, 0, "quit"},
@@ -211,7 +208,7 @@ static int lfs_osts(int argc, char **argv)
         struct mntent *mnt = NULL;
         struct obd_uuid *obduuid = NULL;
         int rc=0;
-                                                                                                                             
+
         if (argc != 1)
                 return CMD_HELP;
 
@@ -223,7 +220,7 @@ static int lfs_osts(int argc, char **argv)
         } else {
                 mnt = getmntent(fp);
                 while (feof(fp) == 0 && ferror(fp) ==0) {
-                        if (strcmp(mnt->mnt_type, "lustre_lite") == 0) {
+                        if (llapi_is_lustre_mnttype(mnt->mnt_type)) {
                                 rc = op_find(mnt->mnt_dir, obduuid, 0, 0, 0);
                                 if (rc)
                                         fprintf(stderr, "error: lfs osts failed for %s\n",
@@ -233,7 +230,7 @@ static int lfs_osts(int argc, char **argv)
                 }
                 endmntent(fp);
         }
-                                                                                                                             
+
         return rc;
 }
 
@@ -274,19 +271,19 @@ static int lfs_check(int argc, char **argv)
         } else {
                 mnt = getmntent(fp);
                 while (feof(fp) == 0 && ferror(fp) ==0) {
-                        if (strcmp(mnt->mnt_type, "lustre_lite") == 0) 
+                        if (llapi_is_lustre_mnttype(mnt->mnt_type))
                                 break;
                         mnt = getmntent(fp);
                 }
                 endmntent(fp);
         }
-           
+
         rc = op_check(type_num,obd_type_p,mnt->mnt_dir);
 
         if (rc)
                 fprintf(stderr, "error: %s: %s status failed\n",
                                 argv[0],argv[1]);
-                                                                                                                             
+
         return rc;
 
 }
@@ -296,7 +293,7 @@ static int lfs_catinfo(int argc, char **argv)
         FILE *fp;
         struct mntent *mnt = NULL;
         int rc;
-        
+
         if (argc < 2 || (!strcmp(argv[1],"config") && argc < 3))
                 return CMD_HELP;
 
@@ -305,12 +302,12 @@ static int lfs_catinfo(int argc, char **argv)
 
         fp = setmntent(MOUNTED, "r");
         if (fp == NULL) {
-                 fprintf(stderr, "setmntent(%s): %s:", MOUNTED, 
+                 fprintf(stderr, "setmntent(%s): %s:", MOUNTED,
                          strerror(errno));
         } else {
                 mnt = getmntent(fp);
                 while (feof(fp) == 0 && ferror(fp) == 0) {
-                        if (strcmp(mnt->mnt_type, "lustre_lite") == 0) 
+                        if (llapi_is_lustre_mnttype(mnt->mnt_type))
                                 break;
                         mnt = getmntent(fp);
                 }
@@ -335,13 +332,13 @@ int main(int argc, char **argv)
         int rc;
 
         setlinebuf(stdout);
-                                                                                                                             
+
         ptl_initialize(argc, argv);
         if (obd_initialize(argc, argv) < 0)
                 exit(2);
         if (dbg_initialize(argc, argv) < 0)
                 exit(3);
-                                                                                                                             
+
         Parser_init("lfs > ", cmdlist);
 
         if (argc > 1) {