1explain_getgroups(3) Library Functions Manual explain_getgroups(3)
2
3
4
6 explain_getgroups - explain getgroups(2) errors
7
9 #include <libexplain/getgroups.h>
10 const char *explain_getgroups(int data_size, gid_t *data);
11 const char *explain_errno_getgroups(int errnum, int data_size, gid_t
12 *data);
13 void explain_message_getgroups(char *message, int message_size, int
14 data_size, gid_t *data);
15 void explain_message_errno_getgroups(char *message, int message_size,
16 int errnum, int data_size, gid_t *data);
17
19 These functions may be used to obtain explanations for errors returned
20 by the getgroups(2) system call.
21
22 explain_getgroups
23 const char *explain_getgroups(int data_size, gid_t *data);
24
25 The explain_getgroups function is used to obtain an explanation of an
26 error returned by the getgroups(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 data_size
34 The original data_size, exactly as passed to the getgroups(2)
35 system call.
36
37 data The original data, exactly as passed to the getgroups(2) system
38 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 (getgroups(data_size, data) < 0)
53 {
54 fprintf(stderr, "%s\n", explain_getgroups(data_size, data));
55 exit(EXIT_FAILURE);
56 }
57
58 The above code example is available pre‐packaged as the explain_get‐
59 groups_or_die(3) function.
60
61 explain_errno_getgroups
62 const char *explain_errno_getgroups(int errnum, int data_size, gid_t
63 *data);
64
65 The explain_errno_getgroups function is used to obtain an explanation
66 of an error returned by the getgroups(2) system call. The least the
67 message will contain is the value of strerror(errno), but usually it
68 will do 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_size
77 The original data_size, exactly as passed to the getgroups(2)
78 system call.
79
80 data The original data, exactly as passed to the getgroups(2) system
81 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 (getgroups(data_size, data) < 0)
96 {
97 int err = errno;
98 fprintf(stderr, "%s\n", explain_errno_getgroups(err,
99 data_size, data));
100 exit(EXIT_FAILURE);
101 }
102
103 The above code example is available pre‐packaged as the explain_get‐
104 groups_or_die(3) function.
105
106 explain_message_getgroups
107 void explain_message_getgroups(char *message, int message_size, int
108 data_size, gid_t *data);
109
110 The explain_message_getgroups function is used to obtain an explanation
111 of an error returned by the getgroups(2) system call. The least the
112 message will contain is the value of strerror(errno), but usually it
113 will do 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_size
127 The original data_size, exactly as passed to the getgroups(2)
128 system call.
129
130 data The original data, exactly as passed to the getgroups(2) system
131 call.
132
133 Example: This function is intended to be used in a fashion similar to
134 the following example:
135 if (getgroups(data_size, data) < 0)
136 {
137 char message[3000];
138 explain_message_getgroups(message, sizeof(message),
139 data_size, data);
140 fprintf(stderr, "%s\n", message);
141 exit(EXIT_FAILURE);
142 }
143
144 The above code example is available pre‐packaged as the explain_get‐
145 groups_or_die(3) function.
146
147 explain_message_errno_getgroups
148 void explain_message_errno_getgroups(char *message, int message_size,
149 int errnum, int data_size, gid_t *data);
150
151 The explain_message_errno_getgroups function is used to obtain an
152 explanation of an error returned by the getgroups(2) system call. The
153 least the message will contain is the value of strerror(errno), but
154 usually it will do much better, and indicate the underlying cause in
155 more detail.
156
157 message The location in which to store the returned message. If a suit‐
158 able message return buffer is supplied, this function is thread
159 safe.
160
161 message_size
162 The size in bytes of the location in which to store the
163 returned message.
164
165 errnum The error value to be decoded, usually obtained from the errno
166 global variable just before this function is called. This is
167 necessary if you need to call any code between the system call
168 to be explained and this function, because many libc functions
169 will alter the value of errno.
170
171 data_size
172 The original data_size, exactly as passed to the getgroups(2)
173 system call.
174
175 data The original data, exactly as passed to the getgroups(2) system
176 call.
177
178 Example: This function is intended to be used in a fashion similar to
179 the following example:
180 if (getgroups(data_size, data) < 0)
181 {
182 int err = errno;
183 char message[3000];
184 explain_message_errno_getgroups(message, sizeof(message),
185 err, data_size, data);
186 fprintf(stderr, "%s\n", message);
187 exit(EXIT_FAILURE);
188 }
189
190 The above code example is available pre‐packaged as the explain_get‐
191 groups_or_die(3) function.
192
194 getgroups(2)
195 get/set list of supplementary group IDs
196
197 explain_getgroups_or_die(3)
198 get/set list of supplementary group IDs and report errors
199
201 libexplain version 0.40
202 Copyright (C) 2009 Peter Miller
203
204
205
206 explain_getgroups(3)