Whamcloud - gitweb
LU-2785 osc: remove unused obd methods
[fs/lustre-release.git] / lnet / utils / debug.c
index ce8892f..a0c0ce1 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -29,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -58,23 +56,8 @@ static int debug_mask = ~0;
 
 #define MAX_MARK_SIZE 256
 
-static const char *libcfs_debug_subsystems[] =
-        {"undefined", "mdc", "mds", "osc",
-         "ost", "class", "log", "llite",
-         "rpc", "mgmt", "lnet", "lnd",
-         "pinger", "filter", "", "echo",
-         "ldlm", "lov", "lquota", "",
-         "", "", "", "lmv",
-         "", "sec", "gss", "", 
-         "mgc", "mgs", "fid", "fld", NULL};
-static const char *libcfs_debug_masks[] =
-        {"trace", "inode", "super", "ext2",
-         "malloc", "cache", "info", "ioctl",
-         "neterror", "net", "warning", "buffs",
-         "other", "dentry", "nettrace", "page",
-         "dlmtrace", "error", "emerg", "ha",
-         "rpctrace", "vfstrace", "reada", "mmap",
-         "config", "console", "quota", "sec", NULL};
+static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
+static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
 
 #ifdef __linux__
 
@@ -602,11 +585,21 @@ int jt_dbg_debug_kernel(int argc, char **argv)
         /* If we are dumping raw (which means no conversion step to ASCII)
          * then dump directly to any supplied filename, otherwise this is
          * just a temp file and we dump to the real file at convert time. */
-        if (argc > 1 && raw)
-                strcpy(filename, argv[1]);
-        else
-                sprintf(filename, "%s"CFS_TIME_T".%u",
-                       LIBCFS_DEBUG_FILE_PATH_DEFAULT, time(NULL), getpid());
+       if (argc > 1 && raw) {
+               if (strlen(argv[1]) > sizeof(filename)-1) {
+                       fprintf(stderr, "File name too long: %s\n", argv[1]);
+                       return 1;
+               }
+               strncpy(filename, argv[1], sizeof(filename));
+       } else {
+               if (snprintf(filename, sizeof(filename), "%s"CFS_TIME_T".%u",
+                            LIBCFS_DEBUG_FILE_PATH_DEFAULT, time(NULL),
+                            getpid()) >=
+                   sizeof(filename)) {
+                       fprintf(stderr, "File name too long\n");
+                       return 1;
+               }
+       }
 
         if (stat(filename, &st) == 0 && S_ISREG(st.st_mode))
                 unlink(filename);
