Port to linux
This commit is contained in:
parent
5eefd45be5
commit
c8ee373ee5
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.19 2002/11/30 03:10:58 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.20 2003/04/03 17:14:24 christos Exp $
|
||||
# Copyright (c) 1992,1991 Carnegie Mellon University
|
||||
# All Rights Reserved.
|
||||
#
|
||||
|
@ -46,11 +46,13 @@
|
|||
|
||||
#SITE = SUNOS
|
||||
#SITE = SOLARIS
|
||||
SITE = NETBSD
|
||||
#SITE = NETBSD
|
||||
#SITE = CMUCS
|
||||
SITE != uname -s | tr '[a-z]' '[A-Z]'
|
||||
|
||||
LINUX_DEFINES = -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR
|
||||
NETBSD_DEFINES = -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR \
|
||||
-DHAS_FPARSELN
|
||||
-DHAS_FPARSELN -DHAS_FGETLN -DHAS_VIS
|
||||
SOLARIS_DEFINES = -UMACH -DVAR_TMP -DHAS_POSIX_DIR -DNEED_VSNPRINTF
|
||||
AFS_DEFINES = -DAFS -I/usr/afsws/include
|
||||
OSF_DEFINES = -UMACH -DOSF -D_BSD -noshrlib -g -DNEED_VSNPRINTF \
|
||||
|
@ -84,6 +86,7 @@ AFS_LIBPATH = /usr/afs/lib
|
|||
AFS_LIBS = -L${AFS_LIBPATH}/afs -lkauth -lprot -L${AFS_LIBPATH} -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcmd -lcom_err -lc ${AFS_LIBPATH}/afs/util.a
|
||||
|
||||
NETBSD_LIBS = -lcrypt
|
||||
LINUX_LIBS = -lcrypt
|
||||
CMUCS_LIBS = -lsys
|
||||
OSF_LIBS = -lbsd
|
||||
EXTRALIBS = libextra.a
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: errmsg.c,v 1.7 2002/07/10 20:19:38 wiz Exp $ */
|
||||
/* $NetBSD: errmsg.c,v 1.8 2003/04/03 17:14:24 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991 Carnegie Mellon University
|
||||
|
@ -52,7 +52,7 @@ itoa(char *p, unsigned n)
|
|||
const char *
|
||||
errmsg(int cod)
|
||||
{
|
||||
#ifndef __NetBSD__
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
|
@ -63,7 +63,7 @@ errmsg(int cod)
|
|||
if (cod < 0)
|
||||
cod = errno;
|
||||
|
||||
#ifndef __NetBSD__
|
||||
#ifndef errno
|
||||
if ((cod >= 0) && (cod < sys_nerr))
|
||||
return (sys_errlist[cod]);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffilecopy.c,v 1.5 2002/07/10 20:19:39 wiz Exp $ */
|
||||
/* $NetBSD: ffilecopy.c,v 1.6 2003/04/03 17:14:24 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991 Carnegie Mellon University
|
||||
|
@ -70,6 +70,7 @@ ffilecopy(FILE * here, FILE * there)
|
|||
here->_r = 0;
|
||||
}
|
||||
#else
|
||||
#ifndef __linux__
|
||||
if ((here->_cnt) > 0) { /* flush buffered input */
|
||||
i = write(therefile, here->_ptr, here->_cnt);
|
||||
if (i != here->_cnt)
|
||||
|
@ -77,6 +78,7 @@ ffilecopy(FILE * here, FILE * there)
|
|||
here->_ptr = here->_base;
|
||||
here->_cnt = 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
i = filecopy(herefile, therefile); /* fast file copy */
|
||||
if (i < 0)
|
||||
|
@ -85,7 +87,11 @@ ffilecopy(FILE * here, FILE * there)
|
|||
#if defined(__386BSD__) || defined(__NetBSD__)
|
||||
(here->_flags) |= __SEOF; /* indicate EOF */
|
||||
#else
|
||||
#ifndef __linux__
|
||||
(here->_flag) |= _IOEOF; /* indicate EOF */
|
||||
#else
|
||||
(void)fseeko(here, (off_t)0, SEEK_END); /* seek to end */
|
||||
#endif
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: read_line.c,v 1.5 2002/07/10 20:19:41 wiz Exp $ */
|
||||
/* $NetBSD: read_line.c,v 1.6 2003/04/03 17:14:24 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
|
||||
|
@ -32,8 +32,8 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: read_line.c,v 1.5 2002/07/10 20:19:41 wiz Exp $");
|
||||
#if defined(lint) && defined(__RCSID)
|
||||
__RCSID("$NetBSD: read_line.c,v 1.6 2003/04/03 17:14:24 christos Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -64,6 +64,9 @@ read_line(FILE * fp, size_t * size, size_t * lineno, const char *delim,
|
|||
free(buf);
|
||||
return (buf = fparseln(fp, size, lineno, delim, flags));
|
||||
#else
|
||||
#ifndef HAS_FGETLN
|
||||
char sbuf[1024];
|
||||
#endif
|
||||
static int buflen;
|
||||
|
||||
size_t s, len;
|
||||
|
@ -75,6 +78,7 @@ read_line(FILE * fp, size_t * size, size_t * lineno, const char *delim,
|
|||
while (cnt) {
|
||||
if (lineno != NULL)
|
||||
(*lineno)++;
|
||||
#ifdef HAS_FGETLN
|
||||
if ((ptr = fgetln(fp, &s)) == NULL) {
|
||||
if (size != NULL)
|
||||
*size = len;
|
||||
|
@ -83,6 +87,25 @@ read_line(FILE * fp, size_t * size, size_t * lineno, const char *delim,
|
|||
else
|
||||
return buf;
|
||||
}
|
||||
#else
|
||||
if ((ptr = fgets(sbuf, sizeof(sbuf) - 1, fp)) == NULL) {
|
||||
char *l;
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
else
|
||||
return buf;
|
||||
if ((l = strchr(sbuf, '\n')) == NULL) {
|
||||
if (sbuf[sizeof(sbuf) - 3] != '\\') {
|
||||
s = sizeof(sbuf);
|
||||
sbuf[sizeof(sbuf) - 2] = '\\';
|
||||
sbuf[sizeof(sbuf) - 1] = '\0';
|
||||
} else
|
||||
s = sizeof(sbuf) - 1;
|
||||
} else {
|
||||
s = l - ptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ptr[s - 1] == '\n') /* the newline may be missing at EOF */
|
||||
s--; /* forget newline */
|
||||
if (!s)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scan.c,v 1.16 2002/07/10 23:55:06 wiz Exp $ */
|
||||
/* $NetBSD: scan.c,v 1.17 2003/04/03 17:14:24 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
|
@ -85,7 +85,9 @@
|
|||
|
||||
#include "libc.h"
|
||||
#include "c.h"
|
||||
#ifdef HAS_VIS
|
||||
#include <vis.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -809,7 +811,11 @@ static int
|
|||
getscanfile(char *scanfile)
|
||||
{
|
||||
char buf[STRINGLENGTH];
|
||||
#ifdef HAS_VIS
|
||||
char fname[MAXPATHLEN];
|
||||
#else
|
||||
char *fname;
|
||||
#endif
|
||||
struct stat sbuf;
|
||||
FILE *f;
|
||||
TREE ts;
|
||||
|
@ -882,7 +888,11 @@ getscanfile(char *scanfile)
|
|||
goaway("scanfile format inconsistent");
|
||||
*q++ = 0;
|
||||
ts.Tmtime = atoi(p);
|
||||
#ifdef HAS_VIS
|
||||
(void) strunvis(fname, q);
|
||||
#else
|
||||
fname = q;
|
||||
#endif
|
||||
if (ts.Tctime > lasttime)
|
||||
ts.Tflags |= FNEW;
|
||||
else if (newonly) {
|
||||
|
@ -958,13 +968,17 @@ static int
|
|||
recordone(TREE * t, void *v)
|
||||
{
|
||||
FILE *scanF = v;
|
||||
#ifdef HAS_VIS
|
||||
char fname[MAXPATHLEN * 4 + 1];
|
||||
strvis(fname, t->Tname, VIS_WHITE);
|
||||
#else
|
||||
char *fname = t->Tname;
|
||||
#endif
|
||||
|
||||
if (t->Tflags & FBACKUP)
|
||||
fprintf(scanF, "B");
|
||||
if (t->Tflags & FNOACCT)
|
||||
fprintf(scanF, "N");
|
||||
strvis(fname, t->Tname, VIS_WHITE);
|
||||
fprintf(scanF, "%o %d %d %s\n",
|
||||
t->Tmode, t->Tctime, t->Tmtime, fname);
|
||||
(void) Tprocess(t->Texec, recordexec, scanF);
|
||||
|
@ -975,8 +989,12 @@ static int
|
|||
recordexec(TREE * t, void *v)
|
||||
{
|
||||
FILE *scanF = v;
|
||||
#ifdef HAS_VIS
|
||||
char fname[MAXPATHLEN * 4 + 1];
|
||||
strvis(fname, t->Tname, VIS_WHITE);
|
||||
#else
|
||||
char *fname = t->Tname;
|
||||
#endif
|
||||
fprintf(scanF, "X%s\n", fname);
|
||||
return (SCMOK);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scm.c,v 1.15 2003/04/01 08:46:10 drochner Exp $ */
|
||||
/* $NetBSD: scm.c,v 1.16 2003/04/03 17:14:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
|
@ -173,7 +173,9 @@
|
|||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef __linux__
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
#include "supcdefs.h"
|
||||
#include "supextern.h"
|
||||
|
||||
|
@ -476,7 +478,12 @@ remotehost(void)
|
|||
|
||||
if (remotename == NULL) {
|
||||
if (getnameinfo((struct sockaddr *) & remoteaddr,
|
||||
remoteaddr.ss_len, h1, sizeof(h1), NULL, 0, 0))
|
||||
#ifdef BSD4_4
|
||||
remoteaddr.ss_len,
|
||||
#else
|
||||
sizeof(struct sockaddr),
|
||||
#endif
|
||||
h1, sizeof(h1), NULL, 0, 0))
|
||||
return ("UNKNOWN");
|
||||
remotename = salloc(h1);
|
||||
if (remotename == NULL)
|
||||
|
@ -499,6 +506,64 @@ thishost(char *host)
|
|||
return (strcasecmp(name, h->h_name) == 0);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/* Nice and sleazy does it... */
|
||||
struct ifaddrs {
|
||||
struct ifaddrs *ifa_next;
|
||||
struct sockaddr *ifa_addr;
|
||||
struct sockaddr ifa_addrspace;
|
||||
};
|
||||
|
||||
static int
|
||||
getifaddrs(struct ifaddrs **ifap)
|
||||
{
|
||||
struct ifaddrs *ifa;
|
||||
int nint;
|
||||
int n;
|
||||
char buf[10 * 1024];
|
||||
struct ifconf ifc;
|
||||
struct ifreq *ifr;
|
||||
int s;
|
||||
|
||||
if ((s = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||
return -1;
|
||||
|
||||
ifc.ifc_len = sizeof(buf);
|
||||
ifc.ifc_buf = buf;
|
||||
|
||||
if (ioctl(s, SIOCGIFCONF, &ifc) == -1) {
|
||||
(void)close(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)close(s);
|
||||
|
||||
if ((nint = ifc.ifc_len / sizeof(struct ifreq)) <= 0)
|
||||
return 0;
|
||||
|
||||
if ((ifa = malloc((unsigned)nint * sizeof(struct ifaddrs))) == NULL)
|
||||
return -1;
|
||||
|
||||
for (ifr = ifc.ifc_req, n = 0; n < nint; n++, ifr++) {
|
||||
ifa[n].ifa_next = &ifa[n + 1];
|
||||
ifa[n].ifa_addr = &ifa[n].ifa_addrspace;
|
||||
(void)memcpy(ifa[n].ifa_addr, &ifr->ifr_addr,
|
||||
sizeof(*ifa[n].ifa_addr));
|
||||
}
|
||||
|
||||
ifa[nint - 1].ifa_next = NULL;
|
||||
*ifap = ifa;
|
||||
return nint;
|
||||
}
|
||||
|
||||
static void
|
||||
freeifaddrs(struct ifaddrs *ifa)
|
||||
{
|
||||
free(ifa);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
samehost(void)
|
||||
{ /* is remote host same as local host? */
|
||||
|
@ -510,15 +575,25 @@ samehost(void)
|
|||
const int niflags = NI_NUMERICHOST;
|
||||
#endif
|
||||
|
||||
if (getnameinfo((struct sockaddr *) & remoteaddr, remoteaddr.ss_len,
|
||||
h1, sizeof(h1), NULL, 0, niflags))
|
||||
if (getnameinfo((struct sockaddr *) &remoteaddr,
|
||||
#ifdef BSD4_4
|
||||
remoteaddr.ss_len,
|
||||
#else
|
||||
sizeof(struct sockaddr),
|
||||
#endif
|
||||
h1, sizeof(h1), NULL, 0, niflags))
|
||||
return (0);
|
||||
if (getifaddrs(&ifap) < 0)
|
||||
return (0);
|
||||
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||
if (remoteaddr.ss_family != ifa->ifa_addr->sa_family)
|
||||
continue;
|
||||
if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
|
||||
if (getnameinfo(ifa->ifa_addr,
|
||||
#ifdef BSD4_4
|
||||
ifa->ifa_addr->sa_len,
|
||||
#else
|
||||
sizeof(struct sockaddr),
|
||||
#endif
|
||||
h2, sizeof(h2), NULL, 0, niflags))
|
||||
continue;
|
||||
if (strcmp(h1, h2) == 0) {
|
||||
|
@ -541,8 +616,13 @@ matchhost(char *name)
|
|||
#endif
|
||||
struct addrinfo hints, *res0, *res;
|
||||
|
||||
if (getnameinfo((struct sockaddr *) & remoteaddr, remoteaddr.ss_len,
|
||||
h1, sizeof(h1), NULL, 0, niflags))
|
||||
if (getnameinfo((struct sockaddr *) & remoteaddr,
|
||||
#ifdef BSD4_4
|
||||
remoteaddr.ss_len,
|
||||
#else
|
||||
sizeof(struct sockaddr),
|
||||
#endif
|
||||
h1, sizeof(h1), NULL, 0, niflags))
|
||||
return (0);
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
|
@ -554,7 +634,7 @@ matchhost(char *name)
|
|||
if (remoteaddr.ss_family != res->ai_family)
|
||||
continue;
|
||||
if (getnameinfo(res->ai_addr, res->ai_addrlen,
|
||||
h2, sizeof(h2), NULL, 0, niflags))
|
||||
h2, sizeof(h2), NULL, 0, niflags))
|
||||
continue;
|
||||
if (strcmp(h1, h2) == 0) {
|
||||
freeaddrinfo(res0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scmio.c,v 1.13 2002/12/22 13:50:35 wiz Exp $ */
|
||||
/* $NetBSD: scmio.c,v 1.14 2003/04/03 17:14:25 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
|
@ -165,6 +165,9 @@
|
|||
#include "supcdefs.h"
|
||||
#include "supextern.h"
|
||||
#include "supmsg.h"
|
||||
#ifndef INFTIM
|
||||
#define INFTIM -1
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
*** M A C R O S ***
|
||||
|
|
Loading…
Reference in New Issue