9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] u9fs:  pread pwrite setreuid setregid
@ 2002-12-05  9:17 steve.simon
  2002-12-05 10:00 ` Lucio De Re
  0 siblings, 1 reply; 4+ messages in thread
From: steve.simon @ 2002-12-05  9:17 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: compat.c --]
[-- Type: application/octet-stream, Size: 893 bytes --]

/* 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);
}

[-- Attachment #2: Type: text/plain, Size: 379 bytes --]

Hi,

Getting u9fs to compile under CYGWIN and its adged posix interface
I needed a four of shims functions:

ssize_t pread(int fd, void *p, size_t n, off_t off);
ssize_t pwrite(int fd, const void *p, size_t n, off_t off);
int setreuid(int ruid, int euid);
int setregid(int rgid, int egid);

Just in case this is usefull to somone else it is here attached.


-Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] u9fs:  pread pwrite setreuid setregid
  2002-12-05  9:17 [9fans] u9fs: pread pwrite setreuid setregid steve.simon
@ 2002-12-05 10:00 ` Lucio De Re
  0 siblings, 0 replies; 4+ messages in thread
From: Lucio De Re @ 2002-12-05 10:00 UTC (permalink / raw)
  To: 9fans

On Thu, Dec 05, 2002 at 09:17:15AM +0000, steve.simon@snellwilcox.com wrote:
>
> Just in case this is usefull to somone else it is here attached.
>
No, it isn't.  I think this is getting pretty twisted, but the tools,
in my opinion, ought to be in the distribution anyway :-)

++L


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] u9fs:  pread pwrite setreuid setregid
  2002-12-05 15:11 Russ Cox
@ 2002-12-05 15:33 ` Lucio De Re
  0 siblings, 0 replies; 4+ messages in thread
From: Lucio De Re @ 2002-12-05 15:33 UTC (permalink / raw)
  To: 9fans

On Thu, Dec 05, 2002 at 10:11:30AM -0500, Russ Cox wrote:
>
> >> Just in case this is usefull to somone else it is here attached.
> >>
> > No, it isn't.  I think this is getting pretty twisted, but the tools,
> > in my opinion, ought to be in the distribution anyway :-)
>
> I assume you were trying to say that it wasn't attached
> rather than trying to say that it wasn't useful.
> I see the attachment though, so I'm confused.
>
Yes, my copy of the message did not include the attachment.  No
idea why not, but I'll try to establish that.

> In any event, I've dropped it into /sys/src/cmd/unix/u9fs
> as cygwin.c.  Thanks to Steve.
>
My thanks too.  Sorry about the confusion.

++L


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] u9fs:  pread pwrite setreuid setregid
@ 2002-12-05 15:11 Russ Cox
  2002-12-05 15:33 ` Lucio De Re
  0 siblings, 1 reply; 4+ messages in thread
From: Russ Cox @ 2002-12-05 15:11 UTC (permalink / raw)
  To: 9fans

>> Just in case this is usefull to somone else it is here attached.
>>
> No, it isn't.  I think this is getting pretty twisted, but the tools,
> in my opinion, ought to be in the distribution anyway :-)

I assume you were trying to say that it wasn't attached
rather than trying to say that it wasn't useful.
I see the attachment though, so I'm confused.

In any event, I've dropped it into /sys/src/cmd/unix/u9fs
as cygwin.c.  Thanks to Steve.

Russ



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-12-05 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-05  9:17 [9fans] u9fs: pread pwrite setreuid setregid steve.simon
2002-12-05 10:00 ` Lucio De Re
2002-12-05 15:11 Russ Cox
2002-12-05 15:33 ` Lucio De Re

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).