From: Lionel Sambuc Date: Tue, 13 May 2014 09:31:36 +0000 (+0200) Subject: Message type for PM_SYSUNAME X-Git-Tag: v3.3.0~291 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/host.html?a=commitdiff_plain;h=a297e52a323b39a625981e76780be1fdf35f5cab;p=minix.git Message type for PM_SYSUNAME Change-Id: I58bd2987393ea56e1886fbce70b4b2c26af4ef2b --- diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 5f15e58ff..9c3c66676 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -64,12 +64,6 @@ /* Field names for the exit(2) call. */ #define PM_EXIT_STATUS m1_i1 /* int */ -/* Field names for the sysuname(2) call. */ -#define PM_SYSUNAME_REQ m1_i1 /* int */ -#define PM_SYSUNAME_FIELD m1_i2 /* int */ -#define PM_SYSUNAME_LEN m1_i3 /* char * */ -#define PM_SYSUNAME_VALUE m1_p1 /* size_t */ - /* Field names for the execve(2) call. */ #define PM_EXEC_NAME m1_p1 /* const char * */ #define PM_EXEC_NAMELEN m1_i1 /* size_t */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index f3f1075af..b307e531d 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -171,6 +171,16 @@ typedef struct { } mess_pm_lc_ptrace; _ASSERT_MSG_SIZE(mess_pm_lc_ptrace); +typedef struct { + int req; + int field; + size_t len; + vir_bytes value; + + uint8_t padding[40]; +} mess_lc_pm_sysuname; +_ASSERT_MSG_SIZE(mess_lc_pm_sysuname); + typedef struct { time_t sec; @@ -950,6 +960,7 @@ typedef struct { mess_lc_pm_itimer m_lc_pm_itimer; mess_lc_pm_ptrace m_lc_pm_ptrace; + mess_lc_pm_sysuname m_lc_pm_sysuname; mess_lc_pm_time m_lc_pm_time; mess_lc_pm_waitpid m_lc_pm_waitpid; diff --git a/lib/libc/sys-minix/sysuname.c b/lib/libc/sys-minix/sysuname.c index 6aa78c1b8..f8f08d09f 100644 --- a/lib/libc/sys-minix/sysuname.c +++ b/lib/libc/sys-minix/sysuname.c @@ -13,10 +13,10 @@ int sysuname(int req, int field, char *value, size_t len) message m; memset(&m, 0, sizeof(m)); - m.PM_SYSUNAME_REQ = req; - m.PM_SYSUNAME_FIELD = field; - m.PM_SYSUNAME_LEN = len; - m.PM_SYSUNAME_VALUE = value; + m.m_lc_pm_sysuname.req = req; + m.m_lc_pm_sysuname.field = field; + m.m_lc_pm_sysuname.len = len; + m.m_lc_pm_sysuname.value = (vir_bytes)value; return _syscall(PM_PROC_NR, PM_SYSUNAME, &m); } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index c4c3781ab..4d9e05aa3 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -81,32 +81,31 @@ int do_sysuname() }; #endif - if ((unsigned) m_in.PM_SYSUNAME_FIELD >= _UTS_MAX) return(EINVAL); + if (m_in.m_lc_pm_sysuname.field >= _UTS_MAX) return(EINVAL); - string = uts_tbl[m_in.PM_SYSUNAME_FIELD]; + string = uts_tbl[m_in.m_lc_pm_sysuname.field]; if (string == NULL) return EINVAL; /* Unsupported field */ - switch (m_in.PM_SYSUNAME_REQ) { + switch (m_in.m_lc_pm_sysuname.req) { case _UTS_GET: /* Copy an uname string to the user. */ n = strlen(string) + 1; - if (n > m_in.PM_SYSUNAME_LEN) n = m_in.PM_SYSUNAME_LEN; - r = sys_datacopy(SELF, (phys_bytes) string, - mp->mp_endpoint, (phys_bytes) m_in.PM_SYSUNAME_VALUE, - (phys_bytes) n); + if (n > m_in.m_lc_pm_sysuname.len) n = m_in.m_lc_pm_sysuname.len; + r = sys_datacopy(SELF, (vir_bytes)string, mp->mp_endpoint, + m_in.m_lc_pm_sysuname.value, (phys_bytes)n); if (r < 0) return(r); break; #if 0 /* no updates yet */ case _UTS_SET: /* Set an uname string, needs root power. */ - len = sizes[m_in.PM_SYSUNAME_FIELD]; + len = sizes[m_in.m_lc_pm_sysuname.field]; if (mp->mp_effuid != 0 || len == 0) return(EPERM); - n = len < m_in.PM_SYSUNAME_LEN ? len : m_in.PM_SYSUNAME_LEN; + n = len < m_in.m_lc_pm_sysuname.len ? len : m_in.m_lc_pm_sysuname.len; if (n <= 0) return(EINVAL); - r = sys_datacopy(mp->mp_endpoint, (phys_bytes) m_in.PM_SYSUNAME_VALUE, - SELF, (phys_bytes) tmp, (phys_bytes) n); + r = sys_datacopy(mp->mp_endpoint, m_in.m_lc_pm_sysuname.value, SELF, + (phys_bytes)tmp, (phys_bytes)n); if (r < 0) return(r); tmp[n-1] = 0; strcpy(string, tmp);