Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sup/source Port to linux
details: https://anonhg.NetBSD.org/src/rev/35f0dd5b5578
branches: trunk
changeset: 545153:35f0dd5b5578
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 03 17:14:24 2003 +0000
description:
Port to linux
diffstat:
usr.sbin/sup/source/Makefile | 9 ++-
usr.sbin/sup/source/errmsg.c | 6 +-
usr.sbin/sup/source/ffilecopy.c | 8 ++-
usr.sbin/sup/source/read_line.c | 29 +++++++++++-
usr.sbin/sup/source/scan.c | 22 ++++++++-
usr.sbin/sup/source/scm.c | 96 +++++++++++++++++++++++++++++++++++++---
usr.sbin/sup/source/scmio.c | 5 +-
7 files changed, 154 insertions(+), 21 deletions(-)
diffs (truncated from 407 to 300 lines):
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/Makefile
--- a/usr.sbin/sup/source/Makefile Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/Makefile Thu Apr 03 17:14:24 2003 +0000
@@ -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_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
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/errmsg.c
--- a/usr.sbin/sup/source/errmsg.c Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/errmsg.c Thu Apr 03 17:14:24 2003 +0000
@@ -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 @@
const char *
errmsg(int cod)
{
-#ifndef __NetBSD__
+#ifndef errno
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
@@ -63,7 +63,7 @@
if (cod < 0)
cod = errno;
-#ifndef __NetBSD__
+#ifndef errno
if ((cod >= 0) && (cod < sys_nerr))
return (sys_errlist[cod]);
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/ffilecopy.c
--- a/usr.sbin/sup/source/ffilecopy.c Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/ffilecopy.c Thu Apr 03 17:14:24 2003 +0000
@@ -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 @@
here->_r = 0;
}
#else
+#ifndef __linux__
if ((here->_cnt) > 0) { /* flush buffered input */
i = write(therefile, here->_ptr, here->_cnt);
if (i != here->_cnt)
@@ -78,6 +79,7 @@
here->_cnt = 0;
}
#endif
+#endif
i = filecopy(herefile, therefile); /* fast file copy */
if (i < 0)
return (EOF);
@@ -85,7 +87,11 @@
#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);
}
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/read_line.c
--- a/usr.sbin/sup/source/read_line.c Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/read_line.c Thu Apr 03 17:14:24 2003 +0000
@@ -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@localhost>
@@ -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 @@
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 @@
while (cnt) {
if (lineno != NULL)
(*lineno)++;
+#ifdef HAS_FGETLN
if ((ptr = fgetln(fp, &s)) == NULL) {
if (size != NULL)
*size = len;
@@ -83,6 +87,25 @@
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)
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/scan.c
--- a/usr.sbin/sup/source/scan.c Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/scan.c Thu Apr 03 17:14:24 2003 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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);
}
diff -r a302adc97910 -r 35f0dd5b5578 usr.sbin/sup/source/scm.c
--- a/usr.sbin/sup/source/scm.c Thu Apr 03 16:41:23 2003 +0000
+++ b/usr.sbin/sup/source/scm.c Thu Apr 03 17:14:24 2003 +0000
@@ -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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index