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