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

NAME

6       explain_remove - explain remove(2) errors
7

SYNOPSIS

9       #include <libexplain/remove.h>
10       const char *explain_remove(const char *pathname);
11       const char *explain_errno_remove(int errnum, const char *pathname);
12       void explain_message_remove(char *message, int message_size, const char
13       *pathname);
14       void explain_message_errno_remove(char *message, int message_size,  int
15       errnum, const char *pathname);
16

DESCRIPTION

18       These  functions may be used to obtain explanations for errors returned
19       by the remove(2) system call.
20
21   explain_remove
22       const char *explain_remove(const char *pathname);
23
24       The explain_remove function may be used to describe errors returned  by
25       the  remove()  system  call.  The least the message will contain is the
26       value of strerror(errno), but usually it will do much better, and indi‐
27       cate 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 (remove(pathname) < 0)
35              {
36                  fprintf(stderr, "%s\n", explain_remove(pathname));
37                  exit(EXIT_FAILURE);
38              }
39
40       pathname
41               The  original pathname, exactly as passed to the remove(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_remove
55       const char *explain_errno_remove(int errnum, const char *pathname);
56
57       The  explain_errno_remove  function  may  be  used  to  describe errors
58       returned by the remove() system call.  The least the message will  con‐
59       tain is the value of strerror(errnum), but usually it will do much bet‐
60       ter, 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 (remove(pathname) < 0)
65              {
66                  int err = errno;
67                  fprintf(stderr, "%s\n", explain_remove(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 remove(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_removevoid explain_message_remove(char *message,
92       int message_size, const char *pathname);
93
94       The  explain_message_remove  function  may  be  used to describe errors
95       returned by the remove() system call.  The least the message will  con‐
96       tain  is the value of strerror(errno), but usually it will do much bet‐
97       ter, 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 (remove(pathname) < 0)
105              {
106                  char message[3000];
107                  explain_message_remove(message, sizeof(message), pathname);
108                  fprintf(stderr, "%s\n", message);
109                  exit(EXIT_FAILURE);
110              }
111
112       message The location in which to store  the  returned  message.   If  a
113               suitable  message  return  buffer is 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 remove(2) sys‐
122               tem call.
123
124   explain_message_errno_remove
125       void explain_message_errno_remove(char *message, int message_size,  int
126       errnum, const char *pathname);
127
128       The  explain_message_errno_remove  function  may  be  used  to describe
129       errors returned by the remove() system call.   The  least  the  message
130       will  contain  is the value of strerror(errnum), but usually it will do
131       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 (remove(pathname) < 0)
136              {
137                  int err = errno;
138                  char message[3000];
139                  explain_message_errno_remove(message, sizeof(message), err, pathname);
140                  fprintf(stderr, "%s\n", message);
141                  exit(EXIT_FAILURE);
142              }
143
144       message The  location  in  which  to  store the returned message.  If a
145               suitable message return buffer is supplied,  this  function  is
146               thread safe.
147
148       message_size
149               The  size  in  bytes  of  the  location  in  which to store the
150               returned message.
151
152       errnum  The error value to be decoded, usually obtained from the  errno
153               global  variable  just before this function is called.  This is
154               necessary if you need to call any code between the system  call
155               to  be explained and this function, because many libc functions
156               will alter the value of errno.
157
158       pathname
159               The original pathname, exactly as passed to the remove(2)  sys‐
160               tem call.
161

SEE ALSO

163       remove  delete a name and possibly the file it refers to
164
165       explain_remove_or_die
166               delete a file and report errors
167
169       libexplain version 1.4
170       Copyright (C) 2008 Peter Miller
171
172
173
174                                                             explain_remove(3)
Impressum