Whamcloud - gitweb
* Landed portals:b_port_step as follows...
[fs/lustre-release.git] / lnet / libcfs / darwin / darwin-proc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include <sys/param.h>
23 #include <sys/kernel.h>
24 #include <sys/malloc.h>
25 #include <sys/systm.h>
26 #include <sys/sysctl.h>
27 #include <sys/proc.h>
28 #include <sys/unistd.h>
29 #include <mach/mach_types.h>
30
31 #define DEBUG_SUBSYSTEM S_PORTALS
32 #include <libcfs/libcfs.h>
33
34 static cfs_sysctl_table_header_t *portals_table_header = NULL;
35 extern unsigned int portal_debug;
36 extern char debug_file_path[1024];
37 extern unsigned int portal_subsystem_debug;
38 extern unsigned int portal_printk;
39 extern atomic_t portal_kmemory;
40
41 extern long max_debug_mb;
42 extern int cfs_trace_daemon SYSCTL_HANDLER_ARGS;
43 extern int cfs_debug_mb SYSCTL_HANDLER_ARGS;
44 /*
45  * sysctl table for portals
46  */
47 SYSCTL_NODE (,                  OID_AUTO,       portals,        CTLFLAG_RW,
48              0,                 "portals sysctl top");
49
50 SYSCTL_INT(_portals,                    OID_AUTO,       debug,  
51              CTLTYPE_INT | CTLFLAG_RW ,                 &portal_debug,  
52              0,         "debug");
53 SYSCTL_INT(_portals,                    OID_AUTO,       subsystem_debug,        
54              CTLTYPE_INT | CTLFLAG_RW,                  &portal_subsystem_debug,        
55              0,         "subsystem debug");
56 SYSCTL_INT(_portals,                    OID_AUTO,       printk, 
57              CTLTYPE_INT | CTLFLAG_RW,                  &portal_printk, 
58              0,         "printk");
59 SYSCTL_STRING(_portals,                 OID_AUTO,       debug_path,     
60              CTLTYPE_STRING | CTLFLAG_RW,               debug_file_path,        
61              1024,      "debug path");
62 SYSCTL_INT(_portals,                    OID_AUTO,       memused,        
63              CTLTYPE_INT | CTLFLAG_RW,                  (int *)&portal_kmemory.counter, 
64              0,         "memused");
65 SYSCTL_PROC(_portals,                   OID_AUTO,       trace_daemon,
66              CTLTYPE_STRING | CTLFLAG_RW,               0,
67              0,         &cfs_trace_daemon,              "A",    "trace daemon");
68 SYSCTL_PROC(_portals,                   OID_AUTO,       debug_mb,
69              CTLTYPE_INT | CTLFLAG_RW,                  &max_debug_mb,
70              0,         &cfs_debug_mb,                  "L",    "max debug size");
71
72
73 static cfs_sysctl_table_t       top_table[] = {
74         &sysctl__portals,
75         &sysctl__portals_debug,
76         &sysctl__portals_subsystem_debug,
77         &sysctl__portals_printk,
78         &sysctl__portals_debug_path,
79         &sysctl__portals_memused,
80         &sysctl__portals_trace_daemon,
81         &sysctl__portals_debug_mb,
82         NULL
83 };
84
85 /* no proc in osx */
86 cfs_proc_dir_entry_t *
87 cfs_create_proc_entry(char *name, int mod, cfs_proc_dir_entry_t *parent)
88 {
89         cfs_proc_dir_entry_t *entry;
90         MALLOC(entry, cfs_proc_dir_entry_t *, sizeof(cfs_proc_dir_entry_t), M_TEMP, M_WAITOK|M_ZERO);
91
92         return  entry;
93 }
94
95 void
96 cfs_free_proc_entry(cfs_proc_dir_entry_t *de){
97         FREE(de, M_TEMP);
98         return;
99 };
100
101 void
102 cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry)
103 {
104         cfs_free_proc_entry(entry);
105         return;
106 }
107
108 int
109 insert_proc(void)
110 {
111 #if 1
112         if (!portals_table_header) 
113                 portals_table_header = register_cfs_sysctl_table(top_table, 0);
114 #endif
115         return 0;
116 }
117
118 void
119 remove_proc(void)
120 {
121 #if 1
122         if (portals_table_header != NULL) 
123                 unregister_cfs_sysctl_table(portals_table_header); 
124         portals_table_header = NULL;
125 #endif
126         return;
127 }
128
129