Browse code

- core.shmmem command added

Tomas Mandys authored on 10/01/2006 15:41:33
Showing 1 changed files
... ...
@@ -20,8 +20,8 @@
20 20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 21
  * GNU General Public License for more details.
22 22
  *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program; if not, write to the Free Software
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27 27
 
... ...
@@ -29,6 +29,7 @@
29 29
 #include <sys/types.h>
30 30
 #include <signal.h>
31 31
 #include "mem/mem.h"
32
+#include "mem/shm_mem.h"
32 33
 #include "sr_module.h"
33 34
 #include "dprint.h"
34 35
 #include "core_cmd.h"
... ...
@@ -54,7 +55,7 @@ static void system_listMethods(rpc_t* rpc, void* c)
54 54
 {
55 55
 	struct sr_module* t;
56 56
 	rpc_export_t* ptr;
57
-	
57
+
58 58
 	for(ptr = core_rpc_methods; ptr && ptr->name; ptr++) {
59 59
 		if (rpc->add(c, "s", ptr->name) < 0) return;
60 60
 	}
... ...
@@ -83,7 +84,7 @@ static const char* system_methodHelp_doc[] = {
83 83
 };
84 84
 
85 85
 static void system_methodHelp(rpc_t* rpc, void* c)
86
-{	
86
+{
87 87
 	struct sr_module* t;
88 88
 	rpc_export_t* ptr;
89 89
 	char* name;
... ...
@@ -146,7 +147,7 @@ static void core_uptime(rpc_t* rpc, void* c)
146 146
 	time_t now;
147 147
 
148 148
 	time(&now);
149
-	
149
+
150 150
 	if (rpc->add(c, "{", &s) < 0) return;
151 151
 	rpc->struct_add(s, "s", "now", ctime(&now));
152 152
 	rpc->struct_add(s, "s", "up_since", up_since_ctime);
... ...
@@ -229,14 +230,30 @@ static void core_kill(rpc_t* rpc, void* c)
229 229
 	kill(0, sig_no);
230 230
 }
231 231
 
232
-static const char* core_test_doc[] = {
233
-	"Sends the given signal to SER.",  /* Documentation string */
234
-	0                                  /* Method signature(s) */
232
+static void core_shmmem(rpc_t* rpc, void* c)
233
+{
234
+	struct mem_info mi;
235
+	void *handle;
236
+
237
+	shm_info(&mi);
238
+	rpc->add(c, "{", &handle);
239
+	rpc->struct_add(handle, "ddddd",
240
+		"total", mi.total_size,
241
+		"free", mi.free,
242
+		"used", mi.real_used,
243
+		"max_used", mi.max_used,
244
+		"fragments", mi.total_frags
245
+	);
246
+}
247
+
248
+static const char* core_shmmem_doc[] = {
249
+	"Returns shared memory info.",  /* Documentation string */
250
+	0                               /* Method signature(s) */
235 251
 };
236 252
 
237 253
 
238
-/* 
239
- * RPC Methods exported by this module 
254
+/*
255
+ * RPC Methods exported by this module
240 256
  */
241 257
 rpc_export_t core_rpc_methods[] = {
242 258
 	{"system.listMethods",     system_listMethods,     system_listMethods_doc,     RET_ARRAY},
... ...
@@ -249,6 +266,7 @@ rpc_export_t core_rpc_methods[] = {
249 249
 	{"core.pwd",               core_pwd,               core_pwd_doc,               RET_ARRAY},
250 250
 	{"core.arg",               core_arg,               core_arg_doc,               RET_ARRAY},
251 251
 	{"core.kill",              core_kill,              core_kill_doc,              0        },
252
+	{"core.shmmem",            core_shmmem,            core_shmmem_doc,            0	},
252 253
 	{0, 0, 0, 0}
253 254
 };
254 255