Message type for PM_SYSUNAME
Change-Id: I58bd2987393ea56e1886fbce70b4b2c26af4ef2b
This commit is contained in:
parent
345b3b5114
commit
a297e52a32
4 changed files with 25 additions and 21 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue