Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/unix/u9fs/cygwin.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* compatability layer for u9fs support on CYGWIN */
2
 
3
#include <unistd.h>
4
#include <errno.h>
5
 
6
ssize_t
7
pread(int fd, void *p, size_t n, off_t off)
8
{
9
	off_t ooff;
10
	int oerrno;
11
 
12
	if ((ooff  = lseek(fd, off, SEEK_SET)) == -1)
13
		return -1;
14
 
15
	n = read(fd, p, n);
16
 
17
	oerrno = errno;
18
	lseek(fd, ooff, SEEK_SET);
19
	errno = oerrno;
20
 
21
	return n;
22
}
23
 
24
ssize_t
25
pwrite(int fd, const void *p, size_t n, off_t off)
26
{
27
	off_t ooff;
28
	int oerrno;
29
 
30
	if ((ooff  = lseek(fd, off, SEEK_SET)) == -1)
31
		return -1;
32
 
33
	n = write(fd, p, n);
34
 
35
	oerrno = errno;
36
	lseek(fd, ooff, SEEK_SET);
37
	errno = oerrno;
38
 
39
	return n;
40
}
41
 
42
int
43
setreuid(int ruid, int euid)
44
{
45
	if (ruid != -1)
46
		if (setuid(ruid) == -1)
47
			return(-1);
48
	if (euid != -1)
49
		if (seteuid(euid) == -1)
50
			return(-1);
51
}
52
 
53
int
54
setregid(int rgid, int egid)
55
{
56
	if (rgid != -1)
57
		if (setgid(rgid) == -1)
58
			return(-1);
59
	if (egid != -1)
60
		if (setegid(egid) == -1)
61
			return(-1);
62
}