Whamcloud - gitweb
b=23270 simplify "lctl osts" (llapi_ostlist) code
authorAndreas Dilger <andreas.dilger@oracle.com>
Mon, 9 Aug 2010 15:08:51 +0000 (19:08 +0400)
committerMikhail Pershin <tappro@sun.com>
Fri, 13 Aug 2010 06:02:55 +0000 (10:02 +0400)
Simplify "lfs osts" command so that it avoids the filesystem traversal code
entirely, and just calls setup_osts() to print the OST list.

i=andrew.perepechko
i=sheng.yang

lustre/utils/liblustreapi.c

index 0855805..94be89b 100644 (file)
@@ -1357,27 +1357,19 @@ retry_get_uuids:
         return ret;
 }
 
-static int cb_ostlist(char *path, DIR *parent, DIR *d, void *data,
-                      struct dirent64 *de)
+int llapi_ostlist(char *path, struct find_param *param)
 {
-        struct find_param *param = (struct find_param *)data;
+        DIR *dir;
         int ret;
 
-        LASSERT(parent != NULL || d != NULL);
-
-        /* Prepare odb. */
-        ret = setup_obd_uuid(d ? d : parent, path, param);
+        dir = opendir(path);
+        if (dir == NULL)
+                return -errno;
 
-        /* We don't want to actually traverse the directory tree,
-         * so return a positive value from sem_init to terminate
-         * the traversal before it starts.
-         */
-        return ret == 0 ? 1 : ret;
-}
+        ret = setup_obd_uuid(dir, path, param);
+        closedir(dir);
 
-int llapi_ostlist(char *path, struct find_param *param)
-{
-        return param_callback(path, cb_ostlist, cb_common_fini, param);
+        return ret;
 }
 
 static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,