4 * Implementation of SVID messages
6 * Author: Daniel Boulet
8 * Copyright 1993 Daniel Boulet and RTMX Inc.
10 * This system call was implemented by Daniel Boulet under contract from RTMX.
12 * Redistribution and use in source forms, with and without modification,
13 * are permitted provided that this entire comment appears intact.
15 * Redistribution in binary form may occur without any restrictions.
16 * Obviously, it would be nice if you gave credit where credit is due
17 * but requiring it would be too onerous.
19 * This software is provided ``AS IS'' without any warranties of any kind.
22 #include "opt_sysvipc.h"
24 #include <sys/param.h>
25 #include <sys/systm.h>
26 #include <sys/sysproto.h>
27 #include <sys/kernel.h>
30 #include <sys/sysent.h>
31 #include <sys/sysctl.h>
32 #include <sys/malloc.h>
35 static MALLOC_DEFINE(M_MSG, "msg", "SVID compatible message queues");
37 static void msginit __P((void *));
42 static void msg_freehdr __P((struct msg *msghdr));
44 /* XXX casting to (sy_call_t *) is bogus, as usual. */
45 static sy_call_t *msgcalls[] = {
46 (sy_call_t *)msgctl, (sy_call_t *)msgget,
47 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv
51 struct msg *msg_next; /* next msg in the chain */
52 long msg_type; /* type of this message */
53 /* >0 -> type of this message */
54 /* 0 -> free header */
55 u_short msg_ts; /* size of this message */
56 short msg_spot; /* location of start of msg in buffer */
61 #define MSGSSZ 8 /* Each segment must be 2^N long */
64 #define MSGSEG 2048 /* must be less than 32767 */
66 #define MSGMAX (MSGSSZ*MSGSEG)
68 #define MSGMNB 2048 /* max # of bytes in a queue */
78 * Based on the configuration parameters described in an SVR2 (yes, two)
79 * config(1m) man page.
81 * Each message is broken up and stored in segments that are msgssz bytes
82 * long. For efficiency reasons, this should be a power of two. Also,
83 * it doesn't make sense if it is less than 8 or greater than about 256.
84 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
85 * two between 8 and 1024 inclusive (and panic's if it isn't).
87 struct msginfo msginfo = {
88 MSGMAX, /* max chars in a message */
89 MSGMNI, /* # of message queue identifiers */
90 MSGMNB, /* max chars in a queue */
91 MSGTQL, /* max messages in system */
92 MSGSSZ, /* size of a message segment */
93 /* (must be small power of 2 greater than 4) */
94 MSGSEG /* number of message segments */
98 * macros to convert between msqid_ds's and msqid's.
99 * (specific to this implementation)
101 #define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000))
102 #define MSQID_IX(id) ((id) & 0xffff)
103 #define MSQID_SEQ(id) (((id) >> 16) & 0xffff)
106 * The rest of this file is specific to this particular implementation.
110 short next; /* next segment in buffer */
111 /* -1 -> available */
112 /* 0..(MSGSEG-1) -> index of next segment */
115 #define MSG_LOCKED 01000 /* Is this msqid_ds locked? */
117 static int nfree_msgmaps; /* # of free map entries */
118 static short free_msgmaps; /* head of linked list of free map entries */
119 static struct msg *free_msghdrs;/* list of free msg headers */
120 static char *msgpool; /* MSGMAX byte long msg buffer pool */
121 static struct msgmap *msgmaps; /* MSGSEG msgmap structures */
122 static struct msg *msghdrs; /* MSGTQL msg headers */
123 static struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
131 msgpool = malloc(msginfo.msgmax, M_MSG, M_WAITOK);
133 panic("msgpool is NULL");
134 msgmaps = malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK);
136 panic("msgmaps is NULL");
137 msghdrs = malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK);
139 panic("msghdrs is NULL");
140 msqids = malloc(sizeof(struct msqid_ds) * msginfo.msgmni, M_MSG, M_WAITOK);
142 panic("msqids is NULL");
145 * msginfo.msgssz should be a power of two for efficiency reasons.
146 * It is also pretty silly if msginfo.msgssz is less than 8
147 * or greater than about 256 so ...
151 while (i < 1024 && i != msginfo.msgssz)
153 if (i != msginfo.msgssz) {
154 printf("msginfo.msgssz=%d (0x%x)\n", msginfo.msgssz,
156 panic("msginfo.msgssz not a small power of 2");
159 if (msginfo.msgseg > 32767) {
160 printf("msginfo.msgseg=%d\n", msginfo.msgseg);
161 panic("msginfo.msgseg > 32767");
165 panic("msgmaps is NULL");
167 for (i = 0; i < msginfo.msgseg; i++) {
169 msgmaps[i-1].next = i;
170 msgmaps[i].next = -1; /* implies entry is available */
173 nfree_msgmaps = msginfo.msgseg;
176 panic("msghdrs is NULL");
178 for (i = 0; i < msginfo.msgtql; i++) {
179 msghdrs[i].msg_type = 0;
181 msghdrs[i-1].msg_next = &msghdrs[i];
182 msghdrs[i].msg_next = NULL;
184 free_msghdrs = &msghdrs[0];
187 panic("msqids is NULL");
189 for (i = 0; i < msginfo.msgmni; i++) {
190 msqids[i].msg_qbytes = 0; /* implies entry is available */
191 msqids[i].msg_perm.seq = 0; /* reset to a known value */
192 msqids[i].msg_perm.mode = 0;
195 SYSINIT(sysv_msg, SI_SUB_SYSV_MSG, SI_ORDER_FIRST, msginit, NULL)
198 * Entry point for all MSG calls
203 /* XXX actually varargs. */
204 struct msgsys_args /* {
214 if (!jail_sysvipc_allowed && p->p_prison != NULL)
217 if (uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
219 return ((*msgcalls[uap->which])(p, &uap->a2));
226 while (msghdr->msg_ts > 0) {
228 if (msghdr->msg_spot < 0 || msghdr->msg_spot >= msginfo.msgseg)
229 panic("msghdr->msg_spot out of range");
230 next = msgmaps[msghdr->msg_spot].next;
231 msgmaps[msghdr->msg_spot].next = free_msgmaps;
232 free_msgmaps = msghdr->msg_spot;
234 msghdr->msg_spot = next;
235 if (msghdr->msg_ts >= msginfo.msgssz)
236 msghdr->msg_ts -= msginfo.msgssz;
240 if (msghdr->msg_spot != -1)
241 panic("msghdr->msg_spot != -1");
242 msghdr->msg_next = free_msghdrs;
243 free_msghdrs = msghdr;
246 #ifndef _SYS_SYSPROTO_H_
250 struct msqid_ds *buf;
257 register struct msgctl_args *uap;
259 int msqid = uap->msqid;
261 struct msqid_ds *user_msqptr = uap->buf;
263 struct msqid_ds msqbuf;
264 register struct msqid_ds *msqptr;
267 printf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr);
270 if (!jail_sysvipc_allowed && p->p_prison != NULL)
273 msqid = IPCID_TO_IX(msqid);
275 if (msqid < 0 || msqid >= msginfo.msgmni) {
277 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
283 msqptr = &msqids[msqid];
285 if (msqptr->msg_qbytes == 0) {
287 printf("no such msqid\n");
291 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
293 printf("wrong sequence number\n");
306 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M)))
308 /* Free the message headers */
309 msghdr = msqptr->msg_first;
310 while (msghdr != NULL) {
311 struct msg *msghdr_tmp;
313 /* Free the segments of each message */
314 msqptr->msg_cbytes -= msghdr->msg_ts;
317 msghdr = msghdr->msg_next;
318 msg_freehdr(msghdr_tmp);
321 if (msqptr->msg_cbytes != 0)
322 panic("msg_cbytes is screwed up");
323 if (msqptr->msg_qnum != 0)
324 panic("msg_qnum is screwed up");
326 msqptr->msg_qbytes = 0; /* Mark it as free */
328 wakeup((caddr_t)msqptr);
334 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M)))
336 if ((eval = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0)
338 if (msqbuf.msg_qbytes > msqptr->msg_qbytes) {
343 if (msqbuf.msg_qbytes > msginfo.msgmnb) {
345 printf("can't increase msg_qbytes beyond %d (truncating)\n",
348 msqbuf.msg_qbytes = msginfo.msgmnb; /* silently restrict qbytes to system limit */
350 if (msqbuf.msg_qbytes == 0) {
352 printf("can't reduce msg_qbytes to 0\n");
354 return(EINVAL); /* non-standard errno! */
356 msqptr->msg_perm.uid = msqbuf.msg_perm.uid; /* change the owner */
357 msqptr->msg_perm.gid = msqbuf.msg_perm.gid; /* change the owner */
358 msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) |
359 (msqbuf.msg_perm.mode & 0777);
360 msqptr->msg_qbytes = msqbuf.msg_qbytes;
361 msqptr->msg_ctime = time_second;
365 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) {
367 printf("requester doesn't have read access\n");
371 eval = copyout((caddr_t)msqptr, user_msqptr,
372 sizeof(struct msqid_ds));
377 printf("invalid command %d\n", cmd);
383 p->p_retval[0] = rval;
387 #ifndef _SYS_SYSPROTO_H_
397 register struct msgget_args *uap;
401 int msgflg = uap->msgflg;
402 struct ucred *cred = p->p_ucred;
403 register struct msqid_ds *msqptr = NULL;
406 printf("msgget(0x%x, 0%o)\n", key, msgflg);
409 if (!jail_sysvipc_allowed && p->p_prison != NULL)
412 if (key != IPC_PRIVATE) {
413 for (msqid = 0; msqid < msginfo.msgmni; msqid++) {
414 msqptr = &msqids[msqid];
415 if (msqptr->msg_qbytes != 0 &&
416 msqptr->msg_perm.key == key)
419 if (msqid < msginfo.msgmni) {
421 printf("found public key\n");
423 if ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) {
425 printf("not exclusive\n");
429 if ((eval = ipcperm(p, &msqptr->msg_perm, msgflg & 0700 ))) {
431 printf("requester doesn't have 0%o access\n",
441 printf("need to allocate the msqid_ds\n");
443 if (key == IPC_PRIVATE || (msgflg & IPC_CREAT)) {
444 for (msqid = 0; msqid < msginfo.msgmni; msqid++) {
446 * Look for an unallocated and unlocked msqid_ds.
447 * msqid_ds's can be locked by msgsnd or msgrcv while
448 * they are copying the message in/out. We can't
449 * re-use the entry until they release it.
451 msqptr = &msqids[msqid];
452 if (msqptr->msg_qbytes == 0 &&
453 (msqptr->msg_perm.mode & MSG_LOCKED) == 0)
456 if (msqid == msginfo.msgmni) {
458 printf("no more msqid_ds's available\n");
463 printf("msqid %d is available\n", msqid);
465 msqptr->msg_perm.key = key;
466 msqptr->msg_perm.cuid = cred->cr_uid;
467 msqptr->msg_perm.uid = cred->cr_uid;
468 msqptr->msg_perm.cgid = cred->cr_gid;
469 msqptr->msg_perm.gid = cred->cr_gid;
470 msqptr->msg_perm.mode = (msgflg & 0777);
471 /* Make sure that the returned msqid is unique */
472 msqptr->msg_perm.seq++;
473 msqptr->msg_first = NULL;
474 msqptr->msg_last = NULL;
475 msqptr->msg_cbytes = 0;
476 msqptr->msg_qnum = 0;
477 msqptr->msg_qbytes = msginfo.msgmnb;
478 msqptr->msg_lspid = 0;
479 msqptr->msg_lrpid = 0;
480 msqptr->msg_stime = 0;
481 msqptr->msg_rtime = 0;
482 msqptr->msg_ctime = time_second;
485 printf("didn't find it and wasn't asked to create it\n");
491 /* Construct the unique msqid */
492 p->p_retval[0] = IXSEQ_TO_IPCID(msqid, msqptr->msg_perm);
496 #ifndef _SYS_SYSPROTO_H_
508 register struct msgsnd_args *uap;
510 int msqid = uap->msqid;
511 void *user_msgp = uap->msgp;
512 size_t msgsz = uap->msgsz;
513 int msgflg = uap->msgflg;
514 int segs_needed, eval;
515 register struct msqid_ds *msqptr;
516 register struct msg *msghdr;
520 printf("call to msgsnd(%d, 0x%x, %d, %d)\n", msqid, user_msgp, msgsz,
524 if (!jail_sysvipc_allowed && p->p_prison != NULL)
527 msqid = IPCID_TO_IX(msqid);
529 if (msqid < 0 || msqid >= msginfo.msgmni) {
531 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
537 msqptr = &msqids[msqid];
538 if (msqptr->msg_qbytes == 0) {
540 printf("no such message queue id\n");
544 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
546 printf("wrong sequence number\n");
551 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_W))) {
553 printf("requester doesn't have write access\n");
558 segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz;
560 printf("msgsz=%d, msgssz=%d, segs_needed=%d\n", msgsz, msginfo.msgssz,
564 int need_more_resources = 0;
568 * (inside this loop in case msg_qbytes changes while we sleep)
571 if (msgsz > msqptr->msg_qbytes) {
573 printf("msgsz > msqptr->msg_qbytes\n");
578 if (msqptr->msg_perm.mode & MSG_LOCKED) {
580 printf("msqid is locked\n");
582 need_more_resources = 1;
584 if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes) {
586 printf("msgsz + msg_cbytes > msg_qbytes\n");
588 need_more_resources = 1;
590 if (segs_needed > nfree_msgmaps) {
592 printf("segs_needed > nfree_msgmaps\n");
594 need_more_resources = 1;
596 if (free_msghdrs == NULL) {
598 printf("no more msghdrs\n");
600 need_more_resources = 1;
603 if (need_more_resources) {
606 if ((msgflg & IPC_NOWAIT) != 0) {
608 printf("need more resources but caller doesn't want to wait\n");
613 if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0) {
615 printf("we don't own the msqid_ds\n");
619 /* Force later arrivals to wait for our
622 printf("we own the msqid_ds\n");
624 msqptr->msg_perm.mode |= MSG_LOCKED;
628 printf("goodnight\n");
630 eval = tsleep((caddr_t)msqptr, (PZERO - 4) | PCATCH,
633 printf("good morning, eval=%d\n", eval);
636 msqptr->msg_perm.mode &= ~MSG_LOCKED;
639 printf("msgsnd: interrupted system call\n");
645 * Make sure that the msq queue still exists
648 if (msqptr->msg_qbytes == 0) {
650 printf("msqid deleted\n");
657 printf("got all the resources that we need\n");
664 * We have the resources that we need.
668 if (msqptr->msg_perm.mode & MSG_LOCKED)
669 panic("msg_perm.mode & MSG_LOCKED");
670 if (segs_needed > nfree_msgmaps)
671 panic("segs_needed > nfree_msgmaps");
672 if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes)
673 panic("msgsz + msg_cbytes > msg_qbytes");
674 if (free_msghdrs == NULL)
675 panic("no more msghdrs");
678 * Re-lock the msqid_ds in case we page-fault when copying in the
682 if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0)
683 panic("msqid_ds is already locked");
684 msqptr->msg_perm.mode |= MSG_LOCKED;
687 * Allocate a message header
690 msghdr = free_msghdrs;
691 free_msghdrs = msghdr->msg_next;
692 msghdr->msg_spot = -1;
693 msghdr->msg_ts = msgsz;
696 * Allocate space for the message
699 while (segs_needed > 0) {
700 if (nfree_msgmaps <= 0)
701 panic("not enough msgmaps");
702 if (free_msgmaps == -1)
703 panic("nil free_msgmaps");
706 panic("next too low #1");
707 if (next >= msginfo.msgseg)
708 panic("next out of range #1");
710 printf("allocating segment %d to message\n", next);
712 free_msgmaps = msgmaps[next].next;
714 msgmaps[next].next = msghdr->msg_spot;
715 msghdr->msg_spot = next;
720 * Copy in the message type
723 if ((eval = copyin(user_msgp, &msghdr->msg_type,
724 sizeof(msghdr->msg_type))) != 0) {
726 printf("error %d copying the message type\n", eval);
729 msqptr->msg_perm.mode &= ~MSG_LOCKED;
730 wakeup((caddr_t)msqptr);
733 user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type);
736 * Validate the message type
739 if (msghdr->msg_type < 1) {
741 msqptr->msg_perm.mode &= ~MSG_LOCKED;
742 wakeup((caddr_t)msqptr);
744 printf("mtype (%d) < 1\n", msghdr->msg_type);
750 * Copy in the message body
753 next = msghdr->msg_spot;
756 if (msgsz > msginfo.msgssz)
757 tlen = msginfo.msgssz;
761 panic("next too low #2");
762 if (next >= msginfo.msgseg)
763 panic("next out of range #2");
764 if ((eval = copyin(user_msgp, &msgpool[next * msginfo.msgssz],
767 printf("error %d copying in message segment\n", eval);
770 msqptr->msg_perm.mode &= ~MSG_LOCKED;
771 wakeup((caddr_t)msqptr);
775 user_msgp = (char *)user_msgp + tlen;
776 next = msgmaps[next].next;
779 panic("didn't use all the msg segments");
782 * We've got the message. Unlock the msqid_ds.
785 msqptr->msg_perm.mode &= ~MSG_LOCKED;
788 * Make sure that the msqid_ds is still allocated.
791 if (msqptr->msg_qbytes == 0) {
793 wakeup((caddr_t)msqptr);
798 * Put the message into the queue
801 if (msqptr->msg_first == NULL) {
802 msqptr->msg_first = msghdr;
803 msqptr->msg_last = msghdr;
805 msqptr->msg_last->msg_next = msghdr;
806 msqptr->msg_last = msghdr;
808 msqptr->msg_last->msg_next = NULL;
810 msqptr->msg_cbytes += msghdr->msg_ts;
812 msqptr->msg_lspid = p->p_pid;
813 msqptr->msg_stime = time_second;
815 wakeup((caddr_t)msqptr);
820 #ifndef _SYS_SYSPROTO_H_
833 register struct msgrcv_args *uap;
835 int msqid = uap->msqid;
836 void *user_msgp = uap->msgp;
837 size_t msgsz = uap->msgsz;
838 long msgtyp = uap->msgtyp;
839 int msgflg = uap->msgflg;
841 register struct msqid_ds *msqptr;
842 register struct msg *msghdr;
847 printf("call to msgrcv(%d, 0x%x, %d, %ld, %d)\n", msqid, user_msgp,
848 msgsz, msgtyp, msgflg);
851 if (!jail_sysvipc_allowed && p->p_prison != NULL)
854 msqid = IPCID_TO_IX(msqid);
856 if (msqid < 0 || msqid >= msginfo.msgmni) {
858 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
864 msqptr = &msqids[msqid];
865 if (msqptr->msg_qbytes == 0) {
867 printf("no such message queue id\n");
871 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
873 printf("wrong sequence number\n");
878 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) {
880 printf("requester doesn't have read access\n");
886 while (msghdr == NULL) {
888 msghdr = msqptr->msg_first;
889 if (msghdr != NULL) {
890 if (msgsz < msghdr->msg_ts &&
891 (msgflg & MSG_NOERROR) == 0) {
893 printf("first message on the queue is too big (want %d, got %d)\n",
894 msgsz, msghdr->msg_ts);
898 if (msqptr->msg_first == msqptr->msg_last) {
899 msqptr->msg_first = NULL;
900 msqptr->msg_last = NULL;
902 msqptr->msg_first = msghdr->msg_next;
903 if (msqptr->msg_first == NULL)
904 panic("msg_first/last screwed up #1");
908 struct msg *previous;
912 prev = &(msqptr->msg_first);
913 while ((msghdr = *prev) != NULL) {
915 * Is this message's type an exact match or is
916 * this message's type less than or equal to
917 * the absolute value of a negative msgtyp?
918 * Note that the second half of this test can
919 * NEVER be true if msgtyp is positive since
920 * msg_type is always positive!
923 if (msgtyp == msghdr->msg_type ||
924 msghdr->msg_type <= -msgtyp) {
926 printf("found message type %d, requested %d\n",
927 msghdr->msg_type, msgtyp);
929 if (msgsz < msghdr->msg_ts &&
930 (msgflg & MSG_NOERROR) == 0) {
932 printf("requested message on the queue is too big (want %d, got %d)\n",
933 msgsz, msghdr->msg_ts);
937 *prev = msghdr->msg_next;
938 if (msghdr == msqptr->msg_last) {
939 if (previous == NULL) {
942 panic("msg_first/last screwed up #2");
950 panic("msg_first/last screwed up #3");
958 prev = &(msghdr->msg_next);
963 * We've either extracted the msghdr for the appropriate
964 * message or there isn't one.
965 * If there is one then bail out of this loop.
972 * Hmph! No message found. Does the user want to wait?
975 if ((msgflg & IPC_NOWAIT) != 0) {
977 printf("no appropriate message found (msgtyp=%d)\n",
980 /* The SVID says to return ENOMSG. */
984 /* Unfortunately, BSD doesn't define that code yet! */
990 * Wait for something to happen
994 printf("msgrcv: goodnight\n");
996 eval = tsleep((caddr_t)msqptr, (PZERO - 4) | PCATCH, "msgwait",
999 printf("msgrcv: good morning (eval=%d)\n", eval);
1004 printf("msgsnd: interrupted system call\n");
1010 * Make sure that the msq queue still exists
1013 if (msqptr->msg_qbytes == 0 ||
1014 msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
1016 printf("msqid deleted\n");
1023 * Return the message to the user.
1025 * First, do the bookkeeping (before we risk being interrupted).
1028 msqptr->msg_cbytes -= msghdr->msg_ts;
1030 msqptr->msg_lrpid = p->p_pid;
1031 msqptr->msg_rtime = time_second;
1034 * Make msgsz the actual amount that we'll be returning.
1035 * Note that this effectively truncates the message if it is too long
1036 * (since msgsz is never increased).
1040 printf("found a message, msgsz=%d, msg_ts=%d\n", msgsz,
1043 if (msgsz > msghdr->msg_ts)
1044 msgsz = msghdr->msg_ts;
1047 * Return the type to the user.
1050 eval = copyout((caddr_t)&(msghdr->msg_type), user_msgp,
1051 sizeof(msghdr->msg_type));
1054 printf("error (%d) copying out message type\n", eval);
1056 msg_freehdr(msghdr);
1057 wakeup((caddr_t)msqptr);
1060 user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type);
1063 * Return the segments to the user
1066 next = msghdr->msg_spot;
1067 for (len = 0; len < msgsz; len += msginfo.msgssz) {
1070 if (msgsz - len > msginfo.msgssz)
1071 tlen = msginfo.msgssz;
1075 panic("next too low #3");
1076 if (next >= msginfo.msgseg)
1077 panic("next out of range #3");
1078 eval = copyout((caddr_t)&msgpool[next * msginfo.msgssz],
1082 printf("error (%d) copying out message segment\n",
1085 msg_freehdr(msghdr);
1086 wakeup((caddr_t)msqptr);
1089 user_msgp = (char *)user_msgp + tlen;
1090 next = msgmaps[next].next;
1094 * Done, return the actual number of bytes copied out.
1097 msg_freehdr(msghdr);
1098 wakeup((caddr_t)msqptr);
1099 p->p_retval[0] = msgsz;