From: Ben Gras Date: Sat, 26 Jul 2014 11:53:53 +0000 (+0200) Subject: custom message type for SHMCTL, SEMCTL, SEMGET X-Git-Tag: v3.3.0~119 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-dsfromkey.html?a=commitdiff_plain;h=c476408dea518873228a75ca172851cc95ff60aa;p=minix.git custom message type for SHMCTL, SEMCTL, SEMGET --- diff --git a/include/minix/com.h b/include/minix/com.h index 67bc7a1f1..d571f2a3c 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -830,22 +830,10 @@ #define IPC_SHMAT (IPC_BASE+2) #define IPC_SHMDT (IPC_BASE+3) #define IPC_SHMCTL (IPC_BASE+4) -# define SHMCTL_ID m2_i1 -# define SHMCTL_CMD m2_i2 -# define SHMCTL_BUF m2_l1 -# define SHMCTL_RET m2_i3 /* Semaphore */ #define IPC_SEMGET (IPC_BASE+5) -# define SEMGET_KEY m2_l1 -# define SEMGET_NR m2_i1 -# define SEMGET_FLAG m2_i2 -# define SEMGET_RETID m2_i3 #define IPC_SEMCTL (IPC_BASE+6) -# define SEMCTL_ID m2_i1 -# define SEMCTL_NUM m2_i2 -# define SEMCTL_CMD m2_i3 -# define SEMCTL_OPT m2_l1 #define IPC_SEMOP (IPC_BASE+7) # define SEMOP_ID m2_i1 # define SEMOP_OPS m2_l1 diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 374da5358..328eab4ca 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -1789,6 +1789,34 @@ typedef struct { } mess_lc_ipc_shmdt; _ASSERT_MSG_SIZE(mess_lc_ipc_shmdt); +typedef struct { + int id; + int cmd; + void *buf; + int ret; + uint8_t padding[40]; +} mess_lc_ipc_shmctl; +_ASSERT_MSG_SIZE(mess_lc_ipc_shmctl); + +typedef struct { + key_t key; + int nr; + int flag; + int retid; + uint8_t padding[40]; +} mess_lc_ipc_semget; +_ASSERT_MSG_SIZE(mess_lc_ipc_semget); + +typedef struct { + int id; + int num; + int cmd; + int opt; + int ret; + uint8_t padding[36]; +} mess_lc_ipc_semctl; +_ASSERT_MSG_SIZE(mess_lc_ipc_semctl); + typedef struct { endpoint_t m_source; /* who sent the message */ int m_type; /* what kind of message is it */ @@ -2018,6 +2046,9 @@ typedef struct { mess_lc_ipc_shmget m_lc_ipc_shmget; mess_lc_ipc_shmat m_lc_ipc_shmat; mess_lc_ipc_shmdt m_lc_ipc_shmdt; + mess_lc_ipc_shmctl m_lc_ipc_shmctl; + mess_lc_ipc_semget m_lc_ipc_semget; + mess_lc_ipc_semctl m_lc_ipc_semctl; mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel; mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose; diff --git a/lib/libc/sys-minix/sem.c b/lib/libc/sys-minix/sem.c index de8ba6c7f..37d3b3e66 100644 --- a/lib/libc/sys-minix/sem.c +++ b/lib/libc/sys-minix/sem.c @@ -35,15 +35,15 @@ int semget(key_t key, int nsems, int semflag) } memset(&m, 0, sizeof(m)); - m.SEMGET_KEY = key; - m.SEMGET_NR = nsems; - m.SEMGET_FLAG = semflag; + m.m_lc_ipc_semget.key = key; + m.m_lc_ipc_semget.nr = nsems; + m.m_lc_ipc_semget.flag = semflag; r = _syscall(ipc_pt, IPC_SEMGET, &m); if (r != OK) return r; - return m.SEMGET_RETID; + return m.m_lc_ipc_semget.retid; } /* Semaphore control operation. */ @@ -60,21 +60,21 @@ int semctl(int semid, int semnum, int cmd, ...) } memset(&m, 0, sizeof(m)); - m.SEMCTL_ID = semid; - m.SEMCTL_NUM = semnum; - m.SEMCTL_CMD = cmd; + m.m_lc_ipc_semctl.id = semid; + m.m_lc_ipc_semctl.num = semnum; + m.m_lc_ipc_semctl.cmd = cmd; va_start(ap, cmd); if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO || cmd == SEM_INFO || cmd == SEM_STAT || cmd == GETALL || cmd == SETALL || cmd == SETVAL) - m.SEMCTL_OPT = (long) va_arg(ap, long); + m.m_lc_ipc_semctl.opt = (long) va_arg(ap, long); va_end(ap); r = _syscall(ipc_pt, IPC_SEMCTL, &m); if ((r != -1) && (cmd == GETNCNT || cmd == GETZCNT || cmd == GETPID || cmd == GETVAL || cmd == IPC_INFO || cmd == SEM_INFO || cmd == SEM_STAT)) - return m.SHMCTL_RET; + return m.m_lc_ipc_semctl.ret; return r; } diff --git a/lib/libc/sys-minix/shmctl.c b/lib/libc/sys-minix/shmctl.c index e3d10e760..9612e65a5 100644 --- a/lib/libc/sys-minix/shmctl.c +++ b/lib/libc/sys-minix/shmctl.c @@ -32,14 +32,14 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf) } memset(&m, 0, sizeof(m)); - m.SHMCTL_ID = shmid; - m.SHMCTL_CMD = cmd; - m.SHMCTL_BUF = (long) buf; + m.m_lc_ipc_shmctl.id = shmid; + m.m_lc_ipc_shmctl.cmd = cmd; + m.m_lc_ipc_shmctl.buf = buf; r = _syscall(ipc_pt, IPC_SHMCTL, &m); if ((cmd == IPC_INFO || cmd == SHM_INFO || cmd == SHM_STAT) && (r == OK)) - return m.SHMCTL_RET; + return m.m_lc_ipc_shmctl.ret; return r; } diff --git a/servers/ipc/sem.c b/servers/ipc/sem.c index 558d35888..1b37894ed 100644 --- a/servers/ipc/sem.c +++ b/servers/ipc/sem.c @@ -57,9 +57,9 @@ int do_semget(message *m) int nsems, flag, id; struct sem_struct *sem; - key = m->SEMGET_KEY; - nsems = m->SEMGET_NR; - flag = m->SEMGET_FLAG; + key = m->m_lc_ipc_semget.key; + nsems = m->m_lc_ipc_semget.nr; + flag = m->m_lc_ipc_semget.flag; if ((sem = sem_find_key(key))) { if ((flag & IPC_CREAT) && (flag & IPC_EXCL)) @@ -94,7 +94,7 @@ int do_semget(message *m) sem_list_nr++; } - m->SEMGET_RETID = id; + m->m_lc_ipc_semget.retid = id; return OK; } @@ -287,14 +287,14 @@ int do_semctl(message *m) struct semid_ds *ds, tmp_ds; struct sem_struct *sem; - id = m->SEMCTL_ID; - num = m->SEMCTL_NUM; - cmd = m->SEMCTL_CMD; + id = m->m_lc_ipc_semctl.id; + num = m->m_lc_ipc_semctl.num; + cmd = m->m_lc_ipc_semctl.cmd; if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO || cmd == SEM_INFO || cmd == SEM_STAT || cmd == GETALL || cmd == SETALL || cmd == SETVAL) - opt = m->SEMCTL_OPT; + opt = m->m_lc_ipc_semctl.opt; if (!(sem = sem_find_id(id))) { return EINVAL; @@ -367,22 +367,22 @@ int do_semctl(message *m) case GETNCNT: if (num < 0 || num >= sem->semid_ds.sem_nsems) return EINVAL; - m->SHMCTL_RET = sem->sems[num].semncnt; + m->m_lc_ipc_semctl.ret = sem->sems[num].semncnt; break; case GETPID: if (num < 0 || num >= sem->semid_ds.sem_nsems) return EINVAL; - m->SHMCTL_RET = sem->sems[num].sempid; + m->m_lc_ipc_semctl.ret = sem->sems[num].sempid; break; case GETVAL: if (num < 0 || num >= sem->semid_ds.sem_nsems) return EINVAL; - m->SHMCTL_RET = sem->sems[num].semval; + m->m_lc_ipc_semctl.ret = sem->sems[num].semval; break; case GETZCNT: if (num < 0 || num >= sem->semid_ds.sem_nsems) return EINVAL; - m->SHMCTL_RET = sem->sems[num].semzcnt; + m->m_lc_ipc_semctl.ret = sem->sems[num].semzcnt; break; case SETALL: buf = malloc(sizeof(unsigned short) * sem->semid_ds.sem_nsems); diff --git a/servers/ipc/shm.c b/servers/ipc/shm.c index da90a9cbd..3ce9568db 100644 --- a/servers/ipc/shm.c +++ b/servers/ipc/shm.c @@ -217,9 +217,9 @@ int do_shmdt(message *m) *===========================================================================*/ int do_shmctl(message *m) { - int id = m->SHMCTL_ID; - int cmd = m->SHMCTL_CMD; - struct shmid_ds *ds = (struct shmid_ds *)m->SHMCTL_BUF; + int id = m->m_lc_ipc_shmctl.id; + int cmd = m->m_lc_ipc_shmctl.cmd; + struct shmid_ds *ds = (struct shmid_ds *)m->m_lc_ipc_shmctl.buf; struct shmid_ds tmp_ds; struct shm_struct *shm = NULL; struct shminfo sinfo; @@ -286,9 +286,9 @@ int do_shmctl(message *m) who_e, (vir_bytes)ds, sizeof(struct shminfo)); if (r != OK) return EFAULT; - m->SHMCTL_RET = shm_list_nr - 1; - if (m->SHMCTL_RET < 0) - m->SHMCTL_RET = 0; + m->m_lc_ipc_shmctl.ret = (shm_list_nr - 1); + if (m->m_lc_ipc_shmctl.ret < 0) + m->m_lc_ipc_shmctl.ret = 0; break; case SHM_INFO: if (!ds) @@ -306,9 +306,9 @@ int do_shmctl(message *m) who_e, (vir_bytes)ds, sizeof(struct shm_info)); if (r != OK) return EFAULT; - m->SHMCTL_RET = shm_list_nr - 1; - if (m->SHMCTL_RET < 0) - m->SHMCTL_RET = 0; + m->m_lc_ipc_shmctl.ret = shm_list_nr - 1; + if (m->m_lc_ipc_shmctl.ret < 0) + m->m_lc_ipc_shmctl.ret = 0; break; case SHM_STAT: if (id < 0 || id >= shm_list_nr) @@ -318,7 +318,7 @@ int do_shmctl(message *m) who_e, (vir_bytes)ds, sizeof(struct shmid_ds)); if (r != OK) return EFAULT; - m->SHMCTL_RET = shm->id; + m->m_lc_ipc_shmctl.ret = shm->id; break; default: return EINVAL;