1explain_opendir(3) Library Functions Manual explain_opendir(3)
2
3
4
6 explain_opendir - explain opendir(3) errors
7
9 const char *explain_opendir(const char *pathname);
10 const char *explain_errno_opendir(int errnum, const char *pathname);
11 int errnum, const char *pathname);
12 void explain_message_opendir(char *message, int message_size,
13 void explain_message_errno_opendir(char *message, int message_size,
14 const char *pathname);
15
17 These functions may be used to explain opendir(3) errors.
18
19 explain_opendir
20 const char *explain_opendir(const char *pathname);
21
22 The explain_opendir function is used to obtain an explanation of an
23 error returned by the opendir(3) function. The least the message will
24 contain is the value of strerror(errno), but usually it will do much
25 better, and indicate the underlying cause in more detail.
26
27 The errno global variable will be used to obtain the error value to be
28 decoded.
29
30 This function is intended to be used in a fashion similar to the fol‐
31 lowing example:
32 DIR *dp = opendir(pathname);
33 if (!dp)
34 {
35 fprintf(stderr, "%s\n", explain_opendir(pathname));
36 exit(EXIT_FAILURE);
37 }
38
39 pathname
40 The original pathname, exactly as passed to the opendir(3) sys‐
41 tem call.
42
43 Returns:
44 The message explaining the error. This message buffer is
45 shared by all libexplain functions which do not supply a buffer
46 in their argument list. This will be overwritten by the next
47 call to any libexplain function which shares this buffer,
48 including other threads.
49
50 Note: This function is not thread safe, because it shares a return buf‐
51 fer across all threads, and many other functions in this library.
52
53 explain_errno_opendir
54 const char *explain_errno_opendir(int errnum, const char *pathname);
55 int errnum, const char *pathname);
56
57 The explain_errno_opendir function is used to obtain an explanation of
58 an error returned by the opendir(3) function. The least the message
59 will contain is the value of strerror(errnum), but usually it will do
60 much better, and indicate the underlying cause in more detail.
61
62 This function is intended to be used in a fashion similar to the fol‐
63 lowing example:
64 DIR *dp = opendir(pathname);
65 if (!dp)
66 {
67 int errnum = errno;
68 const char *message = explain_errno_opendir(errnum, pathname);
69 fprintf(stderr, "%s\n", message);
70 exit(EXIT_FAILURE);
71 }
72
73 errnum The error value to be decoded, usually obtained from the errno
74 global variable just before this function is called. This is
75 necessary if you need to call any code between the system call
76 to be explained and this function, because many libc functions
77 will alter the value of errno.
78
79 pathname
80 The original pathname, exactly as passed to the opendir(3) sys‐
81 tem call.
82
83 Returns:
84 The message explaining the error. This message buffer is
85 shared by all libexplain functions which do not supply a buffer
86 in their argument list. This will be overwritten by the next
87 call to any libexplain function which shares this buffer,
88 including 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 explain_message_opendir
94 void explain_message_opendir(char *message, int message_size, const
95 char *pathname);
96
97 The explain_message_opendir function is used to obtain an explanation
98 of an error returned by the opendir(3) function. The least the message
99 will contain is the value of strerror(errno), but usually it will do
100 much better, and indicate the underlying cause in more detail.
101
102 The errno global variable will be used to obtain the error value to be
103 decoded.
104
105 This function is intended to be used in a fashion similar to the fol‐
106 lowing example:
107 DIR *dp = opendir(pathname);
108 if (!dp)
109 {
110 char message[3000];
111 explain_message_opendir(message, sizeof(message), pathname);
112 fprintf(stderr, "%s\n", message);
113 exit(EXIT_FAILURE);
114 }
115
116 message The location in which to store the returned message. Because a
117 message return buffer has been supplied, this function is
118 thread safe if the buffer is thread safe.
119
120 message_size
121 The size in bytes of the location in which to store the
122 returned message.
123
124 pathname
125 The original pathname, exactly as passed to the opendir(3) sys‐
126 tem call.
127
128 explain_message_errno_opendir
129 void explain_message_errno_opendir(char *message, int message_size,
130 const char *pathname);
131
132 The explain_message_errno_opendir function is used to obtain an expla‐
133 nation of an error returned by the opendir(3) function. The least the
134 message will contain is the value of strerror(errnum), but usually it
135 will do much better, and indicate the underlying cause in more detail.
136
137 This function is intended to be used in a fashion similar to the fol‐
138 lowing example:
139 DIR *dp = opendir(pathname);
140 if (!dp);
141 {
142 int err = errno;
143 char message[3000];
144 explain_message_errno_opendir(message, sizeof(message), err,
145 pathname);
146 fprintf(stderr, '%s\n', message);
147 exit(EXIT_FAILURE);
148 }
149
150 message The location in which to store the returned message. Because a
151 message return buffer has been supplied, this function is
152 thread safe if the buffer is thread safe.
153 message_size The size in bytes of the location in which to
154 store the returned message.
155
156 errnum The error value to be decoded, usually obtained from the errno
157 global variable just before this function is called. This is
158 necessary if you need to call any code between the system call
159 to be explained and this function, because many libc functions
160 will alter the value of errno.
161
162 pathname
163 The original pathname, exactly as passed to the opendir(3) sys‐
164 tem call.
165
167 libexplain version 0.40
168 Copyright (C) 2008 Peter Miller
169
171 Written by Peter Miller <pmiller@opensource.org.au>
172
173
174
175 explain_opendir(3)