Add support for user-level 9P servers/clients and various bug fixes to go with them.
This commit is contained in:
parent
ac244f8d28
commit
32f69c36e0
60 changed files with 965 additions and 485 deletions
|
|
@ -214,92 +214,4 @@ erealloc(void *p, ulong n)
|
|||
return p;
|
||||
}
|
||||
|
||||
#if 0
|
||||
char *
|
||||
strdup(const char *s)
|
||||
{
|
||||
return strcpy(emalloc(strlen(s)), s);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
void exits(const char *s)
|
||||
{
|
||||
if (s) fprint(2, "exit: %s\n", s);
|
||||
exit(s != 0);
|
||||
}
|
||||
|
||||
void
|
||||
_exits(const char *s)
|
||||
{
|
||||
if (s) fprint(2, "exit: %s\n", s);
|
||||
_exit(s != 0);
|
||||
}
|
||||
|
||||
int errstr(char *buf, int size)
|
||||
{
|
||||
extern int errno;
|
||||
|
||||
snprint(buf, size, "%s", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
int
|
||||
create(char *name, int omode, ulong perm)
|
||||
{
|
||||
int mode;
|
||||
int fd;
|
||||
|
||||
if (omode & OWRITE) mode = O_WRONLY;
|
||||
else if (omode & OREAD) mode = O_RDONLY;
|
||||
else mode = O_RDWR;
|
||||
|
||||
if ((fd = open(name, mode|O_CREAT|O_TRUNC, perm)) < 0)
|
||||
return fd;
|
||||
|
||||
if (omode & OCEXEC)
|
||||
fcntl(fd, F_SETFD, fcntl(fd,F_GETFD,0) | FD_CLOEXEC);
|
||||
|
||||
/* SES - not exactly right, but hopefully good enough. */
|
||||
if (omode & ORCLOSE)
|
||||
remove(name);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* SHOULD BE ELSEWHERE */
|
||||
#if 0 /* needed on old __APPLE__ */
|
||||
#include <lib9.h>
|
||||
|
||||
Lock plk;
|
||||
|
||||
ulong
|
||||
pread(int fd, void *buf, ulong n, ulong off)
|
||||
{
|
||||
ulong rv;
|
||||
|
||||
lock(&plk);
|
||||
if (lseek(fd, off, 0) != off)
|
||||
return -1;
|
||||
rv = read(fd, buf, n);
|
||||
unlock(&plk);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
ulong
|
||||
pwrite(int fd, void *buf, ulong n, ulong off)
|
||||
{
|
||||
ulong rv;
|
||||
|
||||
lock(&plk);
|
||||
if (lseek(fd, off, 0) != off)
|
||||
return -1;
|
||||
rv = write(fd, buf, n);
|
||||
unlock(&plk);
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue