]> Zhao Yanbai Git Server - minix.git/commitdiff
Added truncate() and ftruncate() library calls (no FS support yet).
authorBen Gras <ben@minix3.org>
Tue, 20 Dec 2005 14:18:16 +0000 (14:18 +0000)
committerBen Gras <ben@minix3.org>
Tue, 20 Dec 2005 14:18:16 +0000 (14:18 +0000)
Added ELOOP message to errlist.

lib/ansi/errlist.c
lib/posix/Makefile
lib/posix/_truncate.c [new file with mode: 0755]
lib/syscall/Makefile
lib/syscall/truncate.s [new file with mode: 0755]

index f336b02aa664c67e589a880b21a56c8be47aad0a..69ede4e4a80d0d188835b1ba4ace20f2b10e477e 100755 (executable)
@@ -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 */
index 94bf96f7f7b21dbfc760dd389b775909dcefbd08..4ef614d9e034a9f11d91593cc2c7e6f4135f8d3c 100755 (executable)
@@ -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 (executable)
index 0000000..f939ea0
--- /dev/null
@@ -0,0 +1,22 @@
+#include <lib.h>
+#define truncate       _truncate
+#define ftruncate      _ftruncate
+#include <unistd.h>
+
+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));
+}
index db24d39b6ba9eb2f7c7771eb7b89b4eb29255996..b730d2bbe746d515bc6f1fd4be86ed03956991bf 100755 (executable)
@@ -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 (executable)
index 0000000..1915ad7
--- /dev/null
@@ -0,0 +1,13 @@
+.sect .text
+.extern        __truncate
+.extern        __ftruncate
+.define        _truncate
+.define        _ftruncate
+.align 2
+
+_truncate:
+       jmp     __truncate
+
+.align 2
+_ftruncate:
+       jmp     __ftruncate