1explain_openat(3) Library Functions Manual explain_openat(3)
2
3
4
6 explain_openat - explain openat(2) errors
7
9 #include <libexplain/openat.h>
10 const char *explain_openat(int fildes, const char *pathname, int flags,
11 mode_t mode);
12 const char *explain_errno_openat(int errnum, int fildes, const char
13 *pathname, int flags, mode_t mode);
14 void explain_message_openat(char *message, int message_size, int
15 fildes, const char *pathname, int flags, mode_t mode);
16 void explain_message_errno_openat(char *message, int message_size, int
17 errnum, int fildes, const char *pathname, int flags, mode_t mode);
18
20 These functions may be used to obtain explanations for errors returned
21 by the openat(2) system call.
22
23 explain_openat
24 const char *explain_openat(int fildes, const char *pathname, int flags,
25 mode_t mode);
26
27 The explain_openat function is used to obtain an explanation of an
28 error returned by the openat(2) system call. The least the message will
29 contain is the value of strerror(errno), but usually it will do much
30 better, and indicate the underlying cause in more detail.
31
32 The errno global variable will be used to obtain the error value to be
33 decoded.
34
35 fildes The original fildes, exactly as passed to the openat(2) system
36 call.
37
38 pathname
39 The original pathname, exactly as passed to the openat(2) sys‐
40 tem call.
41
42 flags The original flags, exactly as passed to the openat(2) system
43 call.
44
45 mode The original mode, exactly as passed to the openat(2) system
46 call.
47
48 Returns:
49 The message explaining the error. This message buffer is shared
50 by all libexplain functions which do not supply a buffer in
51 their argument list. This will be overwritten by the next call
52 to any libexplain function which shares this buffer, including
53 other threads.
54
55 Note: This function is not thread safe, because it shares a return buf‐
56 fer across all threads, and many other functions in this library.
57
58 Example: This function is intended to be used in a fashion similar to
59 the following example:
60 int result = openat(fildes, pathname, flags, mode);
61 if (result < 0)
62 {
63 fprintf(stderr, "%s\n", explain_openat(fildes, pathname,
64 flags, mode));
65 exit(EXIT_FAILURE);
66 }
67
68 The above code example is available pre-packaged as the explain_ope‐
69 nat_or_die(3) function.
70
71 explain_errno_openat
72 const char *explain_errno_openat(int errnum, int fildes, const char
73 *pathname, int flags, mode_t mode);
74
75 The explain_errno_openat function is used to obtain an explanation of
76 an error returned by the openat(2) system call. The least the message
77 will contain is the value of strerror(errno), but usually it will do
78 much better, and indicate the underlying cause in more detail.
79
80 errnum The error value to be decoded, usually obtained from the errno
81 global variable just before this function is called. This is
82 necessary if you need to call any code between the system call
83 to be explained and this function, because many libc functions
84 will alter the value of errno.
85
86 fildes The original fildes, exactly as passed to the openat(2) system
87 call.
88
89 pathname
90 The original pathname, exactly as passed to the openat(2) sys‐
91 tem call.
92
93 flags The original flags, exactly as passed to the openat(2) system
94 call.
95
96 mode The original mode, exactly as passed to the openat(2) system
97 call.
98
99 Returns:
100 The message explaining the error. This message buffer is shared
101 by all libexplain functions which do not supply a buffer in
102 their argument list. This will be overwritten by the next call
103 to any libexplain function which shares this buffer, including
104 other threads.
105
106 Note: This function is not thread safe, because it shares a return buf‐
107 fer across all threads, and many other functions in this library.
108
109 Example: This function is intended to be used in a fashion similar to
110 the following example:
111 int result = openat(fildes, pathname, flags, mode);
112 if (result < 0)
113 {
114 int err = errno;
115 fprintf(stderr, "%s\n", explain_errno_openat(err, fildes,
116 pathname, flags, mode));
117 exit(EXIT_FAILURE);
118 }
119
120 The above code example is available pre-packaged as the explain_ope‐
121 nat_or_die(3) function.
122
123 explain_message_openat
124 void explain_message_openat(char *message, int message_size, int
125 fildes, const char *pathname, int flags, mode_t mode);
126
127 The explain_message_openat function is used to obtain an explanation of
128 an error returned by the openat(2) system call. The least the message
129 will contain is the value of strerror(errno), but usually it will do
130 much better, and indicate the underlying cause in more detail.
131
132 The errno global variable will be used to obtain the error value to be
133 decoded.
134
135 message The location in which to store the returned message. If a suit‐
136 able message return buffer is supplied, this function is thread
137 safe.
138
139 message_size
140 The size in bytes of the location in which to store the
141 returned message.
142
143 fildes The original fildes, exactly as passed to the openat(2) system
144 call.
145
146 pathname
147 The original pathname, exactly as passed to the openat(2) sys‐
148 tem call.
149
150 flags The original flags, exactly as passed to the openat(2) system
151 call.
152
153 mode The original mode, exactly as passed to the openat(2) system
154 call.
155
156 Example: This function is intended to be used in a fashion similar to
157 the following example:
158 int result = openat(fildes, pathname, flags, mode);
159 if (result < 0)
160 {
161 char message[3000];
162 explain_message_openat(message, sizeof(message), fildes,
163 pathname, flags, mode);
164 fprintf(stderr, "%s\n", message);
165 exit(EXIT_FAILURE);
166 }
167
168 The above code example is available pre-packaged as the explain_ope‐
169 nat_or_die(3) function.
170
171 explain_message_errno_openat
172 void explain_message_errno_openat(char *message, int message_size, int
173 errnum, int fildes, const char *pathname, int flags, mode_t mode);
174
175 The explain_message_errno_openat function is used to obtain an explana‐
176 tion of an error returned by the openat(2) system call. The least the
177 message will contain is the value of strerror(errno), but usually it
178 will do much better, and indicate the underlying cause in more detail.
179
180 message The location in which to store the returned message. If a suit‐
181 able message return buffer is supplied, this function is thread
182 safe.
183
184 message_size
185 The size in bytes of the location in which to store the
186 returned message.
187
188 errnum The error value to be decoded, usually obtained from the errno
189 global variable just before this function is called. This is
190 necessary if you need to call any code between the system call
191 to be explained and this function, because many libc functions
192 will alter the value of errno.
193
194 fildes The original fildes, exactly as passed to the openat(2) system
195 call.
196
197 pathname
198 The original pathname, exactly as passed to the openat(2) sys‐
199 tem call.
200
201 flags The original flags, exactly as passed to the openat(2) system
202 call.
203
204 mode The original mode, exactly as passed to the openat(2) system
205 call.
206
207 Example: This function is intended to be used in a fashion similar to
208 the following example:
209 int result = openat(fildes, pathname, flags, mode);
210 if (result < 0)
211 {
212 int err = errno;
213 char message[3000];
214 explain_message_errno_openat(message, sizeof(message), err,
215 fildes, pathname, flags, mode);
216 fprintf(stderr, "%s\n", message);
217 exit(EXIT_FAILURE);
218 }
219
220 The above code example is available pre-packaged as the explain_ope‐
221 nat_or_die(3) function.
222
224 openat(2)
225 open a file relative to a directory file descriptor
226
227 explain_openat_or_die(3)
228 open a file relative to a directory file descriptor and report
229 errors
230
232 libexplain version 1.4
233 Copyright (C) 2013 Peter Miller
234
235
236
237 explain_openat(3)