]> Zhao Yanbai Git Server - minix.git/commitdiff
Message type for {PM,VFS,VM}_GETRUSAGE
authorLionel Sambuc <lionel@minix3.org>
Mon, 19 May 2014 09:18:20 +0000 (11:18 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:44 +0000 (17:05 +0200)
Change-Id: I793d2e9fa8eb0562a46ccbd81aae3dbb517671cc

include/minix/com.h
include/minix/ipc.h
lib/libc/sys-minix/getrusage.c
servers/pm/misc.c
servers/vfs/misc.c
servers/vm/utility.c

index 36a071375cad32d88fba62f87daf24875c0356c6..444db2677eca612a26f795ee41b1854a7c802a9d 100644 (file)
 #define SVRCTL_REQ             m2_i1   /* int */
 #define SVRCTL_ARG             m2_p1   /* void * */
 
-/* Field names for the getrusage(2) call. */
-#define RU_ENDPT               m1_i1   /* endpoint_t */
-#define RU_WHO                 m1_i1   /* int */
-#define RU_RUSAGE_ADDR         m1_p1   /* struct rusage * */
-
 /*===========================================================================*
  *             Internal codes used by several services                      *
  *===========================================================================*/
index 6a961d5c77197e142dcfa1ba0835ece370eabcd0..21cea51687a733a20ee8325d691ce08b306f376d 100644 (file)
@@ -251,6 +251,14 @@ typedef struct {
 } mess_lc_pm_reboot;
 _ASSERT_MSG_SIZE(mess_lc_pm_reboot);
 
+typedef struct {
+       endpoint_t who;
+       vir_bytes addr;
+
+       uint8_t padding[48];
+} mess_lc_pm_rusage;
+_ASSERT_MSG_SIZE(mess_lc_pm_rusage);
+
 typedef struct {
        gid_t gid;
 
@@ -529,6 +537,13 @@ typedef struct {
 } mess_lc_vfs_readwrite;
 _ASSERT_MSG_SIZE(mess_lc_vfs_readwrite);
 
+typedef struct {
+       vir_bytes addr;
+
+       uint8_t padding[52];
+} mess_lc_vfs_rusage;
+_ASSERT_MSG_SIZE(mess_lc_vfs_rusage);
+
 typedef struct {
        uint32_t nfds;
        fd_set *readfds;
@@ -588,6 +603,13 @@ typedef struct {
 } mess_lc_vfs_umount;
 _ASSERT_MSG_SIZE(mess_lc_vfs_umount);
 
+typedef struct {
+       vir_bytes addr;
+
+       uint8_t padding[52];
+} mess_lc_vm_rusage;
+_ASSERT_MSG_SIZE(mess_lc_vm_rusage);
+
 typedef struct {
        endpoint_t endpt;
        vir_bytes ptr;          /* struct exec_info * */
@@ -1289,6 +1311,7 @@ typedef struct {
                mess_lc_pm_priority     m_lc_pm_priority;
                mess_lc_pm_ptrace       m_lc_pm_ptrace;
                mess_lc_pm_reboot       m_lc_pm_reboot;
+               mess_lc_pm_rusage       m_lc_pm_rusage;
                mess_lc_pm_setgid       m_lc_pm_setgid;
                mess_lc_pm_setuid       m_lc_pm_setuid;
                mess_lc_pm_sig          m_lc_pm_sig;
@@ -1316,6 +1339,7 @@ typedef struct {
                mess_lc_vfs_pipe2       m_lc_vfs_pipe2;
                mess_lc_vfs_readlink    m_lc_vfs_readlink;
                mess_lc_vfs_readwrite   m_lc_vfs_readwrite;
+               mess_lc_vfs_rusage      m_lc_vfs_rusage;
                mess_lc_vfs_select      m_lc_vfs_select;
                mess_lc_vfs_stat        m_lc_vfs_stat;
                mess_lc_vfs_statvfs1    m_lc_vfs_statvfs1;
@@ -1323,6 +1347,8 @@ typedef struct {
                mess_lc_vfs_umask       m_lc_vfs_umask;
                mess_lc_vfs_umount      m_lc_vfs_umount;
 
+               mess_lc_vm_rusage       m_lc_vm_rusage;
+
                mess_lexec_pm_exec_new  m_lexec_pm_exec_new;
 
                mess_li2cdriver_i2c_busc_i2c_exec m_li2cdriver_i2c_busc_i2c_exec;
index faeb83230c945711b14ba2528c838a3363a9dff8..43767e32ed7b1c6449fbb8fa31e21c1a65bd399a 100644 (file)
@@ -12,8 +12,8 @@ int getrusage(int who, struct rusage *r_usage)
        message m;
 
        memset(&m, 0, sizeof(m));
-       m.RU_WHO = who;
-       m.RU_RUSAGE_ADDR = (char *) r_usage;
+       m.m_lc_pm_rusage.who = who;
+       m.m_lc_pm_rusage.addr = (vir_bytes)r_usage;
 
        if (r_usage == NULL) {
                errno = EFAULT;
@@ -29,11 +29,11 @@ int getrusage(int who, struct rusage *r_usage)
                return rc;
 
        memset(&m, 0, sizeof(m));
-       m.RU_RUSAGE_ADDR = (char *) r_usage;
+       m.m_lc_vfs_rusage.addr = (vir_bytes)r_usage;
        if ((rc = _syscall(VFS_PROC_NR, VFS_GETRUSAGE, &m)) < 0)
                return rc;
 
        memset(&m, 0, sizeof(m));
-       m.RU_RUSAGE_ADDR = (char *) r_usage;
+       m.m_lc_vm_rusage.addr = (vir_bytes)r_usage;
        return _syscall(VM_PROC_NR, VM_GETRUSAGE, &m);
 }
index 8649ad63958842f7a3d72a46d61b43af570a0415..63de747fba09f1a3b532c34b6c9efe514a4fd684 100644 (file)
@@ -407,12 +407,13 @@ int do_getrusage()
        clock_t sys_time = 0;
        struct rusage r_usage;
        u64_t usec;
-       if (m_in.RU_WHO != RUSAGE_SELF && m_in.RU_WHO != RUSAGE_CHILDREN)
+       if (m_in.m_lc_pm_rusage.who != RUSAGE_SELF &&
+               m_in.m_lc_pm_rusage.who != RUSAGE_CHILDREN)
                return EINVAL;
        if ((res = sys_getrusage(&r_usage, who_e)) < 0)
                return res;
 
-       if (m_in.RU_WHO == RUSAGE_CHILDREN) {
+       if (m_in.m_lc_pm_rusage.who == RUSAGE_CHILDREN) {
                usec = mp->mp_child_utime * 1000000 / sys_hz();
                r_usage.ru_utime.tv_sec = usec / 1000000;
                r_usage.ru_utime.tv_usec = usec % 1000000;
@@ -421,6 +422,6 @@ int do_getrusage()
                r_usage.ru_stime.tv_usec = usec % 1000000;
        }
 
-       return sys_datacopy(SELF, (vir_bytes) &r_usage, who_e,
-               (vir_bytes) m_in.RU_RUSAGE_ADDR, (vir_bytes) sizeof(r_usage));
+       return sys_datacopy(SELF, (vir_bytes)&r_usage, who_e,
+               m_in.m_lc_pm_rusage.addr, (vir_bytes) sizeof(r_usage));
 }
index b803d2c45c728dc83e5929487a52b00d1e4f64c5..69dae6507f82c20df28187a0f1d2d1739e11a16d 100644 (file)
@@ -961,7 +961,7 @@ int do_getrusage(void)
        int res;
        struct rusage r_usage;
 
-       if ((res = sys_datacopy_wrapper(who_e, (vir_bytes) m_in.RU_RUSAGE_ADDR, SELF,
+       if ((res = sys_datacopy_wrapper(who_e, m_in.m_lc_vfs_rusage.addr, SELF,
                (vir_bytes) &r_usage, (vir_bytes) sizeof(r_usage))) < 0)
                return res;
 
@@ -972,5 +972,5 @@ int do_getrusage(void)
        r_usage.ru_isrss = DEFAULT_STACK_LIMIT;
 
        return sys_datacopy_wrapper(SELF, (vir_bytes) &r_usage, who_e,
-               (vir_bytes) m_in.RU_RUSAGE_ADDR, (phys_bytes) sizeof(r_usage));
+               m_in.m_lc_vfs_rusage.addr, (phys_bytes) sizeof(r_usage));
 }
index aa00c95badac6416b6218d6c2c44ff4b95a0159f..93639180787b2e4e29e97df8e3b82ec348577f69 100644 (file)
@@ -344,7 +344,7 @@ int do_getrusage(message *m)
 
        vmp = &vmproc[slot];
 
-       if ((res = sys_datacopy(m->m_source, (vir_bytes) m->RU_RUSAGE_ADDR,
+       if ((res = sys_datacopy(m->m_source, m->m_lc_vm_rusage.addr,
                SELF, (vir_bytes) &r_usage, (vir_bytes) sizeof(r_usage))) < 0)
                return res;
 
@@ -353,5 +353,5 @@ int do_getrusage(message *m)
        r_usage.ru_majflt = vmp->vm_major_page_fault;
 
        return sys_datacopy(SELF, (vir_bytes) &r_usage, m->m_source,
-               (vir_bytes) m->RU_RUSAGE_ADDR, (vir_bytes) sizeof(r_usage));
+               m->m_lc_vm_rusage.addr, (vir_bytes) sizeof(r_usage));
 }