Whamcloud - gitweb
LU-4961 lustre: remove liblustre.h and obd.h from userspace
[fs/lustre-release.git] / lustre / utils / lustre_cfg.c
index 1c9ed42..6c8355d 100644 (file)
 #include <ctype.h>
 #include <glob.h>
 
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
-#include <lustre_lib.h>
+#include <libcfs/libcfs.h>
 #include <lustre_cfg.h>
 #include <lustre/lustre_idl.h>
-#include <lustre_dlm.h>
-#include <obd.h>          /* for struct lov_stripe_md */
-#include <obd_lov.h>
 #include <lustre/lustre_build_version.h>
 
 #include <unistd.h>
@@ -307,11 +301,6 @@ int jt_lcfg_add_uuid(int argc, char **argv)
         return do_add_uuid(argv[0], argv[1], nid);
 }
 
-int obd_add_uuid(char *uuid, lnet_nid_t nid)
-{
-        return do_add_uuid("obd_add_uuid", uuid, nid);
-}
-
 int jt_lcfg_del_uuid(int argc, char **argv)
 {
         int rc;
@@ -554,7 +543,7 @@ static int jt_lcfg_mgsparam2(int argc, char **argv, struct param_opts *popt)
                        int rc2 = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg);
                        if (rc2 != 0) {
                                fprintf(stderr, "error: executing %s: %s\n",
-                                       jt_cmdname(argv[0]), strerror(rc2));
+                                       jt_cmdname(argv[0]), strerror(errno));
                                if (rc == 0)
                                        rc = rc2;
                        }
@@ -576,13 +565,13 @@ static int jt_lcfg_mgsparam2(int argc, char **argv, struct param_opts *popt)
  * AT NEXT REBOOT, not immediately. */
 int jt_lcfg_mgsparam(int argc, char **argv)
 {
-        int rc;
-        int del = 0;
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-        char *buf = NULL;
+       int rc;
+       int del = 0;
+       struct lustre_cfg_bufs bufs;
+       struct lustre_cfg *lcfg;
+       char *buf = NULL;
 
-#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,7,53,0)
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 7, 53, 0)
        fprintf(stderr, "warning: 'lctl conf_param' is deprecated, "
                "use 'lctl set_param -P' instead\n");
 #endif
@@ -900,7 +889,13 @@ static int getparam_display(struct param_opts *popt, char *pattern)
                 /* As listparam_display is used to show param name (with type),
                  * here "if (only_path)" is ignored.*/
                 if (popt->po_show_path) {
-                        strcpy(filename, glob_info.gl_pathv[i]);
+                       if (strlen(glob_info.gl_pathv[i]) >
+                           sizeof(filename)-1) {
+                               free(buf);
+                               return -E2BIG;
+                       }
+                       strncpy(filename, glob_info.gl_pathv[i],
+                               sizeof(filename));
                         valuename = display_name(filename, 0);
                 }
 
@@ -1029,7 +1024,10 @@ static int setparam_display(struct param_opts *popt, char *pattern, char *value)
                char *valuename = NULL;
 
                if (popt->po_show_path) {
-                       strcpy(filename, glob_info.gl_pathv[i]);
+                       if (strlen(glob_info.gl_pathv[i]) > sizeof(filename)-1)
+                               return -E2BIG;
+                       strncpy(filename, glob_info.gl_pathv[i],
+                               sizeof(filename));
                        valuename = display_name(filename, 0);
                        if (valuename)
                                printf("%s=%s\n", valuename, value);
@@ -1079,6 +1077,8 @@ int jt_lcfg_setparam(int argc, char **argv)
                         *value = '\0';
                         value ++;
                         path = argv[i];
+                       if (*value == '\0')
+                               break;
                 } else {
                         /* format: set_param a b */
                         if (path == NULL) {
@@ -1099,6 +1099,9 @@ int jt_lcfg_setparam(int argc, char **argv)
                if (rc2 < 0 && rc == 0)
                        rc = rc2;
        }
+       if (path != NULL && (value == NULL || *value == '\0'))
+               fprintf(stderr, "error: %s: setting %s=: %s\n",
+                       jt_cmdname(argv[0]), path, strerror(rc = EINVAL));
 
        return rc;
 }