1explain_lchmod(3)          Library Functions Manual          explain_lchmod(3)
2
3
4

NAME

6       explain_lchmod - explain lchmod(2) errors
7

SYNOPSIS

9       #include <libexplain/lchmod.h>
10       const char *explain_lchmod(const char *pathname, mode_t mode);
11       const char *explain_errno_lchmod(int errnum, const char *pathname,
12       mode_t mode);
13       void explain_message_lchmod(char *message, int message_size, const char
14       *pathname, mode_t mode);
15       void explain_message_errno_lchmod(char *message, int message_size, int
16       errnum, const char *pathname, mode_t mode);
17

DESCRIPTION

19       These functions may be used to obtain explanations for errors  returned
20       by the lchmod(2) system call.
21
22   explain_lchmod
23       const char *explain_lchmod(const char *pathname, mode_t mode);
24
25       The  explain_lchmod  function  is  used  to obtain an explanation of an
26       error returned by the lchmod(2) system call. The least the message will
27       contain  is  the  value of strerror(errno), but usually it will do much
28       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       pathname
34               The  original pathname, exactly as passed to the lchmod(2) sys‐
35               tem call.
36
37       mode    The original mode, exactly as passed to  the  lchmod(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 (lchmod(pathname, mode) < 0)
53              {
54                  fprintf(stderr, "%s\n", explain_lchmod(pathname, mode));
55                  exit(EXIT_FAILURE);
56              }
57
58       The  above  code  example is available pre-packaged as the explain_lch‐
59       mod_or_die(3) function.
60
61   explain_errno_lchmod
62       const char *explain_errno_lchmod(int errnum, const char *pathname,
63       mode_t mode);
64
65       The  explain_errno_lchmod  function is used to obtain an explanation of
66       an error returned by the lchmod(2) system call. The least  the  message
67       will  contain  is  the value of strerror(errno), but usually it will do
68       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       pathname
77               The original pathname, exactly as passed to the lchmod(2)  sys‐
78               tem call.
79
80       mode    The  original  mode,  exactly as passed to the lchmod(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 (lchmod(pathname, mode) < 0)
96              {
97                  int err = errno;
98                  fprintf(stderr, "%s\n", explain_errno_lchmod(err, pathname,
99                  mode));
100                  exit(EXIT_FAILURE);
101              }
102
103       The  above  code  example is available pre-packaged as the explain_lch‐
104       mod_or_die(3) function.
105
106   explain_message_lchmod
107       void explain_message_lchmod(char *message, int message_size, const char
108       *pathname, mode_t mode);
109
110       The explain_message_lchmod function is used to obtain an explanation of
111       an error returned by the lchmod(2) system call. The least  the  message
112       will  contain  is  the value of strerror(errno), but usually it will do
113       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       pathname
127               The original pathname, exactly as passed to the lchmod(2)  sys‐
128               tem call.
129
130       mode    The  original  mode,  exactly as passed to the lchmod(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 (lchmod(pathname, mode) < 0)
136              {
137                  char message[3000];
138                  explain_message_lchmod(message, sizeof(message), pathname,
139                  mode);
140                  fprintf(stderr, "%s\n", message);
141                  exit(EXIT_FAILURE);
142              }
143
144       The above code example is available pre-packaged  as  the  explain_lch‐
145       mod_or_die(3) function.
146
147   explain_message_errno_lchmod
148       void explain_message_errno_lchmod(char *message, int message_size, int
149       errnum, const char *pathname, mode_t mode);
150
151       The explain_message_errno_lchmod function is used to obtain an explana‐
152       tion  of  an error returned by the lchmod(2) system call. The least the
153       message will contain is the value of strerror(errno),  but  usually  it
154       will do much better, and indicate the underlying cause in more detail.
155
156       message The location in which to store the returned message. If a suit‐
157               able message return buffer is supplied, this function is thread
158               safe.
159
160       message_size
161               The  size  in  bytes  of  the  location  in  which to store the
162               returned message.
163
164       errnum  The error value to be decoded, usually obtained from the  errno
165               global  variable  just  before this function is called. This is
166               necessary if you need to call any code between the system  call
167               to  be explained and this function, because many libc functions
168               will alter the value of errno.
169
170       pathname
171               The original pathname, exactly as passed to the lchmod(2)  sys‐
172               tem call.
173
174       mode    The  original  mode,  exactly as passed to the lchmod(2) system
175               call.
176
177       Example: This function is intended to be used in a fashion  similar  to
178       the following example:
179              if (lchmod(pathname, mode) < 0)
180              {
181                  int err = errno;
182                  char message[3000];
183                  explain_message_errno_lchmod(message, sizeof(message), err,
184                  pathname, mode);
185                  fprintf(stderr, "%s\n", message);
186                  exit(EXIT_FAILURE);
187              }
188
189       The above code example is available pre-packaged  as  the  explain_lch‐
190       mod_or_die(3) function.
191

SEE ALSO

193       lchmod(2)
194               change permissions of a file
195
196       explain_lchmod_or_die(3)
197               change permissions of a file and report errors
198
200       libexplain version 1.4
201       Copyright (C) 2012 Peter Miller
202
203
204
205                                                             explain_lchmod(3)
Impressum