From owner-p4-projects@FreeBSD.ORG Fri Nov 17 20:56:06 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 4974F16A501; Fri, 17 Nov 2006 20:56:06 +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 204EC16A47E for ; Fri, 17 Nov 2006 20:56:06 +0000 (UTC) (envelope-from jkim@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1D6043D58 for ; Fri, 17 Nov 2006 20:56:05 +0000 (GMT) (envelope-from jkim@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 kAHKu5RQ061223 for ; Fri, 17 Nov 2006 20:56:05 GMT (envelope-from jkim@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kAHKu5NZ061220 for perforce@freebsd.org; Fri, 17 Nov 2006 20:56:05 GMT (envelope-from jkim@freebsd.org) Date: Fri, 17 Nov 2006 20:56:05 GMT Message-Id: <200611172056.kAHKu5NZ061220@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jkim@freebsd.org using -f From: Jung-uk Kim To: Perforce Change Reviews Cc: Subject: PERFORCE change 110179 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: Fri, 17 Nov 2006 20:56:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=110179 Change 110179 by jkim@jkim_hammer on 2006/11/17 20:55:26 Add rudimentary IPC_INFO/MSG_INFO command support for linux_msgctl() to pacify Linux ipcs(1). Note: This patch and another fix from CVS fix msgctl08 and msgctl09. Affected files ... .. //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#5 edit Differences ... ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_ipc.c#5 (text+ko) ==== @@ -83,6 +83,17 @@ l_ulong swap_successes; }; +struct l_msginfo { + l_int msgpool; + l_int msgmap; + l_int msgmax; + l_int msgmnb; + l_int msgmni; + l_int msgssz; + l_int msgtql; + l_ushort msgseg; +}; + static void bsd_to_linux_shminfo( struct shminfo *bpp, struct l_shminfo *lpp) { @@ -580,7 +591,7 @@ l_long lmtype; int error; - if ((l_long)args->msgsz < 0) + if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax) return (EINVAL); msgp = PTRIN(args->msgp); if ((error = copyin(msgp, &lmtype, sizeof(lmtype))) != 0) @@ -599,7 +610,7 @@ l_long lmtype; int error; - if ((l_long)args->msgsz < 0) + if ((l_long)args->msgsz < 0 || args->msgsz > (l_long)msginfo.msgmax) return (EINVAL); msgp = PTRIN(args->msgp); if ((error = kern_msgrcv(td, args->msqid, @@ -631,12 +642,39 @@ struct msqid_ds bsd_msqid; bsd_cmd = args->cmd & ~LINUX_IPC_64; - if (bsd_cmd == LINUX_IPC_SET) { + switch (bsd_cmd) { + case LINUX_IPC_INFO: + case LINUX_MSG_INFO: { + struct l_msginfo linux_msginfo; + + /* + * XXX MSG_INFO uses the same data structure but returns different + * dynamic counters in msgpool, msgmap, and msgtql fields. + */ + linux_msginfo.msgpool = (long)msginfo.msgmni * + (long)msginfo.msgmnb / 1024L; /* XXX MSG_INFO. */ + linux_msginfo.msgmap = msginfo.msgmnb; /* XXX MSG_INFO. */ + linux_msginfo.msgmax = msginfo.msgmax; + linux_msginfo.msgmnb = msginfo.msgmnb; + linux_msginfo.msgmni = msginfo.msgmni; + linux_msginfo.msgssz = msginfo.msgssz; + linux_msginfo.msgtql = msginfo.msgtql; /* XXX MSG_INFO. */ + linux_msginfo.msgseg = msginfo.msgseg; + error = copyout(&linux_msginfo, PTRIN(args->buf), + sizeof(linux_msginfo)); + if (error == 0) + td->td_retval[0] = msginfo.msgmni; /* XXX */ + + return (error); + } + + case LINUX_IPC_SET: error = linux_msqid_pullup(args->cmd & LINUX_IPC_64, &linux_msqid, PTRIN(args->buf)); if (error) return (error); linux_to_bsd_msqid_ds(&linux_msqid, &bsd_msqid); + break; } error = kern_msgctl(td, args->msqid, bsd_cmd, &bsd_msqid);