Changeset 601

Show
Ignore:
Timestamp:
05/15/07 22:58:34 (2 years ago)
Author:
chtekk
Message:

Add automatic conversion from bytes to pages for the limits that need it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vcd/methods/vx/vx_limstatus.c

    r600 r601  
    3030int pagestobytes(int pages) { 
    3131        int bytes; 
    32         bytes = (pages * getpagesize()) >> 10
     32        bytes = (pages * getpagesize()) / 1024
    3333        return bytes; 
    3434} 
  • trunk/src/vcd/methods/vxdb/vxdb_vx_limit_set.c

    r575 r601  
    1616// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    1717 
     18#include <unistd.h> 
    1819#include <inttypes.h> 
    1920 
     
    2627#include <lucid/scanf.h> 
    2728#include <lucid/str.h> 
     29 
     30static 
     31uint64_t bytestopages(uint64_t bytes) { 
     32        uint64_t pages; 
     33        pages = (bytes * 1024) / (uint64_t) getpagesize(); 
     34        return pages; 
     35} 
     36 
     37static 
     38struct limtype_data { 
     39        char *type; 
     40} LIMTYPE[] = { 
     41        { "RLIMIT_AS"      }, 
     42        { "RLIMIT_MEMLOCK" }, 
     43        { "RLIMIT_RSS"     }, 
     44        { "VLIMIT_ANON"    }, 
     45        { "VLIMIT_MAPPED"  }, 
     46        { "VLIMIT_SHMEM"   }, 
     47        { NULL             } 
     48}; 
    2849 
    2950/* vxdb.vx.limit.set(string name, string type, string soft, string max) */ 
     
    7495                method_return_fault(env, MENOVPS); 
    7596 
     97        for(i = 0; LIMTYPE[i].type; i++) { 
     98                if (str_equal(type, LIMTYPE[i].type)) { 
     99                        soft = bytestopages(soft); 
     100                        max = bytestopages(max); 
     101                } 
     102        } 
     103 
    76104        rc = vxdb_exec( 
    77105                        "INSERT OR REPLACE INTO vx_limit (xid, type, soft, max) "