Annoying changes to work on Sun boxes.
This commit is contained in:
parent
50e628cb8f
commit
1c253ceb58
19 changed files with 95 additions and 54 deletions
|
|
@ -1,9 +1,9 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
||||
static char *nets[] = { "tcp", "udp", nil };
|
||||
#define CLASS(p) ((*(uchar*)(p))>>6)
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ _p9dialparse(char *addr, char **pnet, char **punix, u32int *phost, int *pport)
|
|||
int i;
|
||||
struct servent *se;
|
||||
struct hostent *he;
|
||||
struct sockaddr_un *sun;
|
||||
struct sockaddr_un *sockun;
|
||||
|
||||
if(strncmp(addr, "/net/", 5) == 0)
|
||||
addr += 5;
|
||||
|
|
@ -73,7 +73,7 @@ _p9dialparse(char *addr, char **pnet, char **punix, u32int *phost, int *pport)
|
|||
if((port = strchr(host, '!')) == nil){
|
||||
if(strcmp(net, "unix")==0 || strcmp(net, "net")==0){
|
||||
Unix:
|
||||
if(strlen(host)+1 > sizeof sun->sun_path){
|
||||
if(strlen(host)+1 > sizeof sockun->sun_path){
|
||||
werrstr("unix socket name too long");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
#include <u.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef _HAVEDISKLABEL
|
||||
#include <sys/disklabel.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include <u.h>
|
||||
#define NOPLAN9DEFINES
|
||||
#include <libc.h>
|
||||
|
||||
int
|
||||
_p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
|
||||
{
|
||||
|
|
@ -83,7 +85,9 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
|
|||
|
||||
d->muid = "";
|
||||
d->qid.path = ((uvlong)st->st_dev<<32) | st->st_ino;
|
||||
#ifdef _HAVESTGEN
|
||||
d->qid.vers = st->st_gen;
|
||||
#endif
|
||||
d->mode = st->st_mode&0777;
|
||||
d->atime = st->st_atime;
|
||||
d->mtime = st->st_mtime;
|
||||
|
|
@ -96,6 +100,7 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
|
|||
}
|
||||
|
||||
/* fetch real size for disks */
|
||||
#ifdef _HAVEDISKLABEL
|
||||
if(S_ISCHR(st->st_mode)){
|
||||
int fd, n;
|
||||
struct disklabel lab;
|
||||
|
|
@ -114,6 +119,7 @@ _p9dir(struct stat *st, char *name, Dir *d, char **str, char *estr)
|
|||
if(fd >= 0)
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return sz;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#undef sun
|
||||
#define sun sockun
|
||||
extern int _p9dialparse(char*, char**, char**, u32int*, int*);
|
||||
|
||||
static int
|
||||
|
|
@ -88,7 +90,6 @@ print("announce dir: %s\n", dir);
|
|||
Unix:
|
||||
memset(&sun, 0, sizeof sun);
|
||||
sun.sun_family = AF_UNIX;
|
||||
sun.sun_len = sizeof sun;
|
||||
strcpy(sun.sun_path, unix);
|
||||
if((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ static struct {
|
|||
SIGVTALRM, "sys: virtual time alarm",
|
||||
SIGPROF, "sys: profiling timer alarm",
|
||||
SIGWINCH, "sys: window size change",
|
||||
#ifdef SIGINFO
|
||||
SIGINFO, "sys: status request",
|
||||
#endif
|
||||
SIGUSR1, "sys: usr1",
|
||||
SIGUSR2, "sys: usr2",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,8 +25,12 @@ tm2Tm(struct tm *tm, Tm *bigtm)
|
|||
bigtm->mon = tm->tm_mon;
|
||||
bigtm->year = tm->tm_year;
|
||||
bigtm->wday = tm->tm_wday;
|
||||
#ifdef _HAVETMZONE
|
||||
strecpy(bigtm->zone, bigtm->zone+4, tm->tm_zone);
|
||||
#endif
|
||||
#ifdef _HAVETZOFF
|
||||
bigtm->tzoff = tm->tm_gmtoff;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -40,8 +44,12 @@ Tm2tm(Tm *bigtm, struct tm *tm)
|
|||
tm->tm_mon = bigtm->mon;
|
||||
tm->tm_year = bigtm->year;
|
||||
tm->tm_wday = bigtm->wday;
|
||||
#ifdef _HAVETMZONE
|
||||
tm->tm_zone = bigtm->zone;
|
||||
#endif
|
||||
#ifdef _HAVETZOFF
|
||||
tm->tm_gmtoff = bigtm->tzoff;
|
||||
#endif
|
||||
}
|
||||
|
||||
Tm*
|
||||
|
|
@ -64,6 +72,14 @@ p9localtime(long t)
|
|||
return &bigtm;
|
||||
}
|
||||
|
||||
#if !defined(_HAVETIMEGM) && defined(_HAVETIMEZONEINT)
|
||||
static long
|
||||
timegm(struct tm *tm)
|
||||
{
|
||||
return mktime(tm)-timezone;
|
||||
}
|
||||
#endif
|
||||
|
||||
long
|
||||
p9tm2sec(Tm *bigtm)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ p9dial(char *addr, char *dummy1, char *dummy2, int *dummy3)
|
|||
|
||||
Unix:
|
||||
memset(&su, 0, sizeof su);
|
||||
su.sun_len = sizeof su;
|
||||
su.sun_family = AF_UNIX;
|
||||
if(strlen(unix)+1 > sizeof su.sun_path){
|
||||
werrstr("unix socket name too long");
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
#include <sys/time.h>
|
||||
|
||||
#if !defined(_HAVEFUTIMES) && defined(_HAVEFUTIMESAT)
|
||||
static int
|
||||
futimes(int fd, struct timeval *tv)
|
||||
{
|
||||
return futimesat(fd, 0, tv);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
dirfwstat(int fd, Dir *dir)
|
||||
{
|
||||
|
|
@ -19,3 +27,4 @@ dirfwstat(int fd, Dir *dir)
|
|||
tv[1].tv_usec = 0;
|
||||
return futimes(fd, tv);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ countde(char *p, int n)
|
|||
de = (struct dirent*)p;
|
||||
if(de->d_reclen <= 4+2+2+1 || p+de->d_reclen > e)
|
||||
break;
|
||||
if(de->d_namlen == 1 && de->d_name[0]=='.')
|
||||
de->d_namlen = 0;
|
||||
else if(de->d_namlen == 2 && de->d_name[0]=='.' && de->d_name[1]=='.')
|
||||
de->d_namlen = 0;
|
||||
if(de->d_name[0]=='.' && de->d_name[1]==0)
|
||||
de->d_name[0] = 0;
|
||||
else if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0)
|
||||
de->d_name[0] = 0;
|
||||
else
|
||||
m++;
|
||||
p += de->d_reclen;
|
||||
|
|
@ -59,7 +59,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
|
|||
for(i=0; i<n; i++){
|
||||
de = (struct dirent*)p;
|
||||
if(stat(de->d_name, &st) < 0)
|
||||
de->d_namlen = 0;
|
||||
de->d_name[0] = 0;
|
||||
else
|
||||
nstr += _p9dir(&st, de->d_name, nil, nil, nil);
|
||||
p += de->d_reclen;
|
||||
|
|
@ -78,7 +78,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
|
|||
m = 0;
|
||||
for(i=0; i<n; i++){
|
||||
de = (struct dirent*)p;
|
||||
if(de->d_namlen != 0 && stat(de->d_name, &st) >= 0)
|
||||
if(de->d_name[0] != 0 && stat(de->d_name, &st) >= 0)
|
||||
_p9dir(&st, de->d_name, &d[m++], &str, estr);
|
||||
p += de->d_reclen;
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ dirread(int fd, Dir **dp)
|
|||
if(buf == nil)
|
||||
return -1;
|
||||
|
||||
n = getdents(fd, buf, st.st_blksize);
|
||||
n = getdents(fd, (struct dirent*)buf, st.st_blksize);
|
||||
if(n < 0){
|
||||
free(buf);
|
||||
return -1;
|
||||
|
|
@ -141,7 +141,7 @@ dirreadall(int fd, Dir **d)
|
|||
return -1;
|
||||
}
|
||||
buf = nbuf;
|
||||
n = getdents(fd, buf+ts, st.st_blksize);
|
||||
n = getdents(fd, (struct dirent*)(buf+ts), st.st_blksize);
|
||||
if(n <= 0)
|
||||
break;
|
||||
ts += n;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ OFILES=\
|
|||
getuser.$O\
|
||||
getwd.$O\
|
||||
jmp.$O\
|
||||
jmp-FreeBSD.$O\
|
||||
jmp-$SYSNAME.$O\
|
||||
lock.$O\
|
||||
main.$O\
|
||||
malloctag.$O\
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ p9rfork(int flags)
|
|||
return -1;
|
||||
}
|
||||
if(flags&RFNOTEG){
|
||||
setpgrp(0, 0);
|
||||
setpgid(0, getpid());
|
||||
flags &= ~RFNOTEG;
|
||||
}
|
||||
if(flags){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue