From owner-p4-projects@FreeBSD.ORG Wed Jun 28 21:06:24 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 34ACD16A71E; Wed, 28 Jun 2006 21:06:23 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E3DB16A6B8 for ; Wed, 28 Jun 2006 21:06:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A34D44304 for ; Wed, 28 Jun 2006 20:05:10 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5SK5AL2048579 for ; Wed, 28 Jun 2006 20:05:10 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5SK59rK048576 for perforce@freebsd.org; Wed, 28 Jun 2006 20:05:09 GMT (envelope-from jhb@freebsd.org) Date: Wed, 28 Jun 2006 20:05:09 GMT Message-Id: <200606282005.k5SK59rK048576@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 100228 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2006 21:06:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=100228 Change 100228 by jhb@jhb_mutex on 2006/06/28 20:04:17 Split up ibcs2_msgsys() into subfunctions similar to svr4_sys_msgsys() and use kern_msgctl() in ibcs2_msgctl() to avoid the stackgap. Affected files ... .. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.c#9 edit Differences ... ==== //depot/projects/smpng/sys/i386/ibcs2/ibcs2_ipc.c#9 (text+ko) ==== @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -102,50 +103,118 @@ return; } +struct ibcs2_msgget_args { + int what; + int key; + int msgflg; +}; + +static int +ibcs2_msgget(struct thread *td, void *v) +{ + struct ibcs2_msgget_args *uap = v; + struct msgget_args ap; + + ap.key = uap->key; + ap.msgflg = uap->msgflg; + return msgget(td, &ap); +} + +struct ibcs2_msgctl_args { + int what; + int msqid; + int cmd; + struct ibcs2_msqid_ds *buf; +}; + +static int +ibcs2_msgctl(struct thread *td, void *v) +{ + struct ibcs2_msgctl_args *uap = v; + struct ibcs2_msqid_ds is; + struct msqid_ds bs; + int error; + + switch (uap->cmd) { + case IBCS2_IPC_STAT: + error = kern_msgctl(td, uap->msqid, IPC_STAT, &bs); + if (!error) { + cvt_msqid2imsqid(&bs, &is); + error = copyout(&is, uap->buf, sizeof(is)); + } + return (error); + case IBCS2_IPC_SET: + error = copyin(uap->buf, &is, sizeof(is)); + if (error) + return (error); + cvt_imsqid2msqid(&is, &bs); + return (kern_msgctl(td, uap->msqid, IPC_SET, &bs)); + case IBCS2_IPC_RMID: + return (kern_msgctl(td, uap->msqid, IPC_RMID, NULL)); + } + return (EINVAL); +} + +struct ibcs2_msgrcv_args { + int what; + int msqid; + void *msgp; + size_t msgsz; + long msgtyp; + int msgflg; +}; + +static int +ibcs2_msgrcv(struct thread *td, void *v) +{ + struct ibcs2_msgrcv_args *uap = v; + struct msgrcv_args ap; + + ap.msqid = uap->msqid; + ap.msgp = uap->msgp; + ap.msgsz = uap->msgsz; + ap.msgtyp = uap->msgtyp; + ap.msgflg = uap->msgflg; + return (msgrcv(td, &ap)); +} + +struct ibcs2_msgsnd_args { + int what; + int msqid; + void *msgp; + size_t msgsz; + int msgflg; +}; + +static int +ibcs2_msgsnd(struct thread *td, void *v) +{ + struct ibcs2_msgsnd_args *uap = v; + struct msgsnd_args ap; + + ap.msqid = uap->msqid; + ap.msgp = uap->msgp; + ap.msgsz = uap->msgsz; + ap.msgflg = uap->msgflg; + return (msgsnd(td, &ap)); +} + int ibcs2_msgsys(td, uap) struct thread *td; struct ibcs2_msgsys_args *uap; { switch (uap->which) { - case 0: /* msgget */ - uap->which = 1; - return msgsys(td, (struct msgsys_args *)uap); - case 1: { /* msgctl */ - int error; - struct msgsys_args margs; - caddr_t sg = stackgap_init(); - - margs.which = 0; - margs.a2 = uap->a2; - margs.a4 = - (int)stackgap_alloc(&sg, sizeof(struct msqid_ds)); - margs.a3 = uap->a3; - switch (margs.a3) { - case IBCS2_IPC_STAT: - error = msgsys(td, &margs); - if (!error) - cvt_msqid2imsqid( - (struct msqid_ds *)margs.a4, - (struct ibcs2_msqid_ds *)uap->a4); - return error; - case IBCS2_IPC_SET: - cvt_imsqid2msqid((struct ibcs2_msqid_ds *)uap->a4, - (struct msqid_ds *)margs.a4); - return msgsys(td, &margs); - case IBCS2_IPC_RMID: - return msgsys(td, &margs); - } - return EINVAL; - } - case 2: /* msgrcv */ - uap->which = 3; - return msgsys(td, (struct msgsys_args *)uap); - case 3: /* msgsnd */ - uap->which = 2; - return msgsys(td, (struct msgsys_args *)uap); + case 0: + return (ibcs2_msgget(td, uap)); + case 1: + return (ibcs2_msgctl(td, uap)); + case 2: + return (ibcs2_msgrcv(td, uap)); + case 3: + return (ibcs2_msgsnd(td, uap)); default: - return EINVAL; + return (EINVAL); } }