The stream functions do not populate errno.
In these cases return either F_file_read or F_file_write with the error bits set as appropriate.
Update the documentation comments.
if (ferror_unlocked(file.stream)) {
funlockfile(file.stream);
- if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block);
- if (errno == EBADF) return F_status_set_error(F_file_descriptor);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINTR) return F_status_set_error(F_interrupt);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EIO) return F_status_set_error(F_input_output);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
-
- return F_status_set_error(F_failure);
+ return F_status_set_error(F_file_read);
}
buffer->used += size_read;
if (ferror_unlocked(file.stream)) {
funlockfile(file.stream);
- if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block);
- if (errno == EBADF) return F_status_set_error(F_file_descriptor);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINTR) return F_status_set_error(F_interrupt);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EIO) return F_status_set_error(F_input_output);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
-
- return F_status_set_error(F_failure);
+ return F_status_set_error(F_file_read);
}
if (size_read) {
if (ferror_unlocked(file.stream)) {
funlockfile(file.stream);
- if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block);
- if (errno == EBADF) return F_status_set_error(F_file_descriptor);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINTR) return F_status_set_error(F_interrupt);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EIO) return F_status_set_error(F_input_output);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
-
- return F_status_set_error(F_failure);
+ return F_status_set_error(F_file_read);
}
buffer->used += size_read;
* F_parameter (with error bit) if a parameter is invalid.
*
* @see flockfile()
+ * @see feof_unlocked()
+ * @see ferror_unlocked()
* @see fread_unlocked()
* @see funlockfile()
*/
* F_none on success.
* F_none_eof on success and EOF was reached.
*
- * F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
* F_error (with error bit) if the file is already in the error state at the start of this function.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_closed (with error bit) if the file is closed.
+ * F_file_read (with error bit) on file read error.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see feof_unlocked()
+ * @see ferror_unlocked()
+ * @see flockfile()
* @see fread()
+ * @see funlockfile()
*/
#ifndef _di_f_file_stream_read_block_
extern f_status_t f_file_stream_read_block(const f_file_t file, f_string_dynamic_t * const buffer);
* F_none_eof on success and EOF was reached.
* F_none_stop on success and total was reached.
*
- * F_block (with error bit) if file descriptor is set to non-block and the read would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
* F_error (with error bit) if the file is already in the error state at the start of this function.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_closed (with error bit) if the file is closed.
+ * F_file_read (with error bit) on file read error.
* F_parameter (with error bit) if a parameter is invalid.
*
* Errors (with error bit) from: f_string_dynamic_increase_by().
*
+ * @see feof_unlocked()
+ * @see ferror_unlocked()
* @see flockfile()
* @see fread_unlocked()
* @see funlockfile()
*
* @return
* F_none on success.
+ * F_none_eof when the file stream is at the end of the file.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_data_not on success but buffer.used is 0.
*
- * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
* F_file_write (with error bit) on any other error.
*
+ * @see ferror_unlocked()
* @see flockfile()
* @see fwrite_unlocked()
- * @see ferror_unlocked()
* @see funlockfile()
*/
#ifndef _di_f_file_stream_write_
*
* @return
* F_none on success.
+ * F_none_eof when the file stream is at the end of the file.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_data_not on success but buffer.used is 0.
*
- * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
* F_file_write (with error bit) on any other error.
*
* @return
* F_none on success.
- * F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
+ * F_none_eof when the file stream is at the end of the file.
* F_none_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
+ * F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_data_not on success but either buffer.used or total is 0.
*
- * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
* F_file_write (with error bit) on any other error.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
* F_none_eos on success but range.stop exceeded buffer.used (only wrote up to buffer.used).
*
- * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
* @see fwrite_unlocked()
if (ferror_unlocked(file.stream)) {
funlockfile(file.stream);
- if (errno == EAGAIN || errno == EWOULDBLOCK) return F_status_set_error(F_block);
- if (errno == EBADF) return F_status_set_error(F_file_descriptor);
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINTR) return F_status_set_error(F_interrupt);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
- if (errno == EIO) return F_status_set_error(F_input_output);
- if (errno == EISDIR) return F_status_set_error(F_file_type_directory);
-
return F_status_set_error(F_file_write);
}
* F_parameter (with error bit) if a parameter is invalid.
* F_space_not (with error bit) if file system is out of space (or file system quota is reached).
*
+ * @see close()
+ * @see fsync()
+ *
* @see f_file_close()
* @see f_file_copy()
* @see f_file_stream_close()
* F_supported_not if copying a given type of file is unsupported.
* F_failure (with error bit) for any other error.
*
+ * @see open()
+ *
* @see f_file_copy()
* @see f_file_clone()
*/
* F_space_not (with error bit) if file system is out of space (or file system quota is reached).
* F_failure (with error bit) for any other error.
*
+ * @see open()
+ *
* @see f_file_copy()
* @see f_file_create()
*/
* F_space_not (with error bit) if file system is out of space (or file system quota is reached).
* F_failure (with error bit) for any other error.
*
+ * @see openat()
+ *
* @see f_file_create_at()
*/
#if !defined(_di_f_file_create_at_)
* F_space_not (with error bit) if file system is out of space (or file system quota is reached).
* F_failure (with error bit) for any other error.
*
+ * @see mkdir()
+ *
* @see f_file_copy()
*/
#if !defined(_di_f_file_copy_)
* F_space_not (with error bit) if file system is out of space (or file system quota is reached).
* F_failure (with error bit) for any other error.
*
+ * @see mkdirat()
+ *
* @see f_file_copy_at()
*/
#if !defined(_di_f_file_copy_at_)
* F_supported_not (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
+ * @see mkfifo()
+ *
* @see f_file_create_fifo()
* @see f_file_copy()
*/
* F_supported_not (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
+ * @see mkfifoat()
+ *
* @see f_file_create_fifo_at()
* @see f_file_copy_at()
*/
* F_supported_not (with error bit) for unsupported file types.
* F_failure (with error bit) for any other error.
*
+ * @see mknod()
+ *
* @see f_file_copy()
* @see f_file_create_device()
* @see f_file_create_node()
* F_failure (with error bit) for any other error.
* F_supported_not (with error bit) for unsupported file types.
*
+ * @see mknodat()
+ *
* @see f_file_copy_at()
* @see f_file_create_device_at()
* @see f_file_create_node_at()
* F_supported_not (with error bit) if the file system or file type does not support flushing.
* F_file_synchronize (with error bit) on any other failure.
*
+ * @see fsync()
+ *
* @see f_file_close()
* @see f_file_copy()
* @see f_file_flush()
* F_read_only (with error bit) if file system is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see symlink()
+ *
* @see f_file_copy()
* @see f_file_link()
*/
* F_read_only (with error bit) if file system is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see symlinkat()
+ *
* @see f_file_link_at()
*/
#if !defined(_di_f_file_link_at_)
* F_string_too_large (with error bit) if link target path is too large for string buffer size.
* F_failure (with error bit) for any other error.
*
+ * @see readlink()
+ *
* @see f_file_copy()
* @see f_file_link_read()
* @see f_string_dynamic_increase_by()
* F_string_too_large (with error bit) if link target path is too large for string buffer size.
* F_failure (with error bit) for any other error.
*
+ * @see readlinkat()
+ *
* @see f_file_copy_at()
* @see f_file_link_read_at()
* @see f_string_dynamic_increase_by()
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see chmod()
+ *
* @see f_file_copy()
* @see f_file_mode_set()
*/
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see fchmodat()
+ *
* @see f_file_mode_set_at()
*/
#if !defined(_di_f_file_mode_set_at_)
* F_file_open (with error bit) if the file is already open.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see open()
+ *
* @see f_file_copy()
* @see f_file_open()
*/
* F_file_open (with error bit) if the file is already open.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see openat()
+ *
* @see f_file_open_at()
*/
#if !defined(_di_f_file_open_at_)
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see chown()
+ * @see lchown()
+ *
* @see f_file_copy()
* @see f_file_role_change()
*/
* F_read_only (with error bit) if file is read-only.
* F_failure (with error bit) for any other error.
*
+ * @see fchownat()
+ *
* @see f_file_role_change_at()
*/
#if !defined(_di_f_file_role_change_at_)
* F_number_overflow (with error bit) on overflow error.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see lstat()
+ * @see stat()
+ *
* @see f_file_copy()
* @see f_file_exists()
* @see f_file_is()
* F_number_overflow (with error bit) on overflow error.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see fstatat()
+ *
* @see f_file_stat_at()
* @see f_file_exists_at()
* @see f_file_touch_at()
* F_number_overflow (with error bit) on overflow error.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see fstat()
+ *
* @see f_file_size_by_id()
* @see f_file_stat_by_id()
*/
* F_none on success.
* F_none_stop on success but no data was written (written == 0) (not an error and often happens if file type is not a regular file).
*
- * F_block (with error bit) if file descriptor is set to non-block and the write would result in a blocking operation.
- * F_buffer (with error bit) if the buffer is invalid.
- * F_file (with error bit) if file descriptor is in an error state.
- * F_file_closed (with error bit) if file is not open.
- * F_file_descriptor (with error bit) if the file descriptor is invalid.
- * F_file_type_directory (with error bit) if file descriptor represents a directory.
- * F_input_output (with error bit) on I/O error.
- * F_interrupt (with error bit) if interrupt was received.
+ * F_file_write (with error bit) on error during file write.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see flockfile()
+ * @see fwrite_unlocked()
+ * @see funlockfile()
+ *
* @see f_file_stream_write()
* @see f_file_stream_write_block()
* @see f_file_stream_write_range()
* F_interrupt (with error bit) if interrupt was received.
* F_parameter (with error bit) if a parameter is invalid.
*
+ * @see write()
+ *
* @see f_file_write()
* @see f_file_write_block()
* @see f_file_write_range()