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 55
 {
55 56
 	struct sr_module* t;
56 57
 	rpc_export_t* ptr;
57
-	
58
+
58 59
 	for(ptr = core_rpc_methods; ptr && ptr->name; ptr++) {
59 60
 		if (rpc->add(c, "s", ptr->name) < 0) return;
60 61
 	}
... ...
@@ -83,7 +84,7 @@ static const char* system_methodHelp_doc[] = {
83 84
 };
84 85
 
85 86
 static void system_methodHelp(rpc_t* rpc, void* c)
86
-{	
87
+{
87 88
 	struct sr_module* t;
88 89
 	rpc_export_t* ptr;
89 90
 	char* name;
... ...
@@ -146,7 +147,7 @@ static void core_uptime(rpc_t* rpc, void* c)
146 147
 	time_t now;
147 148
 
148 149
 	time(&now);
149
-	
150
+
150 151
 	if (rpc->add(c, "{", &s) < 0) return;
151 152
 	rpc->struct_add(s, "s", "now", ctime(&now));
152 153
 	rpc->struct_add(s, "s", "up_since", up_since_ctime);
... ...
@@ -229,14 +230,30 @@ static void core_kill(rpc_t* rpc, void* c)
229 230
 	kill(0, sig_no);
230 231
 }
231 232
 
232
-static const char* core_test_doc[] = {
233
-	"Sends the given signal to SER.",  /* Documentation string */
234
-	0                                  /* Method signature(s) */
233
+static void core_shmmem(rpc_t* rpc, void* c)
234
+{
235
+	struct mem_info mi;
236
+	void *handle;
237
+
238
+	shm_info(&mi);
239
+	rpc->add(c, "{", &handle);
240
+	rpc->struct_add(handle, "ddddd",
241
+		"total", mi.total_size,
242
+		"free", mi.free,
243
+		"used", mi.real_used,
244
+		"max_used", mi.max_used,
245
+		"fragments", mi.total_frags
246
+	);
247
+}
248
+
249
+static const char* core_shmmem_doc[] = {
250
+	"Returns shared memory info.",  /* Documentation string */
251
+	0                               /* Method signature(s) */
235 252
 };
236 253
 
237 254
 
238
-/* 
239
- * RPC Methods exported by this module 
255
+/*
256
+ * RPC Methods exported by this module
240 257
  */
241 258
 rpc_export_t core_rpc_methods[] = {
242 259
 	{"system.listMethods",     system_listMethods,     system_listMethods_doc,     RET_ARRAY},
... ...
@@ -249,6 +266,7 @@ rpc_export_t core_rpc_methods[] = {
249 266
 	{"core.pwd",               core_pwd,               core_pwd_doc,               RET_ARRAY},
250 267
 	{"core.arg",               core_arg,               core_arg_doc,               RET_ARRAY},
251 268
 	{"core.kill",              core_kill,              core_kill_doc,              0        },
269
+	{"core.shmmem",            core_shmmem,            core_shmmem_doc,            0	},
252 270
 	{0, 0, 0, 0}
253 271
 };
254 272