Whamcloud - gitweb
LU-5030 util: migrate liblustreapi to use cfs_get_paths()
[fs/lustre-release.git] / lustre / utils / lustreapi_internal.h
index a5d7ac1..00a66e3 100644 (file)
@@ -35,6 +35,7 @@
 #ifndef _LUSTREAPI_INTERNAL_H_
 #define _LUSTREAPI_INTERNAL_H_
 
+#include <glob.h>
 #include <uapi_kernelcomm.h>
 
 #define WANT_PATH   0x1
 int get_root_path(int want, char *fsname, int *outfd, char *path, int index);
 int root_ioctl(const char *mdtname, int opc, void *data, int *mdtidxp,
               int want_error);
-int get_param(const char *param_path, char *result,
-             unsigned int result_size);
+
+/**
+ * Often when determining the parameter path in sysfs/procfs we
+ * are often only interest set of data. This enum gives use the
+ * ability to return data of parameters for:
+ *
+ * FILTER_BY_FS_NAME: a specific file system mount
+ * FILTER_BY_PATH:    Using a Lustre file path to determine which
+ *                   file system is of interest
+ * FILTER_BY_EXACT:   The default behavior. Search the parameter
+ *                   path as is.
+ */
+enum param_filter {
+       FILTER_BY_EXACT,
+       FILTER_BY_FS_NAME,
+       FILTER_BY_PATH
+};
+
+int get_lustre_param_path(const char *obd_type, const char *filter,
+                         enum param_filter type, const char *param_name,
+                         glob_t *param);
+int get_lustre_param_value(const char *obd_type, const char *filter,
+                          enum param_filter type, const char *param_name,
+                          char *value, size_t val_len);
+
+static inline int
+poolpath(glob_t *pool_path, const char *fsname, char *pathname)
+{
+       int rc;
+
+       if (fsname != NULL)
+               rc = get_lustre_param_path("lov", fsname, FILTER_BY_FS_NAME,
+                                          "pools", pool_path);
+       else
+               rc = get_lustre_param_path("lov", pathname, FILTER_BY_PATH,
+                                          "pools", pool_path);
+       return rc;
+}
 
 #define LLAPI_LAYOUT_MAGIC 0x11AD1107 /* LLAPILOT */