@@ -851,63 +844,51 @@ int jt_dbg_mark_debug_buf(int argc, char **argv)
 }
 
 static struct mod_paths {
-        char *name, *path;
+       char *name, *path;
 } mod_paths[] = {
-        {"libcfs", "libcfs/libcfs"},
-        {"lnet", "lnet/lnet"},
-        {"kmxlnd", "lnet/klnds/mxlnd"},
-        {"ko2iblnd", "lnet/klnds/o2iblnd"},
-        {"kptllnd", "lnet/klnds/ptllnd"},
-        {"kqswlnd", "lnet/klnds/qswlnd"},
-        {"kralnd", "lnet/klnds/ralnd"},
-        {"ksocklnd", "lnet/klnds/socklnd"},
-        {"ktdilnd", "lnet/klnds/tdilnd"},
-        {"lvfs", "lustre/lvfs"},
-        {"obdclass", "lustre/obdclass"},
-        {"llog_test", "lustre/obdclass"},
-        {"ptlrpc_gss", "lustre/ptlrpc/gss"},
-        {"ptlrpc", "lustre/ptlrpc"},
-        {"gks", "lustre/sec/gks"},
-        {"gkc", "lustre/sec/gks"},
-        {"ost", "lustre/ost"},
-        {"osc", "lustre/osc"},
-        {"mds", "lustre/mds"},
-        {"mdc", "lustre/mdc"},
-        {"llite", "lustre/llite"},
-        {"lustre", "lustre/llite"},
-        {"llite_lloop", "lustre/llite"},
-        {"ldiskfs", "ldiskfs/ldiskfs"},
-        {"smfs", "lustre/smfs"},
-        {"obdecho", "lustre/obdecho"},
-        {"ldlm", "lustre/ldlm"},
-        {"obdfilter", "lustre/obdfilter"},
-        {"lov", "lustre/lov"},
-        {"lmv", "lustre/lmv"},
-        {"fsfilt_ext3", "lustre/lvfs"},
-        {"fsfilt_reiserfs", "lustre/lvfs"},
-        {"fsfilt_smfs", "lustre/lvfs"},
-        {"fsfilt_ldiskfs", "lustre/lvfs"},
-        {"mds_ext3", "lustre/mds"},
-        {"cobd", "lustre/cobd"},
-        {"cmobd", "lustre/cmobd"},
-        {"lquota", "lustre/quota"},
-        {"mgs", "lustre/mgs"},
-        {"mgc", "lustre/mgc"},
-        {"mdt", "lustre/mdt"},
-        {"mdd", "lustre/mdd"},
-        {"osd", "lustre/osd"},
-        {"cmm", "lustre/cmm"},
+       { "libcfs", "libcfs/libcfs" },
+       { "lnet", "lnet/lnet" },
+       { "kmxlnd", "lnet/klnds/mxlnd" },
+       { "ko2iblnd", "lnet/klnds/o2iblnd" },
+       { "kgnilnd", "lnet/klnds/gnilnd"},
+       { "kqswlnd", "lnet/klnds/qswlnd" },
+       { "kralnd", "lnet/klnds/ralnd" },
+       { "ksocklnd", "lnet/klnds/socklnd" },
+       { "ktdilnd", "lnet/klnds/tdilnd" },
+       { "obdclass", "lustre/obdclass" },
+       { "llog_test", "lustre/obdclass" },
+       { "ptlrpc_gss", "lustre/ptlrpc/gss" },
+       { "ptlrpc", "lustre/ptlrpc" },
+       { "gks", "lustre/sec/gks" },
+       { "gkc", "lustre/sec/gks" },
+       { "ost", "lustre/ost" },
+       { "osc", "lustre/osc" },
+       { "mds", "lustre/mds" },
+       { "mdc", "lustre/mdc" },
+       { "lustre", "lustre/llite" },
+       { "llite_lloop", "lustre/llite" },
+       { "ldiskfs", "ldiskfs" },
+       { "obdecho", "lustre/obdecho" },
+       { "ldlm", "lustre/ldlm" },
+       { "obdfilter", "lustre/obdfilter" },
+       { "lov", "lustre/lov" },
+       { "lmv", "lustre/lmv" },
+       { "lquota", "lustre/quota" },
+       { "mgs", "lustre/mgs" },
+       { "mgc", "lustre/mgc" },
+       { "mdt", "lustre/mdt" },
+       { "mdd", "lustre/mdd" },
+       { "osd", "lustre/osd" },
+       { "cmm", "lustre/cmm" },
         {"fid", "lustre/fid"},
         {"fld", "lustre/fld"},
+       {"lod", "lustre/lod"},
+       {"osp", "lustre/osp"},
+       { "lfsck", "lustre/lfsck" },
         {NULL, NULL}
 };
 
-static int jt_dbg_modules_2_4(int argc, char **argv)
-{
-        return -EINVAL;
-}
-
-static int jt_dbg_modules_2_5(int argc, char **argv)
+int jt_dbg_modules(int argc, char **argv)
 {
         struct mod_paths *mp;
         char *path = "";
@@ -935,11 +916,11 @@ static int jt_dbg_modules_2_5(int argc, char **argv)
                                 if (!strcmp(mp->name, modname))
                                         break;
                         }
-                        if (mp->name) {
-                                printf("add-symbol-file %s%s%s/%s.o 0x%0lx\n", 
-                                       path, path[0] ? "/" : "", 
-                                       mp->path, mp->name, modaddr);
-                        }
+                       if (mp->name) {
+                               printf("add-symbol-file %s%s%s/%s.o 0x%0lx\n",
+                                       path, path[0] ? "/" : "",
+                                       mp->path, mp->name, modaddr);
+                       }
                 }
         }
 
@@ -947,26 +928,6 @@ static int jt_dbg_modules_2_5(int argc, char **argv)
         return 0;
 }
 
-int jt_dbg_modules(int argc, char **argv)
-{
-        int rc = 0;
-        struct utsname sysinfo;
-
-        rc = uname(&sysinfo);
-        if (rc) {
-                printf("uname() failed: %s\n", strerror(errno));
-                return 0;
-        }
-
-        if (sysinfo.release[2] > '4') {
-                return jt_dbg_modules_2_5(argc, argv);
-        } else {
-                return jt_dbg_modules_2_4(argc, argv);
-        }
-
-        return 0;
-}
-
 int jt_dbg_panic(int argc, char **argv)
 {
         int rc;