Add fsync(2).
This commit is contained in:
parent
04a4564924
commit
f29abd73ec
|
@ -176,6 +176,7 @@ fsm_recv.o \
|
||||||
fsm_send.o \
|
fsm_send.o \
|
||||||
fstatat.o \
|
fstatat.o \
|
||||||
fstat.o \
|
fstat.o \
|
||||||
|
fsync.o \
|
||||||
ftruncate.o \
|
ftruncate.o \
|
||||||
getc.o \
|
getc.o \
|
||||||
getcwd.o \
|
getcwd.o \
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library 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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
fsync.cpp
|
||||||
|
Open a file relative to directory.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
DEFN_SYSCALL1(int, sys_fsync, SYSCALL_FSYNC, int);
|
||||||
|
|
||||||
|
extern "C" int fsync(int fd)
|
||||||
|
{
|
||||||
|
return sys_fsync(fd);
|
||||||
|
}
|
|
@ -93,7 +93,6 @@ void encrypt(char [64], int);
|
||||||
int fdatasync(int);
|
int fdatasync(int);
|
||||||
int fexecve(int, char* const [], char* const []);
|
int fexecve(int, char* const [], char* const []);
|
||||||
long fpathconf(int, int);
|
long fpathconf(int, int);
|
||||||
int fsync(int);
|
|
||||||
gid_t getegid(void);
|
gid_t getegid(void);
|
||||||
uid_t geteuid(void);
|
uid_t geteuid(void);
|
||||||
gid_t getgid(void);
|
gid_t getgid(void);
|
||||||
|
@ -155,6 +154,7 @@ int faccessat(int, const char*, int, int);
|
||||||
int fchdir(int);
|
int fchdir(int);
|
||||||
int fchown(int, uid_t, gid_t);
|
int fchown(int, uid_t, gid_t);
|
||||||
int fchownat(int, const char*, uid_t, gid_t, int);
|
int fchownat(int, const char*, uid_t, gid_t, int);
|
||||||
|
int fsync(int);
|
||||||
int ftruncate(int, off_t);
|
int ftruncate(int, off_t);
|
||||||
char* getcwd(char*, size_t);
|
char* getcwd(char*, size_t);
|
||||||
char* get_current_dir_name(void);
|
char* get_current_dir_name(void);
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
#define SYSCALL_PPOLL 72
|
#define SYSCALL_PPOLL 72
|
||||||
#define SYSCALL_RENAMEAT 73
|
#define SYSCALL_RENAMEAT 73
|
||||||
#define SYSCALL_READLINKAT 74
|
#define SYSCALL_READLINKAT 74
|
||||||
#define SYSCALL_MAX_NUM 75 /* index of highest constant + 1 */
|
#define SYSCALL_FSYNC 75
|
||||||
|
#define SYSCALL_MAX_NUM 76 /* index of highest constant + 1 */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -559,6 +559,15 @@ static ssize_t sys_readlinkat(int dirfd, const char* path, char* buf, size_t siz
|
||||||
return (int) desc->readlink(&ctx, buf, size);
|
return (int) desc->readlink(&ctx, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sys_fsync(int fd)
|
||||||
|
{
|
||||||
|
Ref<Descriptor> desc = CurrentProcess()->GetDescriptor(fd);
|
||||||
|
if ( !desc )
|
||||||
|
return -1;
|
||||||
|
ioctx_t ctx; SetupUserIOCtx(&ctx);
|
||||||
|
return desc->sync(&ctx);
|
||||||
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
Syscall::Register(SYSCALL_ACCESS, (void*) sys_access);
|
Syscall::Register(SYSCALL_ACCESS, (void*) sys_access);
|
||||||
|
@ -577,6 +586,7 @@ void Init()
|
||||||
Syscall::Register(SYSCALL_FCNTL, (void*) sys_fcntl);
|
Syscall::Register(SYSCALL_FCNTL, (void*) sys_fcntl);
|
||||||
Syscall::Register(SYSCALL_FSTATAT, (void*) sys_fstatat);
|
Syscall::Register(SYSCALL_FSTATAT, (void*) sys_fstatat);
|
||||||
Syscall::Register(SYSCALL_FSTAT, (void*) sys_fstat);
|
Syscall::Register(SYSCALL_FSTAT, (void*) sys_fstat);
|
||||||
|
Syscall::Register(SYSCALL_FSYNC, (void*) sys_fsync);
|
||||||
Syscall::Register(SYSCALL_FTRUNCATE, (void*) sys_ftruncate);
|
Syscall::Register(SYSCALL_FTRUNCATE, (void*) sys_ftruncate);
|
||||||
Syscall::Register(SYSCALL_GETTERMMODE, (void*) sys_gettermmode);
|
Syscall::Register(SYSCALL_GETTERMMODE, (void*) sys_gettermmode);
|
||||||
Syscall::Register(SYSCALL_ISATTY, (void*) sys_isatty);
|
Syscall::Register(SYSCALL_ISATTY, (void*) sys_isatty);
|
||||||
|
|
Loading…
Reference in New Issue