Whamcloud - gitweb
b=23270 simplify "lctl osts" (llapi_ostlist) code
authorAndreas Dilger <andreas.dilger@oracle.com>
Mon, 9 Aug 2010 14:25:34 +0000 (10:25 -0400)
committerJohann Lombardi <johann.lombardi@oracle.com>
Tue, 10 Aug 2010 08:33:12 +0000 (10:33 +0200)
Simplify "lfs osts" command so that it avoids the filesystem traversal code
entirely, and just calls setup_osts() to print the OST list.

lustre/utils/liblustreapi.c

index e466d49..1e88a51 100644 (file)
@@ -1337,27 +1337,20 @@ 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,