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

NAME

6       explain_unlink - explain unlink(2) errors
7

SYNOPSIS

9       #include <libexplain/unlink.h>
10       const char *explain_unlink(const char *pathname);
11       void explain_message_unlink(char *message, int message_size, const char
12       *pathname);
13       const char *explain_errno_unlink(int errnum, const char *pathname);
14       void explain_message_errno_unlink(char *message, int message_size,  int
15       errnum, const char *pathname);
16

DESCRIPTION

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

AUTHOR

169       Written by Peter Miller <pmiller@opensource.org.au>
170
171
172
173                                                             explain_unlink(3)
Impressum