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>
34 static MALLOC_DEFINE(M_MSG, "msg", "SVID compatible message queues");
36 static void msginit __P((void *));
41 static void msg_freehdr __P((struct msg *msghdr));
43 /* XXX casting to (sy_call_t *) is bogus, as usual. */
44 static sy_call_t *msgcalls[] = {
45 (sy_call_t *)msgctl, (sy_call_t *)msgget,
46 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv
50 struct msg *msg_next; /* next msg in the chain */
51 long msg_type; /* type of this message */
52 /* >0 -> type of this message */
53 /* 0 -> free header */
54 u_short msg_ts; /* size of this message */
55 short msg_spot; /* location of start of msg in buffer */
60 #define MSGSSZ 8 /* Each segment must be 2^N long */
63 #define MSGSEG 2048 /* must be less than 32767 */
65 #define MSGMAX (MSGSSZ*MSGSEG)
67 #define MSGMNB 2048 /* max # of bytes in a queue */
77 * Based on the configuration parameters described in an SVR2 (yes, two)
78 * config(1m) man page.
80 * Each message is broken up and stored in segments that are msgssz bytes
81 * long. For efficiency reasons, this should be a power of two. Also,
82 * it doesn't make sense if it is less than 8 or greater than about 256.
83 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
84 * two between 8 and 1024 inclusive (and panic's if it isn't).
86 struct msginfo msginfo = {
87 MSGMAX, /* max chars in a message */
88 MSGMNI, /* # of message queue identifiers */
89 MSGMNB, /* max chars in a queue */
90 MSGTQL, /* max messages in system */
91 MSGSSZ, /* size of a message segment */
92 /* (must be small power of 2 greater than 4) */
93 MSGSEG /* number of message segments */
97 * macros to convert between msqid_ds's and msqid's.
98 * (specific to this implementation)
100 #define MSQID(ix,ds) ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000))
101 #define MSQID_IX(id) ((id) & 0xffff)
102 #define MSQID_SEQ(id) (((id) >> 16) & 0xffff)
105 * The rest of this file is specific to this particular implementation.
109 short next; /* next segment in buffer */
110 /* -1 -> available */
111 /* 0..(MSGSEG-1) -> index of next segment */
114 #define MSG_LOCKED 01000 /* Is this msqid_ds locked? */
116 static int nfree_msgmaps; /* # of free map entries */
117 static short free_msgmaps; /* head of linked list of free map entries */
118 static struct msg *free_msghdrs;/* list of free msg headers */
119 static char *msgpool; /* MSGMAX byte long msg buffer pool */
120 static struct msgmap *msgmaps; /* MSGSEG msgmap structures */
121 static struct msg *msghdrs; /* MSGTQL msg headers */
122 static struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
130 msgpool = malloc(msginfo.msgmax, M_MSG, M_WAITOK);
132 panic("msgpool is NULL");
133 msgmaps = malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK);
135 panic("msgmaps is NULL");
136 msghdrs = malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK);
138 panic("msghdrs is NULL");
139 msqids = malloc(sizeof(struct msqid_ds) * msginfo.msgmni, M_MSG, M_WAITOK);
141 panic("msqids is NULL");
144 * msginfo.msgssz should be a power of two for efficiency reasons.
145 * It is also pretty silly if msginfo.msgssz is less than 8
146 * or greater than about 256 so ...
150 while (i < 1024 && i != msginfo.msgssz)
152 if (i != msginfo.msgssz) {
153 printf("msginfo.msgssz=%d (0x%x)\n", msginfo.msgssz,
155 panic("msginfo.msgssz not a small power of 2");
158 if (msginfo.msgseg > 32767) {
159 printf("msginfo.msgseg=%d\n", msginfo.msgseg);
160 panic("msginfo.msgseg > 32767");
164 panic("msgmaps is NULL");
166 for (i = 0; i < msginfo.msgseg; i++) {
168 msgmaps[i-1].next = i;
169 msgmaps[i].next = -1; /* implies entry is available */
172 nfree_msgmaps = msginfo.msgseg;
175 panic("msghdrs is NULL");
177 for (i = 0; i < msginfo.msgtql; i++) {
178 msghdrs[i].msg_type = 0;
180 msghdrs[i-1].msg_next = &msghdrs[i];
181 msghdrs[i].msg_next = NULL;
183 free_msghdrs = &msghdrs[0];
186 panic("msqids is NULL");
188 for (i = 0; i < msginfo.msgmni; i++) {
189 msqids[i].msg_qbytes = 0; /* implies entry is available */
190 msqids[i].msg_perm.seq = 0; /* reset to a known value */
191 msqids[i].msg_perm.mode = 0;
194 SYSINIT(sysv_msg, SI_SUB_SYSV_MSG, SI_ORDER_FIRST, msginit, NULL)
197 * Entry point for all MSG calls
202 /* XXX actually varargs. */
203 struct msgsys_args /* {
213 if (uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
215 return ((*msgcalls[uap->which])(p, &uap->a2));
222 while (msghdr->msg_ts > 0) {
224 if (msghdr->msg_spot < 0 || msghdr->msg_spot >= msginfo.msgseg)
225 panic("msghdr->msg_spot out of range");
226 next = msgmaps[msghdr->msg_spot].next;
227 msgmaps[msghdr->msg_spot].next = free_msgmaps;
228 free_msgmaps = msghdr->msg_spot;
230 msghdr->msg_spot = next;
231 if (msghdr->msg_ts >= msginfo.msgssz)
232 msghdr->msg_ts -= msginfo.msgssz;
236 if (msghdr->msg_spot != -1)
237 panic("msghdr->msg_spot != -1");
238 msghdr->msg_next = free_msghdrs;
239 free_msghdrs = msghdr;
242 #ifndef _SYS_SYSPROTO_H_
246 struct msqid_ds *buf;
253 register struct msgctl_args *uap;
255 int msqid = uap->msqid;
257 struct msqid_ds *user_msqptr = uap->buf;
259 struct msqid_ds msqbuf;
260 register struct msqid_ds *msqptr;
263 printf("call to msgctl(%d, %d, 0x%x)\n", msqid, cmd, user_msqptr);
266 msqid = IPCID_TO_IX(msqid);
268 if (msqid < 0 || msqid >= msginfo.msgmni) {
270 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
276 msqptr = &msqids[msqid];
278 if (msqptr->msg_qbytes == 0) {
280 printf("no such msqid\n");
284 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
286 printf("wrong sequence number\n");
299 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M)))
301 /* Free the message headers */
302 msghdr = msqptr->msg_first;
303 while (msghdr != NULL) {
304 struct msg *msghdr_tmp;
306 /* Free the segments of each message */
307 msqptr->msg_cbytes -= msghdr->msg_ts;
310 msghdr = msghdr->msg_next;
311 msg_freehdr(msghdr_tmp);
314 if (msqptr->msg_cbytes != 0)
315 panic("msg_cbytes is screwed up");
316 if (msqptr->msg_qnum != 0)
317 panic("msg_qnum is screwed up");
319 msqptr->msg_qbytes = 0; /* Mark it as free */
321 wakeup((caddr_t)msqptr);
327 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_M)))
329 if ((eval = copyin(user_msqptr, &msqbuf, sizeof(msqbuf))) != 0)
331 if (msqbuf.msg_qbytes > msqptr->msg_qbytes) {
336 if (msqbuf.msg_qbytes > msginfo.msgmnb) {
338 printf("can't increase msg_qbytes beyond %d (truncating)\n",
341 msqbuf.msg_qbytes = msginfo.msgmnb; /* silently restrict qbytes to system limit */
343 if (msqbuf.msg_qbytes == 0) {
345 printf("can't reduce msg_qbytes to 0\n");
347 return(EINVAL); /* non-standard errno! */
349 msqptr->msg_perm.uid = msqbuf.msg_perm.uid; /* change the owner */
350 msqptr->msg_perm.gid = msqbuf.msg_perm.gid; /* change the owner */
351 msqptr->msg_perm.mode = (msqptr->msg_perm.mode & ~0777) |
352 (msqbuf.msg_perm.mode & 0777);
353 msqptr->msg_qbytes = msqbuf.msg_qbytes;
354 msqptr->msg_ctime = time_second;
358 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) {
360 printf("requester doesn't have read access\n");
364 eval = copyout((caddr_t)msqptr, user_msqptr,
365 sizeof(struct msqid_ds));
370 printf("invalid command %d\n", cmd);
376 p->p_retval[0] = rval;
380 #ifndef _SYS_SYSPROTO_H_
390 register struct msgget_args *uap;
394 int msgflg = uap->msgflg;
395 struct ucred *cred = p->p_ucred;
396 register struct msqid_ds *msqptr = NULL;
399 printf("msgget(0x%x, 0%o)\n", key, msgflg);
402 if (key != IPC_PRIVATE) {
403 for (msqid = 0; msqid < msginfo.msgmni; msqid++) {
404 msqptr = &msqids[msqid];
405 if (msqptr->msg_qbytes != 0 &&
406 msqptr->msg_perm.key == key)
409 if (msqid < msginfo.msgmni) {
411 printf("found public key\n");
413 if ((msgflg & IPC_CREAT) && (msgflg & IPC_EXCL)) {
415 printf("not exclusive\n");
419 if ((eval = ipcperm(p, &msqptr->msg_perm, msgflg & 0700 ))) {
421 printf("requester doesn't have 0%o access\n",
431 printf("need to allocate the msqid_ds\n");
433 if (key == IPC_PRIVATE || (msgflg & IPC_CREAT)) {
434 for (msqid = 0; msqid < msginfo.msgmni; msqid++) {
436 * Look for an unallocated and unlocked msqid_ds.
437 * msqid_ds's can be locked by msgsnd or msgrcv while
438 * they are copying the message in/out. We can't
439 * re-use the entry until they release it.
441 msqptr = &msqids[msqid];
442 if (msqptr->msg_qbytes == 0 &&
443 (msqptr->msg_perm.mode & MSG_LOCKED) == 0)
446 if (msqid == msginfo.msgmni) {
448 printf("no more msqid_ds's available\n");
453 printf("msqid %d is available\n", msqid);
455 msqptr->msg_perm.key = key;
456 msqptr->msg_perm.cuid = cred->cr_uid;
457 msqptr->msg_perm.uid = cred->cr_uid;
458 msqptr->msg_perm.cgid = cred->cr_gid;
459 msqptr->msg_perm.gid = cred->cr_gid;
460 msqptr->msg_perm.mode = (msgflg & 0777);
461 /* Make sure that the returned msqid is unique */
462 msqptr->msg_perm.seq++;
463 msqptr->msg_first = NULL;
464 msqptr->msg_last = NULL;
465 msqptr->msg_cbytes = 0;
466 msqptr->msg_qnum = 0;
467 msqptr->msg_qbytes = msginfo.msgmnb;
468 msqptr->msg_lspid = 0;
469 msqptr->msg_lrpid = 0;
470 msqptr->msg_stime = 0;
471 msqptr->msg_rtime = 0;
472 msqptr->msg_ctime = time_second;
475 printf("didn't find it and wasn't asked to create it\n");
481 /* Construct the unique msqid */
482 p->p_retval[0] = IXSEQ_TO_IPCID(msqid, msqptr->msg_perm);
486 #ifndef _SYS_SYSPROTO_H_
498 register struct msgsnd_args *uap;
500 int msqid = uap->msqid;
501 void *user_msgp = uap->msgp;
502 size_t msgsz = uap->msgsz;
503 int msgflg = uap->msgflg;
504 int segs_needed, eval;
505 register struct msqid_ds *msqptr;
506 register struct msg *msghdr;
510 printf("call to msgsnd(%d, 0x%x, %d, %d)\n", msqid, user_msgp, msgsz,
514 msqid = IPCID_TO_IX(msqid);
516 if (msqid < 0 || msqid >= msginfo.msgmni) {
518 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
524 msqptr = &msqids[msqid];
525 if (msqptr->msg_qbytes == 0) {
527 printf("no such message queue id\n");
531 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
533 printf("wrong sequence number\n");
538 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_W))) {
540 printf("requester doesn't have write access\n");
545 segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz;
547 printf("msgsz=%d, msgssz=%d, segs_needed=%d\n", msgsz, msginfo.msgssz,
551 int need_more_resources = 0;
555 * (inside this loop in case msg_qbytes changes while we sleep)
558 if (msgsz > msqptr->msg_qbytes) {
560 printf("msgsz > msqptr->msg_qbytes\n");
565 if (msqptr->msg_perm.mode & MSG_LOCKED) {
567 printf("msqid is locked\n");
569 need_more_resources = 1;
571 if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes) {
573 printf("msgsz + msg_cbytes > msg_qbytes\n");
575 need_more_resources = 1;
577 if (segs_needed > nfree_msgmaps) {
579 printf("segs_needed > nfree_msgmaps\n");
581 need_more_resources = 1;
583 if (free_msghdrs == NULL) {
585 printf("no more msghdrs\n");
587 need_more_resources = 1;
590 if (need_more_resources) {
593 if ((msgflg & IPC_NOWAIT) != 0) {
595 printf("need more resources but caller doesn't want to wait\n");
600 if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0) {
602 printf("we don't own the msqid_ds\n");
606 /* Force later arrivals to wait for our
609 printf("we own the msqid_ds\n");
611 msqptr->msg_perm.mode |= MSG_LOCKED;
615 printf("goodnight\n");
617 eval = tsleep((caddr_t)msqptr, (PZERO - 4) | PCATCH,
620 printf("good morning, eval=%d\n", eval);
623 msqptr->msg_perm.mode &= ~MSG_LOCKED;
626 printf("msgsnd: interrupted system call\n");
632 * Make sure that the msq queue still exists
635 if (msqptr->msg_qbytes == 0) {
637 printf("msqid deleted\n");
644 printf("got all the resources that we need\n");
651 * We have the resources that we need.
655 if (msqptr->msg_perm.mode & MSG_LOCKED)
656 panic("msg_perm.mode & MSG_LOCKED");
657 if (segs_needed > nfree_msgmaps)
658 panic("segs_needed > nfree_msgmaps");
659 if (msgsz + msqptr->msg_cbytes > msqptr->msg_qbytes)
660 panic("msgsz + msg_cbytes > msg_qbytes");
661 if (free_msghdrs == NULL)
662 panic("no more msghdrs");
665 * Re-lock the msqid_ds in case we page-fault when copying in the
669 if ((msqptr->msg_perm.mode & MSG_LOCKED) != 0)
670 panic("msqid_ds is already locked");
671 msqptr->msg_perm.mode |= MSG_LOCKED;
674 * Allocate a message header
677 msghdr = free_msghdrs;
678 free_msghdrs = msghdr->msg_next;
679 msghdr->msg_spot = -1;
680 msghdr->msg_ts = msgsz;
683 * Allocate space for the message
686 while (segs_needed > 0) {
687 if (nfree_msgmaps <= 0)
688 panic("not enough msgmaps");
689 if (free_msgmaps == -1)
690 panic("nil free_msgmaps");
693 panic("next too low #1");
694 if (next >= msginfo.msgseg)
695 panic("next out of range #1");
697 printf("allocating segment %d to message\n", next);
699 free_msgmaps = msgmaps[next].next;
701 msgmaps[next].next = msghdr->msg_spot;
702 msghdr->msg_spot = next;
707 * Copy in the message type
710 if ((eval = copyin(user_msgp, &msghdr->msg_type,
711 sizeof(msghdr->msg_type))) != 0) {
713 printf("error %d copying the message type\n", eval);
716 msqptr->msg_perm.mode &= ~MSG_LOCKED;
717 wakeup((caddr_t)msqptr);
720 user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type);
723 * Validate the message type
726 if (msghdr->msg_type < 1) {
728 msqptr->msg_perm.mode &= ~MSG_LOCKED;
729 wakeup((caddr_t)msqptr);
731 printf("mtype (%d) < 1\n", msghdr->msg_type);
737 * Copy in the message body
740 next = msghdr->msg_spot;
743 if (msgsz > msginfo.msgssz)
744 tlen = msginfo.msgssz;
748 panic("next too low #2");
749 if (next >= msginfo.msgseg)
750 panic("next out of range #2");
751 if ((eval = copyin(user_msgp, &msgpool[next * msginfo.msgssz],
754 printf("error %d copying in message segment\n", eval);
757 msqptr->msg_perm.mode &= ~MSG_LOCKED;
758 wakeup((caddr_t)msqptr);
762 user_msgp = (char *)user_msgp + tlen;
763 next = msgmaps[next].next;
766 panic("didn't use all the msg segments");
769 * We've got the message. Unlock the msqid_ds.
772 msqptr->msg_perm.mode &= ~MSG_LOCKED;
775 * Make sure that the msqid_ds is still allocated.
778 if (msqptr->msg_qbytes == 0) {
780 wakeup((caddr_t)msqptr);
785 * Put the message into the queue
788 if (msqptr->msg_first == NULL) {
789 msqptr->msg_first = msghdr;
790 msqptr->msg_last = msghdr;
792 msqptr->msg_last->msg_next = msghdr;
793 msqptr->msg_last = msghdr;
795 msqptr->msg_last->msg_next = NULL;
797 msqptr->msg_cbytes += msghdr->msg_ts;
799 msqptr->msg_lspid = p->p_pid;
800 msqptr->msg_stime = time_second;
802 wakeup((caddr_t)msqptr);
807 #ifndef _SYS_SYSPROTO_H_
820 register struct msgrcv_args *uap;
822 int msqid = uap->msqid;
823 void *user_msgp = uap->msgp;
824 size_t msgsz = uap->msgsz;
825 long msgtyp = uap->msgtyp;
826 int msgflg = uap->msgflg;
828 register struct msqid_ds *msqptr;
829 register struct msg *msghdr;
834 printf("call to msgrcv(%d, 0x%x, %d, %ld, %d)\n", msqid, user_msgp,
835 msgsz, msgtyp, msgflg);
838 msqid = IPCID_TO_IX(msqid);
840 if (msqid < 0 || msqid >= msginfo.msgmni) {
842 printf("msqid (%d) out of range (0<=msqid<%d)\n", msqid,
848 msqptr = &msqids[msqid];
849 if (msqptr->msg_qbytes == 0) {
851 printf("no such message queue id\n");
855 if (msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
857 printf("wrong sequence number\n");
862 if ((eval = ipcperm(p, &msqptr->msg_perm, IPC_R))) {
864 printf("requester doesn't have read access\n");
870 while (msghdr == NULL) {
872 msghdr = msqptr->msg_first;
873 if (msghdr != NULL) {
874 if (msgsz < msghdr->msg_ts &&
875 (msgflg & MSG_NOERROR) == 0) {
877 printf("first message on the queue is too big (want %d, got %d)\n",
878 msgsz, msghdr->msg_ts);
882 if (msqptr->msg_first == msqptr->msg_last) {
883 msqptr->msg_first = NULL;
884 msqptr->msg_last = NULL;
886 msqptr->msg_first = msghdr->msg_next;
887 if (msqptr->msg_first == NULL)
888 panic("msg_first/last screwed up #1");
892 struct msg *previous;
896 prev = &(msqptr->msg_first);
897 while ((msghdr = *prev) != NULL) {
899 * Is this message's type an exact match or is
900 * this message's type less than or equal to
901 * the absolute value of a negative msgtyp?
902 * Note that the second half of this test can
903 * NEVER be true if msgtyp is positive since
904 * msg_type is always positive!
907 if (msgtyp == msghdr->msg_type ||
908 msghdr->msg_type <= -msgtyp) {
910 printf("found message type %d, requested %d\n",
911 msghdr->msg_type, msgtyp);
913 if (msgsz < msghdr->msg_ts &&
914 (msgflg & MSG_NOERROR) == 0) {
916 printf("requested message on the queue is too big (want %d, got %d)\n",
917 msgsz, msghdr->msg_ts);
921 *prev = msghdr->msg_next;
922 if (msghdr == msqptr->msg_last) {
923 if (previous == NULL) {
926 panic("msg_first/last screwed up #2");
934 panic("msg_first/last screwed up #3");
942 prev = &(msghdr->msg_next);
947 * We've either extracted the msghdr for the appropriate
948 * message or there isn't one.
949 * If there is one then bail out of this loop.
956 * Hmph! No message found. Does the user want to wait?
959 if ((msgflg & IPC_NOWAIT) != 0) {
961 printf("no appropriate message found (msgtyp=%d)\n",
964 /* The SVID says to return ENOMSG. */
968 /* Unfortunately, BSD doesn't define that code yet! */
974 * Wait for something to happen
978 printf("msgrcv: goodnight\n");
980 eval = tsleep((caddr_t)msqptr, (PZERO - 4) | PCATCH, "msgwait",
983 printf("msgrcv: good morning (eval=%d)\n", eval);
988 printf("msgsnd: interrupted system call\n");
994 * Make sure that the msq queue still exists
997 if (msqptr->msg_qbytes == 0 ||
998 msqptr->msg_perm.seq != IPCID_TO_SEQ(uap->msqid)) {
1000 printf("msqid deleted\n");
1007 * Return the message to the user.
1009 * First, do the bookkeeping (before we risk being interrupted).
1012 msqptr->msg_cbytes -= msghdr->msg_ts;
1014 msqptr->msg_lrpid = p->p_pid;
1015 msqptr->msg_rtime = time_second;
1018 * Make msgsz the actual amount that we'll be returning.
1019 * Note that this effectively truncates the message if it is too long
1020 * (since msgsz is never increased).
1024 printf("found a message, msgsz=%d, msg_ts=%d\n", msgsz,
1027 if (msgsz > msghdr->msg_ts)
1028 msgsz = msghdr->msg_ts;
1031 * Return the type to the user.
1034 eval = copyout((caddr_t)&(msghdr->msg_type), user_msgp,
1035 sizeof(msghdr->msg_type));
1038 printf("error (%d) copying out message type\n", eval);
1040 msg_freehdr(msghdr);
1041 wakeup((caddr_t)msqptr);
1044 user_msgp = (char *)user_msgp + sizeof(msghdr->msg_type);
1047 * Return the segments to the user
1050 next = msghdr->msg_spot;
1051 for (len = 0; len < msgsz; len += msginfo.msgssz) {
1054 if (msgsz - len > msginfo.msgssz)
1055 tlen = msginfo.msgssz;
1059 panic("next too low #3");
1060 if (next >= msginfo.msgseg)
1061 panic("next out of range #3");
1062 eval = copyout((caddr_t)&msgpool[next * msginfo.msgssz],
1066 printf("error (%d) copying out message segment\n",
1069 msg_freehdr(msghdr);
1070 wakeup((caddr_t)msqptr);
1073 user_msgp = (char *)user_msgp + tlen;
1074 next = msgmaps[next].next;
1078 * Done, return the actual number of bytes copied out.
1081 msg_freehdr(msghdr);
1082 wakeup((caddr_t)msqptr);
1083 p->p_retval[0] = msgsz;