Skip to content

Commit ec34eaf

Browse files
committed
Add fsync, ftruncate, truncate
Using: - sysLv2FsTruncate - sysLv2FsFtruncate - sysLv2FsFsync
1 parent 579ef1a commit ec34eaf

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

ppu/crt/crt1.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern int __librt_fstat_r(struct _reent *r,int fd,struct stat *st);
1414
extern int __librt_fstat64_r(struct _reent *r,int fd,struct stat *st);
1515
extern int __librt_stat_r(struct _reent *r,const char *path,struct stat *st);
1616
extern int __librt_stat64_r(struct _reent *r,const char *path,struct stat *st);
17+
extern int __librt_ftruncate_r(struct _reent *r,int fd,off_t len);
18+
extern int __librt_truncate_r(struct _reent *r,const char *path,off_t len);
19+
extern int __librt_fsync_r(struct _reent *r,int fd);
1720
extern _ssize_t __librt_read_r(struct _reent *r,int fd,void *ptr,size_t len);
1821
extern _ssize_t __librt_write_r(struct _reent *r,int fd,const void *ptr,size_t len);
1922
extern _off_t __librt_lseek_r(struct _reent *r,int fd,_off_t pos,int dir);
@@ -66,6 +69,9 @@ static void __syscalls_init(void)
6669
__syscalls.fstat64_r = __librt_fstat64_r;
6770
__syscalls.stat_r = __librt_stat_r;
6871
__syscalls.stat64_r = __librt_stat64_r;
72+
__syscalls.ftruncate_r = __librt_ftruncate_r;
73+
__syscalls.truncate_r = __librt_truncate_r;
74+
__syscalls.fsync_r = __librt_fsync_r;
6975
__syscalls.chmod_r = __librt_chmod_r;
7076
__syscalls.rename_r = __librt_rename_r;
7177
__syscalls.isatty_r = __librt_isatty_r;

ppu/librt/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ OBJS := \
4646
sbrk.o exit.o close.o lseek.o read.o open.o sleep.o write.o fstat.o \
4747
socket.o lock.o dirent.o mkdir.o times.o umask.o lv2errno.o heap.o \
4848
chmod.o rename.o rmdir.o isatty.o gettod.o settod.o unlink.o access.o \
49-
link.o
49+
link.o truncate.o fsync.o
5050

5151
all: ppu
5252

ppu/librt/fsync.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <_ansi.h>
2+
#include <_syslist.h>
3+
#include <sys/reent.h>
4+
#include <sys/errno.h>
5+
#include <sys/types.h>
6+
#include <sys/socket.h>
7+
#include <sys/lv2errno.h>
8+
9+
#include <sys/file.h>
10+
11+
int
12+
_DEFUN(__librt_fsync_r,(ptr,fd),
13+
struct _reent *ptr _AND
14+
int fd)
15+
{
16+
return lv2errno_r(ptr,sysLv2FsFsync(fd));
17+
}

ppu/librt/truncate.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
#include <fcntl.h>
3+
#include <_ansi.h>
4+
#include <_syslist.h>
5+
#include <sys/reent.h>
6+
#include <sys/errno.h>
7+
#include <sys/types.h>
8+
#include <sys/lv2errno.h>
9+
10+
#include <sys/file.h>
11+
12+
int
13+
_DEFUN(__librt_truncate_r,(r,path,len),
14+
struct _reent *r _AND
15+
const char *path _AND
16+
off_t len)
17+
{
18+
return lv2errno_r(r,sysLv2FsTruncate(path,len));
19+
}
20+
21+
int
22+
_DEFUN(__librt_ftruncate_r,(r,fd,len),
23+
struct _reent *r _AND
24+
int fd _AND
25+
off_t len)
26+
{
27+
return lv2errno_r(r,sysLv2FsFtruncate(fd,len));
28+
}

0 commit comments

Comments
 (0)