Added stubs for truncate(2) and ftruncate(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2012-01-14 16:37:21 +01:00
parent 0519af33ee
commit 56084556bb
4 changed files with 33 additions and 3 deletions

View File

@ -102,7 +102,6 @@ int fdatasync(int);
int fexecve(int, char* const [], char* const []);
long fpathconf(int, int);
int fsync(int);
int ftruncate(int, off_t);
gid_t getegid(void);
uid_t geteuid(void);
gid_t getgid(void);
@ -142,7 +141,6 @@ void sync(void);
long sysconf(int);
pid_t tcgetpgrp(int);
int tcsetpgrp(int, pid_t);
int truncate(const char*, off_t);
char* ttyname(int);
int ttyname_r(int, char*, size_t);
int unlinkat(int, const char*, int);
@ -160,6 +158,7 @@ int close(int);
int dup(int);
void _exit(int);
pid_t fork(void);
int ftruncate(int, off_t);
char* getcwd(char*, size_t);
pid_t getpid(void);
pid_t getppid(void);
@ -169,6 +168,7 @@ int pipe(int [2]);
ssize_t read(int, void*, size_t);
int rmdir(const char*);
unsigned sleep(unsigned);
int truncate(const char*, off_t);
#if __POSIX_OBSOLETE <= 200112 || defined(SORTIX_EXTENSIONS)
int usleep(useconds_t useconds);
#endif

View File

@ -53,6 +53,8 @@ namespace Maxsi
DEFN_SYSCALL3_VOID(SysSeek, SYSCALL_SEEK, int, off_t*, int);
DEFN_SYSCALL2(int, SysMkDir, SYSCALL_MKDIR, const char*, mode_t);
DEFN_SYSCALL1(int, SysRmDir, SYSCALL_RMDIR, const char*);
DEFN_SYSCALL2(int, SysTruncate, SYSCALL_TRUNCATE, const char*, off_t);
DEFN_SYSCALL2(int, SysFTruncate, SYSCALL_FTRUNCATE, int, off_t);
size_t Print(const char* string)
{
@ -268,6 +270,16 @@ namespace Maxsi
return SysRmDir(pathname);
}
extern "C" int truncate(const char* pathname, off_t length)
{
return SysTruncate(pathname, length);
}
extern "C" int ftruncate(int fd, off_t length)
{
return SysFTruncate(fd, length);
}
extern "C" int isatty(int fd)
{
return SysIsATTY(fd);

View File

@ -97,12 +97,28 @@ namespace Sortix
return -1;
}
int SysTruncate(const char* pathname, off_t length)
{
// TODO: Add the proper filesystem support!
Error::Set(ENOSYS);
return -1;
}
int SysFTruncate(const char* pathname, off_t length)
{
// TODO: Add the proper filesystem support!
Error::Set(ENOSYS);
return -1;
}
void Init()
{
Syscall::Register(SYSCALL_OPEN, (void*) SysOpen);
Syscall::Register(SYSCALL_UNLINK, (void*) SysUnlink);
Syscall::Register(SYSCALL_MKDIR, (void*) SysMkDir);
Syscall::Register(SYSCALL_RMDIR, (void*) SysRmDir);
Syscall::Register(SYSCALL_TRUNCATE, (void*) SysTruncate);
Syscall::Register(SYSCALL_FTRUNCATE, (void*) SysFTruncate);
}
}

View File

@ -65,7 +65,9 @@
#define SYSCALL_GET_PAGE_SIZE 37
#define SYSCALL_MKDIR 38
#define SYSCALL_RMDIR 39
#define SYSCALL_MAX_NUM 40 /* index of highest constant + 1 */
#define SYSCALL_TRUNCATE 40
#define SYSCALL_FTRUNCATE 41
#define SYSCALL_MAX_NUM 42 /* index of highest constant + 1 */
#endif