#include <string.h>
#include <errno.h>
#include "filedesc.h"
+#include "file.h"
struct file;
return(ret_val);
}
+
+/*
+ * fd_read() - Read data from a file descriptor
+ *
+ * SYNOPSIS
+ * ssize_t fd_read(struct filedesc *fd, void *dst, const size_t dst_size);
+ *
+ * DESCRIPTION
+ * The fd_read() function attempts to read up to `dst_size' bytes of data from the file
+ * descriptor pointed to by `fd' and writes it to the buffer pointed to by `dst'.
+ *
+ * This function is the abstract interface to the file-specific read function. For implementation
+ * details, please refer to the documentation of the more specific read function (for example
+ * _pipe_read() for pipes).
+ *
+ * RETURN VALUE
+ * Upon success, the number of bytes read is returned. Otherwise, a negative error number is
+ * returned.
+ *
+ * ERRORS
+ * For possible errors, please refer to the documentation of the read function for the respective
+ * file type.
+ */
+ssize_t fd_read(struct filedesc *fd, void *dst, const size_t dst_size)
+{
+ return(file_read(fd->fd_file, dst, dst_size));
+}
+
+/*
+ * fd_write() - Write data to a file descriptor
+ *
+ * SYNOPSIS
+ * ssize_t fd_write(struct filedesc *fd, const void *src, const size_t src_len);
+ *
+ * DESCRIPTION
+ * The fd_write() function attempts to write up to `src_len' bytes from the buffer pointed to by
+ * `src' and write that data to the file descriptor pointed to by `fd'.
+ *
+ * This function is the abstract interface to the file-specific write function. For
+ * implementation details, please refer to the documentation of the more specific write function
+ * (for example _pipe_write() for pipes).
+ *
+ * RETURN VALUE
+ * Upon success, the number of bytes read is returned. Otherwise a negative error number is
+ * returned.
+ *
+ * ERRORS
+ * For possible errors, please refer to the documentation of the write function for the
+ * respective file type.
+ */
+ssize_t fd_write(struct filedesc *fd, const void *src, const size_t src_len)
+{
+ return(file_write(fd->fd_file, src, src_len));
+}