Example #1
0
int
ibcs2_sys_msgsys(struct lwp *l, const struct ibcs2_sys_msgsys_args *uap, register_t *retval)
{
#ifdef SYSVMSG
	/* {
		syscallarg(int) which;
		syscallarg(int) a2;
		syscallarg(int) a3;
		syscallarg(int) a4;
		syscallarg(int) a5;
		syscallarg(int) a6;
	} */
	int error;
	struct msqid_ds msqbuf;
	struct ibcs2_msqid_ds msqbuf_ibcs2, *ibp;

	switch (SCARG(uap, which)) {
	case 0:				/* msgget */
		return do_compat_10_sys_msgsys(l, uap, retval, 1);
	case 1: 			/* msgctl */
		ibp = (void *)SCARG(uap, a4);
		switch (SCARG(uap, a3)) {
		case IPC_STAT:
			error = msgctl1(l, SCARG(uap, a2), IPC_STAT, &msqbuf);
			if (error == 0) {
				cvt_msqid2imsqid(&msqbuf, &msqbuf_ibcs2);
				error = copyout(&msqbuf_ibcs2, ibp,
				    sizeof msqbuf_ibcs2);
			}
			return error;
		case IPC_SET:
			error = copyin(ibp, &msqbuf_ibcs2, sizeof msqbuf_ibcs2);
			if (error == 0) {
				cvt_imsqid2msqid(&msqbuf_ibcs2, &msqbuf);
				error = msgctl1(l, SCARG(uap, a2),
				    IPC_SET, &msqbuf);
			}
			return error;
		case IPC_RMID:
			return msgctl1(l, SCARG(uap, a2), IPC_RMID, NULL);
		}
		return EINVAL;
	case 2:				/* msgrcv */
		return do_compat_10_sys_msgsys(l, uap, retval, 3);
	case 3:				/* msgsnd */
		return do_compat_10_sys_msgsys(l, uap, retval, 2);
	default:
		break;
	}
#endif
	return EINVAL;
}
Example #2
0
int
netbsd32___msgctl13(struct lwp *l, const struct netbsd32___msgctl13_args *uap, register_t *retval)
{
	/* {
		syscallarg(int) msqid;
		syscallarg(int) cmd;
		syscallarg(netbsd32_msqid_dsp_t) buf;
	} */
	struct msqid_ds ds;
	struct netbsd32_msqid_ds ds32;
	int error, cmd;

	cmd = SCARG(uap, cmd);
	if (cmd == IPC_SET) {
		error = copyin(SCARG_P32(uap, buf), &ds32, sizeof(ds32));
		if (error)
			return error;
		netbsd32_to_msqid_ds(&ds32, &ds);
	}

	error = msgctl1(l, SCARG(uap, msqid), cmd,
	    (cmd == IPC_SET || cmd == IPC_STAT) ? &ds : NULL);

	if (error == 0 && cmd == IPC_STAT) {
		netbsd32_from_msqid_ds(&ds, &ds32);
		error = copyout(&ds32, SCARG_P32(uap, buf), sizeof(ds32));
	}

	return error;
}
int
sys___msgctl50(struct lwp *l, const struct sys___msgctl50_args *uap,
    register_t *retval)
{
	/* {
		syscallarg(int) msqid;
		syscallarg(int) cmd;
		syscallarg(struct msqid_ds *) buf;
	} */
	struct msqid_ds msqbuf;
	int cmd, error;

	cmd = SCARG(uap, cmd);

	if (cmd == IPC_SET) {
		error = copyin(SCARG(uap, buf), &msqbuf, sizeof(msqbuf));
		if (error)
			return (error);
	}

	error = msgctl1(l, SCARG(uap, msqid), cmd,
	    (cmd == IPC_SET || cmd == IPC_STAT) ? &msqbuf : NULL);

	if (error == 0 && cmd == IPC_STAT)
		error = copyout(&msqbuf, SCARG(uap, buf), sizeof(msqbuf));

	return (error);
}
static int
linux32_msgctl(struct lwp *l, const struct linux32_sys_ipc_args *uap, register_t *retval)
{
	struct msqid_ds bm, *bmp = NULL;
	struct linux32_msqid_ds lm;
	struct linux32_msqid64_ds lm64;
	int cmd, lcmd, error;
	void *data = SCARG_P32(uap, ptr);

	lcmd = SCARG(uap, a2);

	switch (lcmd & ~LINUX32_IPC_64) {
	case LINUX32_IPC_STAT:
		cmd = IPC_STAT;
		bmp = &bm;
		break;
	case LINUX32_IPC_SET:
		if (lcmd & LINUX32_IPC_64) {
			error = copyin(data, &lm64, sizeof lm64);
			linux32_to_bsd_msqid64_ds(&lm64, &bm);
		} else {
			error = copyin(data, &lm, sizeof lm);
			linux32_to_bsd_msqid_ds(&lm, &bm);
		}
		if (error)
			return error;
		cmd = IPC_SET;
		bmp = &bm;
		break;
	case LINUX32_IPC_RMID:
		cmd = IPC_RMID;
		break;
	default:
		return EINVAL;
	}

	if ((error = msgctl1(l, SCARG(uap, a1), cmd, bmp)))
		return error;

	switch (lcmd) {
	case LINUX32_IPC_STAT:
		bsd_to_linux32_msqid_ds(&bm, &lm);
		error = copyout(&lm, data, sizeof lm);
		break;
	case LINUX32_IPC_STAT|LINUX32_IPC_64:
		bsd_to_linux32_msqid64_ds(&bm, &lm64);
		error = copyout(&lm64, data, sizeof lm64);
		break;
	default:
		break;
	}

	return error;
}
Example #5
0
int
sys_msgctl(struct proc *p, void *v, register_t *retval)
{
	struct sys_msgctl_args /* {
		syscallarg(int) msqid;
		syscallarg(int) cmd;
		syscallarg(struct msqid_ds *) buf;
	} */ *uap = v;

	return (msgctl1(p, SCARG(uap, msqid), SCARG(uap, cmd),
	    (caddr_t)SCARG(uap, buf), copyin, copyout));
}