Added stubs for pread(2) and pwrite(2).

These are not implemented yet because the current kernel design is bad.

However, I need the stubs for other code.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-24 15:23:07 +01:00
parent 757184fd5c
commit c62eb09cdc
4 changed files with 53 additions and 24 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
@ -21,7 +21,7 @@
The <unistd.h> 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);

View File

@ -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 <http://www.gnu.org/licenses/>.
@ -20,7 +20,7 @@
io.cpp
Functions for management of input and output.
******************************************************************************/
*******************************************************************************/
#include <libmaxsi/platform.h>
#include <libmaxsi/syscall.h>
@ -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);

View File

@ -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 <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
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

View File

@ -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 <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
io.cpp
Provides system calls for input and output.
******************************************************************************/
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include <libmaxsi/error.h>
@ -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);