From: Ben Gras Date: Tue, 20 Dec 2005 14:18:16 +0000 (+0000) Subject: Added truncate() and ftruncate() library calls (no FS support yet). X-Git-Tag: v3.1.2a~469 X-Git-Url: http://zhaoyanbai.com/repos/%22https:/www.google.com/jsapi/static/mdoc.3.html?a=commitdiff_plain;h=ffe192724ea1e4877610e7843576b8a12c9961f2;p=minix.git Added truncate() and ftruncate() library calls (no FS support yet). Added ELOOP message to errlist. --- diff --git a/lib/ansi/errlist.c b/lib/ansi/errlist.c index f336b02aa..69ede4e4a 100755 --- a/lib/ansi/errlist.c +++ b/lib/ansi/errlist.c @@ -49,7 +49,7 @@ const char *_sys_errlist[] = { "No locks available", /* ENOLCK */ "Function not implemented", /* ENOSYS */ "Directory not empty", /* ENOTEMPTY */ - unknown, /* 40 */ + "Too many levels of symbolic links", /* ELOOP */ unknown, /* 41 */ unknown, /* 42 */ unknown, /* 43 */ diff --git a/lib/posix/Makefile b/lib/posix/Makefile index 94bf96f7f..4ef614d9e 100755 --- a/lib/posix/Makefile +++ b/lib/posix/Makefile @@ -47,6 +47,7 @@ libc_OBJECTS = \ _kill.o \ _link.o \ _lseek.o \ + _lstat.o \ _mkdir.o \ _mkfifo.o \ _mknod.o \ @@ -62,6 +63,7 @@ libc_OBJECTS = \ _rename.o \ _rewinddir.o \ _rmdir.o \ + _readlink.o \ _select.o \ _setgid.o \ _setsid.o \ @@ -76,6 +78,7 @@ libc_OBJECTS = \ _sleep.o \ _stat.o \ _stime.o \ + _symlink.o \ _sync.o \ _tcdrain.o \ _tcflow.o \ @@ -85,6 +88,7 @@ libc_OBJECTS = \ _tcsetattr.o \ _time.o \ _times.o \ + _truncate.o \ _umask.o \ _umount.o \ _uname.o \ @@ -93,14 +97,11 @@ libc_OBJECTS = \ _wait.o \ _waitpid.o \ _write.o \ - gettimeofday.o \ + getloadavg.o \ getopt.o \ - _lstat.o \ + gettimeofday.o \ priority.o \ - _readlink.o \ - _symlink.o \ usleep.o \ - getloadavg.o include ../Makefile.inc diff --git a/lib/posix/_truncate.c b/lib/posix/_truncate.c new file mode 100755 index 000000000..f939ea0b4 --- /dev/null +++ b/lib/posix/_truncate.c @@ -0,0 +1,22 @@ +#include +#define truncate _truncate +#define ftruncate _ftruncate +#include + +PUBLIC int truncate(const char *_path, off_t _length) +{ + message m; + m.m1_p1 = (char *) _path; + m.m1_i1 = _length; + + return(_syscall(FS, TRUNCATE, &m)); +} + +PUBLIC int ftruncate(int _fd, off_t _length) +{ + message m; + m.m1_i2 = _fd; + m.m1_i1 = _length; + + return(_syscall(FS, FTRUNCATE, &m)); +} diff --git a/lib/syscall/Makefile b/lib/syscall/Makefile index db24d39b6..b730d2bbe 100755 --- a/lib/syscall/Makefile +++ b/lib/syscall/Makefile @@ -101,6 +101,7 @@ libc_OBJECTS = \ tcsetattr.o \ time.o \ times.o \ + truncate.o \ umask.o \ umount.o \ uname.o \ diff --git a/lib/syscall/truncate.s b/lib/syscall/truncate.s new file mode 100755 index 000000000..1915ad785 --- /dev/null +++ b/lib/syscall/truncate.s @@ -0,0 +1,13 @@ +.sect .text +.extern __truncate +.extern __ftruncate +.define _truncate +.define _ftruncate +.align 2 + +_truncate: + jmp __truncate + +.align 2 +_ftruncate: + jmp __ftruncate