diff --git a/sys/include/posix_io.h b/sys/include/posix_io.h deleted file mode 100644 index 0f4e998b4..000000000 --- a/sys/include/posix_io.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2013 INRIA. - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup posix - * @{ - * @file - * @brief POSIX-like IO - * - * @author Kaspar Schleiser - * @author Stephan Zeisberg - * @author Oliver Hahm - * @author Martine Lenders - */ -#ifndef __READ_H -#define __READ_H - -#include "kernel_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define OPEN 0 -#define CLOSE 1 -#define READ 2 -#define WRITE 3 - -/** - * @brief POSIX IO ringbuffer - */ -struct posix_iop_t { - /** number of bytes */ - int nbytes; - /** array for the ringbuffer */ - char *buffer; -}; - -/** - * @brief Opens a file descriptor - represented by a corresponding thread - * - * @param[in] pid The thread managing the fd to open - * @param[in] flags Access modes - * - * @return 0 on success - * @return a negative value in error case - */ -int posix_open(int pid, int flags); - -/** - * @brief Closes an open file descriptor - * - * @param[in] pid The opened thread - * - * @return 0 on success - * @return a negative value in error case - */ -int posix_close(int pid); - -/** - * @brief Reads from an open file descriptor - * - * @param[in] pid The thread managing the open fd - * @param[out] buffer Buffer to fill - * @param[in] bufsize Read up to that many bytes into @p buffer - * - * @return the number of read bytes - */ -int posix_read(int pid, char *buffer, int bufsize); - -/** - * @brief Writes to an open file descriptor - * - * @param[in] pid The thread managing the open fd - * @param[in] buffer Buffer to write - * @param[in] bufsize Write that many bytes from @p buffer - * - * @return the number of written bytes - */ -int posix_write(int pid, char *buffer, int bufsize); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif /* __READ_H */ diff --git a/sys/posix/fd.c b/sys/posix/fd.c index 9a1580e73..391e4eca9 100644 --- a/sys/posix/fd.c +++ b/sys/posix/fd.c @@ -20,7 +20,6 @@ #include #include -#include "posix_io.h" #include "unistd.h" #include "fd.h" diff --git a/sys/posix/posix_io.c b/sys/posix/posix_io.c deleted file mode 100644 index d67ee6c55..000000000 --- a/sys/posix/posix_io.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * POSIX implementation of basic IO operations. - * - * Copyright (C) 2013, INRIA. - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - * - * @ingroup sys_posix - * @{ - * @file - * @brief Implementation of basic POSIX IO functionality. - * @author Kaspar Schleiser - * @} - */ - -#include "thread.h" -#include "msg.h" - -#include "posix_io.h" - - -static int _posix_fileop(kernel_pid_t pid, int op, int flags) -{ - msg_t m; - m.type = op; - m.content.value = flags; - msg_send_receive(&m, &m, pid); - return m.content.value; -} - -static int _posix_fileop_data(kernel_pid_t pid, int op, char *buffer, int nbytes) -{ - struct posix_iop_t r; - r.nbytes = nbytes; - r.buffer = buffer; - - msg_t m; - m.type = op; - m.content.ptr = (char *) &r; - - msg_send_receive(&m, &m, pid); - - return r.nbytes; -} - -int posix_open(int pid, int flags) -{ - if (pid == KERNEL_PID_UNDEF) { - return -1; - } - return _posix_fileop((kernel_pid_t) pid, OPEN, flags); -} - -int posix_close(int pid) -{ - return _posix_fileop((kernel_pid_t) pid, CLOSE, 0); -} - -int posix_read(int pid, char *buffer, int bufsize) -{ - return _posix_fileop_data((kernel_pid_t) pid, READ, buffer, bufsize); -} - -int posix_write(int pid, char *buffer, int bufsize) -{ - return _posix_fileop_data((kernel_pid_t) pid, WRITE, buffer, bufsize); -}