Changeset 604
- Timestamp:
- 05/15/07 23:31:21 (2 years ago)
- Files:
-
- trunk/src/vcd/methods/vxdb/vxdb_vx_limit_get.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/vcd/methods/vxdb/vxdb_vx_limit_get.c
r596 r604 16 16 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 17 18 #include <unistd.h> 19 #include <inttypes.h> 20 18 21 #include "auth.h" 19 22 #include "methods.h" … … 22 25 23 26 #include <lucid/log.h> 27 #include <lucid/scanf.h> 28 #include <lucid/str.h> 29 30 static 31 uint64_t bytestopages(uint64_t bytes) { 32 uint64_t pages; 33 pages = (bytes * 1024) / (uint64_t) getpagesize(); 34 return pages; 35 } 36 37 static 38 struct limtype_data { 39 char *type; 40 } LIMTYPE[] = { 41 { "ANON" }, 42 { "AS" }, 43 { "MAPPED" }, 44 { "MEMLOCK" }, 45 { "RSS" }, 46 { "SHMEM" }, 47 { NULL } 48 }; 24 49 25 50 /* vxdb.vx.limit.get(string name[, string type]) */ … … 69 94 70 95 vxdb_foreach_step(rc, dbr) 96 char *typedb = vxdb_column_text(dbr, 0); 97 uint64_t soft = vxdb_column_uint64(dbr, 1); 98 uint64_t max = vxdb_column_uint64(dbr, 2); 99 100 for(i = 0; LIMTYPE[i].type; i++) { 101 if (str_equal(typedb, LIMTYPE[i].type)) { 102 soft = bytestopages(soft); 103 max = bytestopages(max); 104 } 105 } 106 107 char *softs, maxs; 108 asprintf(&softs, "%" PRIu64, soft); 109 asprintf(&maxs, "%" PRIu64, max); 110 71 111 xmlrpc_array_append_item(env, response, xmlrpc_build_value(env, 72 112 "{s:s,s:s,s:s}", 73 "type", vxdb_column_text(dbr, 0),74 "soft", vxdb_column_text(dbr, 1),75 "max", vxdb_column_text(dbr, 2)));113 "type", typedb, 114 "soft", softs, 115 "max", maxs)); 76 116 77 117 if (rc != VXDB_DONE)
