Today's changes.
More changes.
This commit is contained in:
parent
cb27443abf
commit
8ad517944e
73 changed files with 2865 additions and 1293 deletions
|
|
@ -14,7 +14,7 @@ static struct {
|
|||
};
|
||||
|
||||
char*
|
||||
_p9translate(char *old)
|
||||
plan9translate(char *old)
|
||||
{
|
||||
char *new;
|
||||
int i, olen, nlen, len;
|
||||
|
|
@ -36,7 +36,7 @@ _p9translate(char *old)
|
|||
len = strlen(old)+nlen-olen;
|
||||
new = malloc(len+1);
|
||||
if(new == nil)
|
||||
return nil;
|
||||
return "<out of memory>";
|
||||
strcpy(new, replace[i].new);
|
||||
strcpy(new+nlen, old+olen);
|
||||
assert(strlen(new) == len);
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
#include <u.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
char *_p9translate(char*);
|
||||
|
||||
int
|
||||
p9access(char *xname, int what)
|
||||
{
|
||||
int ret;
|
||||
char *name;
|
||||
|
||||
if((name = _p9translate(xname)) == nil)
|
||||
return -1;
|
||||
ret = access(name, what);
|
||||
if(name != xname)
|
||||
free(name);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -40,7 +40,8 @@ p9announce(char *addr, char *dir)
|
|||
char *net;
|
||||
u32int host;
|
||||
int port, s;
|
||||
int n, sn;
|
||||
int n;
|
||||
socklen_t sn;
|
||||
struct sockaddr_in sa;
|
||||
struct sockaddr_un sun;
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ p9announce(char *addr, char *dir)
|
|||
if((s = socket(AF_INET, proto, 0)) < 0)
|
||||
return -1;
|
||||
sn = sizeof n;
|
||||
if(port && getsockopt(s, SOL_SOCKET, SO_TYPE, (char*)&n, &sn) >= 0
|
||||
if(port && getsockopt(s, SOL_SOCKET, SO_TYPE, (void*)&n, &sn) >= 0
|
||||
&& n == SOCK_STREAM){
|
||||
n = 1;
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&n, sizeof n);
|
||||
|
|
|
|||
|
|
@ -3,16 +3,10 @@
|
|||
#include <libc.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
extern char *_p9translate(char*);
|
||||
|
||||
int
|
||||
p9create(char *xpath, int mode, ulong perm)
|
||||
p9create(char *path, int mode, ulong perm)
|
||||
{
|
||||
int fd, cexec, umode, rclose;
|
||||
char *path;
|
||||
|
||||
if((path = _p9translate(xpath)) == nil)
|
||||
return -1;
|
||||
|
||||
cexec = mode&OCEXEC;
|
||||
rclose = mode&ORCLOSE;
|
||||
|
|
@ -48,7 +42,5 @@ out:
|
|||
if(rclose)
|
||||
remove(path);
|
||||
}
|
||||
if(path != xpath)
|
||||
free(path);
|
||||
return fd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ ct_numb(char *cp, int n)
|
|||
char*
|
||||
asctime(Tm *t)
|
||||
{
|
||||
int i;
|
||||
char *ncp;
|
||||
static char cbuf[30];
|
||||
|
||||
|
|
@ -32,6 +33,12 @@ asctime(Tm *t)
|
|||
ct_numb(cbuf+14, t->min+100);
|
||||
ct_numb(cbuf+17, t->sec+100);
|
||||
ncp = t->zone;
|
||||
for(i=0; i<3; i++)
|
||||
if(ncp[i] == 0)
|
||||
break;
|
||||
for(; i<3; i++)
|
||||
ncp[i] = '?';
|
||||
ncp = t->zone;
|
||||
cbuf[20] = *ncp++;
|
||||
cbuf[21] = *ncp++;
|
||||
cbuf[22] = *ncp;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <stdlib.h> /* setenv etc. */
|
||||
|
||||
#include <u.h>
|
||||
#include <stdlib.h> /* setenv etc. */
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
#include <time.h>
|
||||
|
|
@ -25,6 +24,8 @@ static Tm bigtm;
|
|||
static void
|
||||
tm2Tm(struct tm *tm, Tm *bigtm)
|
||||
{
|
||||
char *s;
|
||||
|
||||
memset(bigtm, 0, sizeof *bigtm);
|
||||
bigtm->sec = tm->tm_sec;
|
||||
bigtm->min = tm->tm_min;
|
||||
|
|
@ -39,6 +40,13 @@ tm2Tm(struct tm *tm, Tm *bigtm)
|
|||
#ifdef _HAVETZOFF
|
||||
bigtm->tzoff = tm->tm_gmtoff;
|
||||
#endif
|
||||
if(bigtm->zone[0] == 0){
|
||||
s = getenv("TIMEZONE");
|
||||
if(s){
|
||||
strecpy(bigtm->zone, bigtm->zone+4, tm->tm_zone);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ mygetdents(int fd, struct dirent *buf, int n)
|
|||
nn = getdirentries(fd, (void*)buf, n, &off);
|
||||
return nn;
|
||||
}
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
static int
|
||||
mygetdents(int fd, struct dirent *buf, int n)
|
||||
{
|
||||
|
|
@ -171,7 +171,7 @@ dirreadall(int fd, Dir **d)
|
|||
ts += n;
|
||||
}
|
||||
if(ts >= 0)
|
||||
ts = dirpackage(fd, buf, ts, d);
|
||||
ts = dirpackage(fd, (char*)buf, ts, d);
|
||||
free(buf);
|
||||
if(ts == 0 && n < 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@
|
|||
* okay.
|
||||
*/
|
||||
|
||||
#include <u.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <lib9.h>
|
||||
#include <libc.h>
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
|||
1
src/lib9/ffork-OpenBSD.c
Normal file
1
src/lib9/ffork-OpenBSD.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "ffork-pthread.c"
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
#include <pwd.h>
|
||||
|
||||
#include <u.h>
|
||||
#include <pwd.h>
|
||||
#include <libc.h>
|
||||
|
||||
char*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <u.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <lib9.h>
|
||||
#include <libc.h>
|
||||
|
||||
int _ntas;
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <u.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <lib9.h>
|
||||
#include <libc.h>
|
||||
|
||||
void*
|
||||
mallocz(unsigned long n, int clr)
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ LIB9OFILES=\
|
|||
_p9dialparse.$O\
|
||||
_p9dir.$O\
|
||||
_p9proc.$O\
|
||||
_p9translate.$O\
|
||||
access.$O\
|
||||
announce.$O\
|
||||
argv0.$O\
|
||||
atexit.$O\
|
||||
|
|
@ -100,6 +98,7 @@ LIB9OFILES=\
|
|||
exec.$O\
|
||||
fcallfmt.$O\
|
||||
ffork-$SYSNAME.$O\
|
||||
get9root.$O\
|
||||
getcallerpc-$OBJTYPE.$O\
|
||||
getenv.$O\
|
||||
getfields.$O\
|
||||
|
|
@ -142,6 +141,7 @@ LIB9OFILES=\
|
|||
u16.$O\
|
||||
u32.$O\
|
||||
u64.$O\
|
||||
unsharp.$O\
|
||||
wait.$O\
|
||||
waitpid.$O\
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <signal.h>
|
||||
|
||||
#include <u.h>
|
||||
#include <signal.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
#include "9proc.h"
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@
|
|||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
extern char* _p9translate(char*);
|
||||
|
||||
int
|
||||
p9open(char *xname, int mode)
|
||||
p9open(char *name, int mode)
|
||||
{
|
||||
char *name;
|
||||
int cexec, rclose;
|
||||
int fd, umode;
|
||||
|
||||
|
|
@ -23,8 +20,6 @@ p9open(char *xname, int mode)
|
|||
werrstr("mode not supported");
|
||||
return -1;
|
||||
}
|
||||
if((name = _p9translate(xname)) == nil)
|
||||
return -1;
|
||||
fd = open(name, umode);
|
||||
if(fd >= 0){
|
||||
if(cexec)
|
||||
|
|
@ -32,7 +27,5 @@ p9open(char *xname, int mode)
|
|||
if(rclose)
|
||||
remove(name);
|
||||
}
|
||||
if(name != xname)
|
||||
free(name);
|
||||
return fd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
/* Could use futex(2) here instead of signals? */
|
||||
|
||||
#include "rendez-signal.c"
|
||||
|
|
|
|||
1
src/lib9/rendez-OpenBSD.c
Normal file
1
src/lib9/rendez-OpenBSD.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "rendez-signal.c"
|
||||
|
|
@ -32,9 +32,10 @@
|
|||
* shared memory and mutexes.
|
||||
*/
|
||||
|
||||
#include <u.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <lib9.h>
|
||||
#include <libc.h>
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <u.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue