1rmvb(9F)                 Kernel Functions for Drivers                 rmvb(9F)
2
3
4

NAME

6       rmvb - remove a message block from a message
7

SYNOPSIS

9       #include <sys/stream.h>
10
11
12
13       mblk_t *rmvb(mblk_t *mp, mblk_t *bp);
14
15

INTERFACE LEVEL

17       Architecture independent level 1 (DDI/DKI).
18

PARAMETERS

20       mp    Message  from  which  a  block  is  to  be  removed. mblk_t is an
21             instance of the msgb(9S) structure.
22
23
24       bp    Message block to be removed.
25
26

DESCRIPTION

28       The rmvb() function removes a message block (bp) from a  message  (mp),
29       and  returns a pointer to the altered message. The message block is not
30       freed, merely removed from the message. It is the  module  or  driver's
31       responsibility to free the message block.
32

RETURN VALUES

34       If  successful,  a  pointer to the message (minus the removed block) is
35       returned. The pointer is NULL if bp was the only block of  the  message
36       before   rmvb()  was  called. If the designated message block (bp) does
37       not exist, -1 is returned.
38

CONTEXT

40       The rmvb() function can be called from user, interrupt, or kernel  con‐
41       text.
42

EXAMPLES

44       This  routine  removes  all  zero-length M_DATA message blocks from the
45       given message. For each message block in the  message,  save  the  next
46       message block (line 10). If the current message block is of type M_DATA
47       and has no data in its buffer (line 11), then remove it from  the  mes‐
48       sage (line 12) and free it (line 13). In either case, continue with the
49       next message block in the message (line 16).
50
51         1  void
52          2  xxclean(mp)
53          3      mblk_t *mp;
54          4  {
55          5          mblk_t *tmp;
56          6          mblk_t *nmp;
57          7
58          8          tmp = mp;
59          9          while (tmp) {
60         10                   nmp = tmp->b_cont;
61         11                   if ((tmp->b_datap->db_type == M_DATA) &&
62                                    (tmp->b_rptr == tmp->b_wptr)) {
63         12                        (void) rmvb(mp, tmp);
64         13                        freeb(tmp);
65         14                   }
66         15                   tmp = nmp;
67         16          }
68         17  }
69
70

SEE ALSO

72       freeb(9F), msgb(9S)
73
74
75       Writing Device Drivers
76
77
78       STREAMS Programming Guide
79
80
81
82SunOS 5.11                        16 Jan 2006                         rmvb(9F)
Impressum