1explain_munmap(3)          Library Functions Manual          explain_munmap(3)
2
3
4

NAME

6       explain_munmap - explain munmap(2) errors
7

SYNOPSIS

9       #include <libexplain/munmap.h>
10       const char *explain_munmap(void *data, size_t data_size);
11       const char *explain_errno_munmap(int errnum, void *data, size_t
12       data_size);
13       void explain_message_munmap(char *message, int message_size, void
14       *data, size_t data_size);
15       void explain_message_errno_munmap(char *message, int message_size, int
16       errnum, void *data, size_t data_size);
17

DESCRIPTION

19       These functions may be used to obtain explanations for errors  returned
20       by the munmap(2) system call.
21
22   explain_munmap
23       const char *explain_munmap(void *data, size_t data_size);
24
25       The  explain_munmap  function  is  used  to obtain an explanation of an
26       error returned by the munmap(2) system call. The least the message will
27       contain  is  the  value of strerror(errno), but usually it will do much
28       better, and indicate the underlying cause in more detail.
29
30       The errno global variable will be used to obtain the error value to  be
31       decoded.
32
33       data    The  original  data,  exactly as passed to the munmap(2) system
34               call.
35
36       data_size
37               The original data_size, exactly as passed to the munmap(2) sys‐
38               tem call.
39
40       Returns:
41               The message explaining the error. This message buffer is shared
42               by all libexplain functions which do not  supply  a  buffer  in
43               their argument list.  This will be overwritten by the next call
44               to any libexplain function which shares this buffer,  including
45               other threads.
46
47       Note: This function is not thread safe, because it shares a return buf‐
48       fer across all threads, and many other functions in this library.
49
50       Example: This function is intended to be used in a fashion  similar  to
51       the following example:
52              if (munmap(data, data_size) < 0)
53              {
54                  fprintf(stderr, "%s\n", explain_munmap(data, data_size));
55                  exit(EXIT_FAILURE);
56              }
57
58       The  above  code  example is available pre‐packaged as the explain_mun‐
59       map_or_die(3) function.
60
61   explain_errno_munmap
62       const char *explain_errno_munmap(int errnum, void *data, size_t
63       data_size);
64
65       The  explain_errno_munmap  function is used to obtain an explanation of
66       an error returned by the munmap(2) system call. The least  the  message
67       will  contain  is  the value of strerror(errno), but usually it will do
68       much better, and indicate the underlying cause in more detail.
69
70       errnum  The error value to be decoded, usually obtained from the  errno
71               global  variable  just  before this function is called. This is
72               necessary if you need to call any code between the system  call
73               to  be explained and this function, because many libc functions
74               will alter the value of errno.
75
76       data    The original data, exactly as passed to  the  munmap(2)  system
77               call.
78
79       data_size
80               The original data_size, exactly as passed to the munmap(2) sys‐
81               tem call.
82
83       Returns:
84               The message explaining the error. This message buffer is shared
85               by  all  libexplain  functions  which do not supply a buffer in
86               their argument list.  This will be overwritten by the next call
87               to  any libexplain function which shares this buffer, including
88               other threads.
89
90       Note: This function is not thread safe, because it shares a return buf‐
91       fer across all threads, and many other functions in this library.
92
93       Example:  This  function is intended to be used in a fashion similar to
94       the following example:
95              if (munmap(data, data_size) < 0)
96              {
97                  int err = errno;
98                  fprintf(stderr, "%s\n", explain_errno_munmap(err, data,
99                  data_size));
100                  exit(EXIT_FAILURE);
101              }
102
103       The  above  code  example is available pre‐packaged as the explain_mun‐
104       map_or_die(3) function.
105
106   explain_message_munmap
107       void explain_message_munmap(char *message, int message_size, void
108       *data, size_t data_size);
109
110       The explain_message_munmap function is used to obtain an explanation of
111       an error returned by the munmap(2) system call. The least  the  message
112       will  contain  is  the value of strerror(errno), but usually it will do
113       much better, and indicate the underlying cause in more detail.
114
115       The errno global variable will be used to obtain the error value to  be
116       decoded.
117
118       message The location in which to store the returned message. If a suit‐
119               able message return buffer is supplied, this function is thread
120               safe.
121
122       message_size
123               The  size  in  bytes  of  the  location  in  which to store the
124               returned message.
125
126       data    The original data, exactly as passed to  the  munmap(2)  system
127               call.
128
129       data_size
130               The original data_size, exactly as passed to the munmap(2) sys‐
131               tem call.
132
133       Example: This function is intended to be used in a fashion  similar  to
134       the following example:
135              if (munmap(data, data_size) < 0)
136              {
137                  char message[3000];
138                  explain_message_munmap(message, sizeof(message), data,
139                  data_size);
140                  fprintf(stderr, "%s\n", message);
141                  exit(EXIT_FAILURE);
142              }
143
144       The above code example is available pre‐packaged  as  the  explain_mun‐
145       map_or_die(3) function.
146
147   explain_message_errno_munmap
148       void explain_message_errno_munmap(char *message, int message_size, int
149       errnum, void *data, size_t data_size);
150
151       The explain_message_errno_munmap function is used to obtain an explana‐
152       tion  of  an error returned by the munmap(2) system call. The least the
153       message will contain is the value of strerror(errno),  but  usually  it
154       will do much better, and indicate the underlying cause in more detail.
155
156       message The location in which to store the returned message. If a suit‐
157               able message return buffer is supplied, this function is thread
158               safe.
159
160       message_size
161               The  size  in  bytes  of  the  location  in  which to store the
162               returned message.
163
164       errnum  The error value to be decoded, usually obtained from the  errno
165               global  variable  just  before this function is called. This is
166               necessary if you need to call any code between the system  call
167               to  be explained and this function, because many libc functions
168               will alter the value of errno.
169
170       data    The original data, exactly as passed to  the  munmap(2)  system
171               call.
172
173       data_size
174               The original data_size, exactly as passed to the munmap(2) sys‐
175               tem call.
176
177       Example: This function is intended to be used in a fashion  similar  to
178       the following example:
179              if (munmap(data, data_size) < 0)
180              {
181                  int err = errno;
182                  char message[3000];
183                  explain_message_errno_munmap(message, sizeof(message), err,
184                  data, data_size);
185                  fprintf(stderr, "%s\n", message);
186                  exit(EXIT_FAILURE);
187              }
188
189       The above code example is available pre‐packaged  as  the  explain_mun‐
190       map_or_die(3) function.
191

SEE ALSO

193       munmap(2)
194               unmap a file or device from memory
195
196       explain_munmap_or_die(3)
197               unmap a file or device from memory and report errors
198
200       libexplain version 0.40
201       Copyright (C) 2010 Peter Miller
202
203
204
205                                                             explain_munmap(3)
Impressum