Whamcloud - gitweb
Land b_release_1_4_3 onto HEAD (20050619_0305)
[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 unsigned int portals_catastrophe;
40 extern atomic_t portal_kmemory;
41
42 extern long max_debug_mb;
43 extern int cfs_trace_daemon SYSCTL_HANDLER_ARGS;
44 extern int cfs_debug_mb SYSCTL_HANDLER_ARGS;
45 /*
46  * sysctl table for portals
47  */
48 SYSCTL_NODE (,                  OID_AUTO,       portals,        CTLFLAG_RW,
49              0,                 "portals sysctl top");
50
51 SYSCTL_INT(_portals,                    OID_AUTO,       debug,  
52              CTLTYPE_INT | CTLFLAG_RW ,                 &portal_debug,  
53              0,         "debug");
54 SYSCTL_INT(_portals,                    OID_AUTO,       subsystem_debug,        
55              CTLTYPE_INT | CTLFLAG_RW,                  &portal_subsystem_debug,        
56              0,         "subsystem debug");
57 SYSCTL_INT(_portals,                    OID_AUTO,       printk, 
58              CTLTYPE_INT | CTLFLAG_RW,                  &portal_printk, 
59              0,         "printk");
60 SYSCTL_STRING(_portals,                 OID_AUTO,       debug_path,     
61              CTLTYPE_STRING | CTLFLAG_RW,               debug_file_path,        
62              1024,      "debug path");
63 SYSCTL_INT(_portals,                    OID_AUTO,       memused,        
64              CTLTYPE_INT | CTLFLAG_RW,                  (int *)&portal_kmemory.counter, 
65              0,         "memused");
66 SYSCTL_PROC(_portals,                   OID_AUTO,       trace_daemon,
67              CTLTYPE_STRING | CTLFLAG_RW,               0,
68              0,         &cfs_trace_daemon,              "A",    "trace daemon");
69 SYSCTL_PROC(_portals,                   OID_AUTO,       debug_mb,
70              CTLTYPE_INT | CTLFLAG_RW,                  &max_debug_mb,
71              0,         &cfs_debug_mb,                  "L",    "max debug size");
72 #warning "add 'catastrophe' entry for LBUG detection"
73
74
75 static cfs_sysctl_table_t       top_table[] = {
76         &sysctl__portals,
77         &sysctl__portals_debug,
78         &sysctl__portals_subsystem_debug,
79         &sysctl__portals_printk,
80         &sysctl__portals_debug_path,
81         &sysctl__portals_memused,
82         &sysctl__portals_trace_daemon,
83         &sysctl__portals_debug_mb,
84         NULL
85 };
86
87 /* no proc in osx */
88 cfs_proc_dir_entry_t *
89 cfs_create_proc_entry(char *name, int mod, cfs_proc_dir_entry_t *parent)
90 {
91         cfs_proc_dir_entry_t *entry;
92         MALLOC(entry, cfs_proc_dir_entry_t *, sizeof(cfs_proc_dir_entry_t), M_TEMP, M_WAITOK|M_ZERO);
93
94         return  entry;
95 }
96
97 void
98 cfs_free_proc_entry(cfs_proc_dir_entry_t *de){
99         FREE(de, M_TEMP);
100         return;
101 };
102
103 void
104 cfs_remove_proc_entry(char *name, cfs_proc_dir_entry_t *entry)
105 {
106         cfs_free_proc_entry(entry);
107         return;
108 }
109
110 int
111 insert_proc(void)
112 {
113 #if 1
114         if (!portals_table_header) 
115                 portals_table_header = register_cfs_sysctl_table(top_table, 0);
116 #endif
117         return 0;
118 }
119
120 void
121 remove_proc(void)
122 {
123 #if 1
124         if (portals_table_header != NULL) 
125                 unregister_cfs_sysctl_table(portals_table_header); 
126         portals_table_header = NULL;
127 #endif
128         return;
129 }
130
131