From b7c75fab5b4387779ab31dd4bdc2c6ca82bbb6f2 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 17 Jun 2005 11:43:24 +0000 Subject: [PATCH] Added dummy readlink() call that returns an error (we don't have symlinks yet) also select() stub --- lib/posix/Makefile | 4 ++++ lib/posix/_select.c | 46 +++++++++++++++++++++++++++++++++++++++----- lib/posix/readlink.c | 14 ++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 lib/posix/readlink.c diff --git a/lib/posix/Makefile b/lib/posix/Makefile index cd8f68f8b..64d2c27c9 100755 --- a/lib/posix/Makefile +++ b/lib/posix/Makefile @@ -97,6 +97,7 @@ OBJECTS = \ $(LIBRARY)(_write.o) \ $(LIBRARY)(gettimeofday.o) \ $(LIBRARY)(lstat.o) \ + $(LIBRARY)(readlink.o) \ $(LIBRARY)(symlink.o) \ $(LIBRARY): $(OBJECTS) @@ -370,6 +371,9 @@ $(LIBRARY)(_write.o): _write.c $(LIBRARY)(gettimeofday.o): gettimeofday.c $(CC1) gettimeofday.c +$(LIBRARY)(readlink.o): readlink.c + $(CC1) readlink.c + $(LIBRARY)(lstat.o): lstat.c $(CC1) lstat.c diff --git a/lib/posix/_select.c b/lib/posix/_select.c index 5d4cef4f1..d84808b40 100755 --- a/lib/posix/_select.c +++ b/lib/posix/_select.c @@ -8,11 +8,47 @@ PUBLIC int select(int nfds, { message m; - m.m8_i1 = nfds; - m.m8_p1 = (char *) readfds; - m.m8_p2 = (char *) writefds; - m.m8_p3 = (char *) errorfds; - m.m8_p4 = (char *) timeout; + m.SEL_NFDS = nfds; + m.SEL_READFDS = (char *) readfds; + m.SEL_WRITEFDS = (char *) writefds; + m.SEL_ERRORFDS = (char *) errorfds; + m.SEL_TIMEOUT = (char *) timeout; return (_syscall(FS, SELECT, &m)); } + +#define FD_BITMASK(b) (1L << ((b) % _FDSETBITSPERWORD)) +#define FD_BITWORD(b) ((b)/_FDSETBITSPERWORD) + +PUBLIC void FD_CLR(int fd, fd_set *fdset) +{ + if(fd < 0 || fd >= FD_SETSIZE) return; + fdset->_fdsetval[FD_BITWORD(fd)] &= ~(FD_BITMASK(fd)); + return; +} + +PUBLIC int FD_ISSET(int fd, fd_set *fdset) +{ + if(fd < 0 || fd >= FD_SETSIZE) + return 0; + if(fdset->_fdsetval[FD_BITWORD(fd)] & FD_BITMASK(fd)) + return 1; + return 0; +} + +PUBLIC void FD_SET(int fd, fd_set *fdset) +{ + if(fd < 0 || fd >= FD_SETSIZE) + return; + fdset->_fdsetval[FD_BITWORD(fd)] |= FD_BITMASK(fd); + return; +} + +PUBLIC void FD_ZERO(fd_set *fdset) +{ + int i; + for(i = 0; i < _FDSETWORDS; i++) + fdset->_fdsetval[i] = 0; + return; +} + diff --git a/lib/posix/readlink.c b/lib/posix/readlink.c new file mode 100644 index 000000000..819c7eee1 --- /dev/null +++ b/lib/posix/readlink.c @@ -0,0 +1,14 @@ +/* +readlink.c +*/ + +#define readlink _readlink + +#include +#include + +int readlink(const char *path, char *buf, int bufsiz) +{ + errno = EINVAL; /* "The named file is not a symbolic link" */ + return -1; +}