diff --git a/libmaxsi/include/unistd.h b/libmaxsi/include/unistd.h index c1252cf8..00e1738c 100644 --- a/libmaxsi/include/unistd.h +++ b/libmaxsi/include/unistd.h @@ -1,6 +1,6 @@ -/****************************************************************************** +/******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. + COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012. This file is part of LibMaxsi. @@ -11,8 +11,8 @@ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for - more details. + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. You should have received a copy of the GNU Lesser General Public License along with LibMaxsi. If not, see . @@ -21,7 +21,7 @@ The header defines miscellaneous symbolic constants and types, and declares miscellaneous functions. -******************************************************************************/ +*******************************************************************************/ /* TODO: POSIX-1.2008 compliance is only partial */ @@ -119,8 +119,6 @@ int lockf(int, int, off_t); int nice(int); long pathconf(const char*, int); int pause(void); -ssize_t pread(int, void*, size_t, off_t); -ssize_t pwrite(int, const void*, size_t, off_t); ssize_t readlink(const char* restrict, char* restrict, size_t); ssize_t readlinkat(int, const char* restrict, char* restrict, size_t); int setegid(gid_t); @@ -165,6 +163,8 @@ pid_t getppid(void); int isatty(int); off_t lseek(int, off_t, int); int pipe(int [2]); +ssize_t pread(int, void*, size_t, off_t); +ssize_t pwrite(int, const void*, size_t, off_t); ssize_t read(int, void*, size_t); int rmdir(const char*); unsigned sleep(unsigned); diff --git a/libmaxsi/io.cpp b/libmaxsi/io.cpp index 9f42b8c5..5c768567 100644 --- a/libmaxsi/io.cpp +++ b/libmaxsi/io.cpp @@ -1,6 +1,6 @@ -/****************************************************************************** +/******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. + COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012. This file is part of LibMaxsi. @@ -11,8 +11,8 @@ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for - more details. + FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + details. You should have received a copy of the GNU Lesser General Public License along with LibMaxsi. If not, see . @@ -20,7 +20,7 @@ io.cpp Functions for management of input and output. -******************************************************************************/ +*******************************************************************************/ #include #include @@ -242,6 +242,18 @@ retry: return 0; } + extern "C" ssize_t pread(int, void*, size_t, off_t) + { + errno = ENOSYS; + return -1; + } + + extern "C" ssize_t pwrite(int, const void*, size_t, off_t) + { + errno = ENOSYS; + return -1; + } + extern "C" off_t lseek(int fd, off_t offset, int whence) { SysSeek(fd, &offset, whence); diff --git a/sortix/include/sortix/syscallnum.h b/sortix/include/sortix/syscallnum.h index ccd1c4ba..f88e4e1d 100644 --- a/sortix/include/sortix/syscallnum.h +++ b/sortix/include/sortix/syscallnum.h @@ -1,6 +1,6 @@ -/****************************************************************************** +/******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. + COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012. This file is part of Sortix. @@ -14,13 +14,12 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Sortix. If not, see . - + You should have received a copy of the GNU General Public License along with + Sortix. If not, see . syscallnum.h Stores numerical constants for each available system call on this kernel. -******************************************************************************/ +*******************************************************************************/ #ifndef SORTIX_SYSCALLNUM_H #define SORTIX_SYSCALLNUM_H @@ -73,7 +72,9 @@ #define SYSCALL_FCNTL 46 #define SYSCALL_ACCESS 47 #define SYSCALL_KERNELINFO 48 -#define SYSCALL_MAX_NUM 49 /* index of highest constant + 1 */ +#define SYSCALL_PREAD 49 +#define SYSCALL_PWRITE 50 +#define SYSCALL_MAX_NUM 51 /* index of highest constant + 1 */ #endif diff --git a/sortix/io.cpp b/sortix/io.cpp index d9db489b..2864fe8d 100644 --- a/sortix/io.cpp +++ b/sortix/io.cpp @@ -1,6 +1,6 @@ -/****************************************************************************** +/******************************************************************************* - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. + COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012. This file is part of Sortix. @@ -14,13 +14,13 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with Sortix. If not, see . + You should have received a copy of the GNU General Public License along with + Sortix. If not, see . io.cpp Provides system calls for input and output. -******************************************************************************/ +*******************************************************************************/ #include #include @@ -78,6 +78,13 @@ namespace Sortix return 0; } + // TODO: Not implemented yet due to stupid internal kernel design. + ssize_t SysPWrite(int fd, const byte* buffer, size_t count, off_t off) + { + Error::Set(ENOSYS); + return -1; + } + struct SysRead_t { union { size_t align1; int fd; }; @@ -118,6 +125,13 @@ namespace Sortix return 0; } + // TODO: Not implemented yet due to stupid internal kernel design. + ssize_t SysPRead(int fd, byte* buffer, size_t count, off_t off) + { + Error::Set(ENOSYS); + return -1; + } + void SysSeek(int fd, off_t* offset, int whence) { // TODO: Validate that offset is a legal user-space off_t! @@ -160,7 +174,9 @@ namespace Sortix void Init() { Syscall::Register(SYSCALL_WRITE, (void*) SysWrite); + Syscall::Register(SYSCALL_PWRITE, (void*) SysPWrite); Syscall::Register(SYSCALL_READ, (void*) SysRead); + Syscall::Register(SYSCALL_PREAD, (void*) SysPRead); Syscall::Register(SYSCALL_CLOSE, (void*) SysClose); Syscall::Register(SYSCALL_DUP, (void*) SysDup); Syscall::Register(SYSCALL_SEEK, (void*) SysSeek);