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