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

NAME

6       explain_ftruncate - explain ftruncate(2) errors
7

SYNOPSIS

9       #include <libexplain/ftruncate.h>
10       const char *explain_ftruncate(int fildes, long long length);
11       const  char  *explain_errno_ftruncate(int errnum, int fildes, long long
12       length);
13       void explain_message_ftruncate(char  *message,  int  message_size,  int
14       fildes, long long length);
15       void  explain_message_errno_ftruncate(char  *message, int message_size,
16       int errnum, int fildes, long long length);
17

DESCRIPTION

19       These functions may be used to obtain explanations for errors  returned
20       by the ftruncate(2) system call.
21
22   explain_ftruncate
23       const char *explain_ftruncate(int fildes, long long length);
24
25       The  explain_ftruncate  function is used to obtain an explanation of an
26       error returned by the ftruncate(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 (ftruncate(fildes, length) < 0)
36              {
37                  fprintf(stderr, "%s\n", explain_ftruncate(fildes, length));
38                  exit(EXIT_FAILURE);
39              }
40
41       fildes  The original fildes, exactly as passed to the ftruncate(2) sys‐
42               tem call.
43
44       length  The original length, exactly as passed to the ftruncate(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_ftruncate
58       const  char  *explain_errno_ftruncate(int errnum, int fildes, long long
59       length);
60
61       The explain_errno_ftruncate function is used to obtain  an  explanation
62       of  an  error  returned by the ftruncate(2) system call.  The least the
63       message will contain is the value of strerror(errnum), but  usually  it
64       will do 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 (ftruncate(fildes, length) < 0)
69              {
70                  int err = errno;
71                  fprintf(stderr, "%s\n", explain_errno_ftruncate(err, fildes, length));
72                  exit(EXIT_FAILURE);
73              }
74
75       errnum  The error value to be decoded, usually obtained from the  errno
76               global  variable  just before this function is called.  This is
77               necessary if you need to call any code between the system  call
78               to  be explained and this function, because many libc functions
79               will alter the value of errno.
80
81       fildes  The original fildes, exactly as passed to the ftruncate(2) sys‐
82               tem call.
83
84       length  The original length, exactly as passed to the ftruncate(2) sys‐
85               tem call.
86
87       Returns:
88               The message explaining  the  error.   This  message  buffer  is
89               shared by all libexplain functions which do not supply a buffer
90               in their argument list.  This will be overwritten by  the  next
91               call  to  any  libexplain  function  which  shares this buffer,
92               including other threads.
93
94       Note: This function is not thread safe, because it shares a return buf‐
95       fer across all threads, and many other functions in this library.
96
97   explain_message_ftruncate
98       void  explain_message_ftruncate(char  *message,  int  message_size, int
99       fildes, long long length);
100
101       The explain_message_ftruncate function may be used to  obtain an expla‐
102       nation of an error returned by the ftruncate(2) system call.  The least
103       the message will contain is the value of strerror(errno),  but  usually
104       it  will  do  much  better,  and  indicate the underlying cause in more
105       detail.
106
107       The errno global variable will be used to obtain the error value to  be
108       decoded.
109
110       This  function  is intended to be used in a fashion similar to the fol‐
111       lowing example:
112              if (ftruncate(fildes, length) < 0)
113              {
114                  char message[3000];
115                  explain_message_ftruncate(message, sizeof(message), fildes, length);
116                  fprintf(stderr, "%s\n", message);
117                  exit(EXIT_FAILURE);
118              }
119
120       message The location in which to store  the  returned  message.   If  a
121               suitable  message  return  buffer is supplied, this function is
122               thread safe.
123
124       message_size
125               The size in bytes  of  the  location  in  which  to  store  the
126               returned message.
127
128       fildes  The original fildes, exactly as passed to the ftruncate(2) sys‐
129               tem call.
130
131       length  The original length, exactly as passed to the ftruncate(2) sys‐
132               tem call.
133
134   explain_message_errno_ftruncate
135       void  explain_message_errno_ftruncate(char  *message, int message_size,
136       int errnum, int fildes, long long length);
137
138       The explain_message_errno_ftruncate function may be used to  obtain  an
139       explanation  of an error returned by the ftruncate(2) system call.  The
140       least the message will contain is the value  of  strerror(errnum),  but
141       usually  it  will  do much better, and indicate the underlying cause in
142       more detail.
143
144       This function is intended to be used in a fashion similar to  the  fol‐
145       lowing example:
146              if (ftruncate(fildes, length) < 0)
147              {
148                  int err = errno;
149                  char message[3000];
150                  explain_message_errno_ftruncate(message, sizeof(message), err,
151                      fildes, length);
152                  fprintf(stderr, "%s\n", message);
153                  exit(EXIT_FAILURE);
154              }
155
156       message The  location  in  which  to  store the returned message.  If a
157               suitable message return buffer is supplied,  this  function  is
158               thread 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       fildes  The original fildes, exactly as passed to the ftruncate(2) sys‐
171               tem call.
172
173       length  The original length, exactly as passed to the ftruncate(2) sys‐
174               tem call.
175

SEE ALSO

177       ftruncate(2)
178               truncate a file to a specified length
179
180       explain_ftruncate_or_die(3)
181               truncate a file and report errors
182
184       libexplain version 1.4
185       Copyright (C) 2008 Peter Miller
186
187
188
189                                                          explain_ftruncate(3)
Impressum