Whamcloud - gitweb
LU-2785 osc: remove unused obd methods
[fs/lustre-release.git] / lnet / utils / debugctl.c
index 02cb9b4..93c208f 100644 (file)
@@ -1,7 +1,5 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  *
  *   This file is part of Portals, http://www.sf.net/projects/lustre/
  *
  *
  * Some day I'll split all of this functionality into a cfs_debug module
  * of its own.  That day is not today.
- *
  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <portals/api-support.h>
-#include <portals/ptlctl.h>
-#include "parser.h"
+#include <lnet/lnetctl.h>
+#include <libcfs/libcfsutil.h>
 
 
 command_t list[] = {
         {"debug_kernel", jt_dbg_debug_kernel, 0, "usage: debug_kernel [file] [raw], get debug buffer and print it [to a file]"},
-        {"debug_daemon", jt_dbg_debug_daemon, 0, "usage: debug_daemon [start file [#MB]|stop|pause|continue], control debug daemon to dump debug buffer to a file"}, 
+        {"debug_daemon", jt_dbg_debug_daemon, 0, "usage: debug_daemon [start file|stop], control debug daemon to dump debug buffer to a file"}, 
         {"debug_file", jt_dbg_debug_file, 0, "usage: debug_file <input> [output] [raw], read debug buffer from input and print it [to output]"},
         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer"},
         {"mark", jt_dbg_mark_debug_buf, 0, "insert a marker into the kernel debug buffer (args: [marker text])"},
@@ -50,17 +46,31 @@ command_t list[] = {
 
 int main(int argc, char **argv)
 {
-        if (dbg_initialize(argc, argv) < 0)
-                exit(2);
+        int rc = 0;
+
+        rc = libcfs_arch_init();
+        if (rc < 0)
+                return rc;
 
-        register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH);
+        rc =  dbg_initialize(argc, argv);
+        if (rc < 0)
+                goto errorout;
+
+        register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH, 
+                         LNET_DEV_MAJOR, LNET_DEV_MINOR);
 
         Parser_init("debugctl > ", list);
-        if (argc > 1)
-                return Parser_execarg(argc - 1, &argv[1], list);
+        if (argc > 1) {
+                rc = Parser_execarg(argc - 1, &argv[1], list);
+                unregister_ioc_dev(LNET_DEV_ID);
+                goto errorout;
+        }
 
         Parser_commands();
 
-        unregister_ioc_dev(PORTALS_DEV_ID);
-        return 0;
+        unregister_ioc_dev(LNET_DEV_ID);
+
+errorout:
+        libcfs_arch_cleanup();
+        return rc;
 }