diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/unix/u9fs/cygwin.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/unix/u9fs/cygwin.c')
-rwxr-xr-x | sys/src/cmd/unix/u9fs/cygwin.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sys/src/cmd/unix/u9fs/cygwin.c b/sys/src/cmd/unix/u9fs/cygwin.c new file mode 100755 index 000000000..773d02cfb --- /dev/null +++ b/sys/src/cmd/unix/u9fs/cygwin.c @@ -0,0 +1,62 @@ +/* compatability layer for u9fs support on CYGWIN */ + +#include <unistd.h> +#include <errno.h> + +ssize_t +pread(int fd, void *p, size_t n, off_t off) +{ + off_t ooff; + int oerrno; + + if ((ooff = lseek(fd, off, SEEK_SET)) == -1) + return -1; + + n = read(fd, p, n); + + oerrno = errno; + lseek(fd, ooff, SEEK_SET); + errno = oerrno; + + return n; +} + +ssize_t +pwrite(int fd, const void *p, size_t n, off_t off) +{ + off_t ooff; + int oerrno; + + if ((ooff = lseek(fd, off, SEEK_SET)) == -1) + return -1; + + n = write(fd, p, n); + + oerrno = errno; + lseek(fd, ooff, SEEK_SET); + errno = oerrno; + + return n; +} + +int +setreuid(int ruid, int euid) +{ + if (ruid != -1) + if (setuid(ruid) == -1) + return(-1); + if (euid != -1) + if (seteuid(euid) == -1) + return(-1); +} + +int +setregid(int rgid, int egid) +{ + if (rgid != -1) + if (setgid(rgid) == -1) + return(-1); + if (egid != -1) + if (setegid(egid) == -1) + return(-1); +} |