commands: resolve compiler warnings

Change-Id: I95f0d0c48f998d4d950a0800eedd5fbbf2e50423
This commit is contained in:
David van Moolenbroek 2015-09-20 12:13:58 +00:00
parent fd962fdd93
commit d0055759dd
53 changed files with 252 additions and 508 deletions

View file

@ -6,8 +6,4 @@ LDADD+= -lasyn -lterminfo
BINDIR?=/usr/bin BINDIR?=/usr/bin
# BJG too many warnings here
NOGCCERROR?= yes
NOCLANGERROR?= yes
.include "../Makefile.inc" .include "../Makefile.inc"

View file

@ -21,6 +21,7 @@ Created August 7, 1991 by Philip Homburg
#include <net/gen/route.h> #include <net/gen/route.h>
#include <net/gen/socket.h> #include <net/gen/socket.h>
#include <net/gen/ip_io.h> #include <net/gen/ip_io.h>
#include <arpa/inet.h>
static char *prog_name; static char *prog_name;
static enum { ADD, DEL } action; static enum { ADD, DEL } action;
@ -165,7 +166,8 @@ int main(int argc, char *argv[])
{ {
if (parse_cidr(destination_str, &destination, &netmask)) if (parse_cidr(destination_str, &destination, &netmask))
cidr= 1; cidr= 1;
else if (inet_aton(destination_str, &destination)) else if (inet_aton(destination_str,
(struct in_addr *)&destination))
; ;
else if ((netent= getnetbyname(destination_str)) != NULL) else if ((netent= getnetbyname(destination_str)) != NULL)
destination= netent->n_net; destination= netent->n_net;
@ -194,7 +196,8 @@ int main(int argc, char *argv[])
else /* class D is multicast ... */ else /* class D is multicast ... */
{ {
fprintf(stderr, "%s: Warning: Martian address '%s'\n", fprintf(stderr, "%s: Warning: Martian address '%s'\n",
prog_name, inet_ntoa(destination)); prog_name,
inet_ntoa(*(struct in_addr *)&destination));
defaultmask= htonl(0xffffffff); defaultmask= htonl(0xffffffff);
} }
if (destination & ~defaultmask) if (destination & ~defaultmask)
@ -210,7 +213,7 @@ int main(int argc, char *argv[])
{ {
if (cidr) if (cidr)
usage(); usage();
if (inet_aton(netmask_str, &netmask) == 0) if (inet_aton(netmask_str, (struct in_addr *)&netmask) == 0)
{ {
fprintf(stderr, "%s: illegal netmask'%s'\n", prog_name, fprintf(stderr, "%s: illegal netmask'%s'\n", prog_name,
netmask_str); netmask_str);
@ -248,9 +251,11 @@ int main(int argc, char *argv[])
printf("%s %s route to %s ", printf("%s %s route to %s ",
action == ADD ? "adding" : "deleting", action == ADD ? "adding" : "deleting",
itab ? "input" : "output", itab ? "input" : "output",
inet_ntoa(destination)); inet_ntoa(*(struct in_addr *)&destination));
printf("with netmask %s ", inet_ntoa(netmask)); printf("with netmask %s ",
printf("using gateway %s", inet_ntoa(gateway)); inet_ntoa(*(struct in_addr *)&netmask));
printf("using gateway %s",
inet_ntoa(*(struct in_addr *)&gateway));
if (itab && action == ADD) if (itab && action == ADD)
printf(" at distance %d", metric); printf(" at distance %d", metric);
printf("\n"); printf("\n");
@ -305,7 +310,7 @@ static int name_to_ip(const char *name, ipaddr_t *addr)
*/ */
struct hostent *hostent; struct hostent *hostent;
if (!inet_aton(name, addr)) { if (!inet_aton(name, (struct in_addr *)addr)) {
if ((hostent= gethostbyname(name)) == NULL) return 0; if ((hostent= gethostbyname(name)) == NULL) return 0;
if (hostent->h_addrtype != AF_INET) return 0; if (hostent->h_addrtype != AF_INET) return 0;
if (hostent->h_length != sizeof(*addr)) return 0; if (hostent->h_length != sizeof(*addr)) return 0;
@ -327,7 +332,7 @@ static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask)
*slash++= 0; *slash++= 0;
ok= 1; ok= 1;
if (!inet_aton(cidr, &a)) if (!inet_aton(cidr, (struct in_addr *)&a))
ok= 0; ok= 0;
len= strtoul(slash, &check, 10); len= strtoul(slash, &check, 10);

View file

@ -30,6 +30,8 @@ Manipulate ARP table
#include <net/gen/arp_io.h> #include <net/gen/arp_io.h>
#include <arpa/inet.h>
char *progname; char *progname;
static int ipfd= -1; static int ipfd= -1;
static int do_setuid= 0; static int do_setuid= 0;
@ -256,9 +258,10 @@ static void print_one(ipaddr_t ipaddr, nwio_arp_t *arpp, int do_num)
else else
he= NULL; he= NULL;
if (he) if (he)
printf("%s (%s)", he->h_name, inet_ntoa(ipaddr)); printf("%s (%s)", he->h_name,
inet_ntoa(*(struct in_addr *)&ipaddr));
else else
printf("%s", inet_ntoa(ipaddr)); printf("%s", inet_ntoa(*(struct in_addr *)&ipaddr));
if (!arpp) if (!arpp)
{ {
printf(" -- no entry\n"); printf(" -- no entry\n");
@ -328,7 +331,8 @@ static void delete_all(void)
continue; continue;
} }
fatal("unable to delete host %s: %s", fatal("unable to delete host %s: %s",
inet_ntoa(arptab[i].nwa_ipaddr), strerror(errno)); inet_ntoa(*(struct in_addr *)&arptab[i].nwa_ipaddr),
strerror(errno));
} }
} }
@ -348,7 +352,8 @@ static void delete(char *hostname)
print_one(ipaddr, NULL, 0); print_one(ipaddr, NULL, 0);
exit(1); exit(1);
} }
fatal("unable to delete host %s: %s", inet_ntoa(ipaddr), fatal("unable to delete host %s: %s",
inet_ntoa(*(struct in_addr *)&ipaddr),
errno == EINVAL ? "entry is incomplete" : strerror(errno)); errno == EINVAL ? "entry is incomplete" : strerror(errno));
} }
@ -389,7 +394,7 @@ static void do_set(char *hostname, char *ethername, int temp, int pub,
if (r == -1 && errno != ENOENT) if (r == -1 && errno != ENOENT)
{ {
fatal("unable to delete entry for host %s: %s", fatal("unable to delete entry for host %s: %s",
inet_ntoa(ipaddr), inet_ntoa(*(struct in_addr *)&ipaddr),
errno == EINVAL ? "incomplete entry" : errno == EINVAL ? "incomplete entry" :
strerror(errno)); strerror(errno));
} }
@ -415,7 +420,7 @@ static ipaddr_t nametoipaddr(char *hostname)
ipaddr_t ipaddr; ipaddr_t ipaddr;
struct hostent *he; struct hostent *he;
if (inet_aton(hostname, &ipaddr) == 0) if (inet_aton(hostname, (struct in_addr *)&ipaddr) == 0)
{ {
he= gethostbyname(hostname); he= gethostbyname(hostname);
if (!he) if (!he)

View file

@ -28,7 +28,7 @@ int main(int argc, char **argv, char **envp)
int i, c, mask, ltim, year, lday = NODAY; int i, c, mask, ltim, year, lday = NODAY;
char buf[64], job[30], pastjob[35], *dp, *sp; char buf[64], job[30], pastjob[35], *dp, *sp;
struct tm *p; struct tm *p;
long clk; time_t clk;
FILE *fp; FILE *fp;
char pwd[PATH_MAX+1]; char pwd[PATH_MAX+1];

View file

@ -28,6 +28,7 @@
* 4. This notice may not be removed or altered. * 4. This notice may not be removed or altered.
*/ */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef UNIX #ifdef UNIX

View file

@ -36,6 +36,7 @@ static char Version[] = "4.0";
#include "cawf.h" #include "cawf.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#ifndef UNIX #ifndef UNIX
#include <io.h> #include <io.h>
#include <process.h> #include <process.h>

View file

@ -1,3 +1,4 @@
#ifndef __minix
/* /*
Newsgroups: mod.std.unix Newsgroups: mod.std.unix
Subject: public domain AT&T getopt source Subject: public domain AT&T getopt source
@ -71,3 +72,4 @@ int getopt(int argc, char **argv, char **opts) {
} }
return(c); return(c);
} }
#endif /* !__minix */

View file

@ -35,7 +35,7 @@
* Delmacro(mx) - delete macro * Delmacro(mx) - delete macro
*/ */
int Delmacro(int mx) { void Delmacro(int mx) {
/* macro index mx */ /* macro index mx */
unsigned char buf[MAXLINE]; /* error message buffer */ unsigned char buf[MAXLINE]; /* error message buffer */
int i, j; /* temporary indexes */ int i, j; /* temporary indexes */

View file

@ -690,7 +690,7 @@ static void nr_Uc(unsigned char *line, int brk) {
if (*s4) if (*s4)
s4++; s4++;
} }
while (*s1++ = *s4++) while ((*s1++ = *s4++))
; ;
if (*s2 == 'h' && *(s2+1) == 'y') if (*s2 == 'h' && *(s2+1) == 'y')
(void) Findhy(buf, i, 1); (void) Findhy(buf, i, 1);

View file

@ -80,7 +80,7 @@ char *malloc(unsigned size);
unsigned char *Asmcode(unsigned char **s, unsigned char *c); unsigned char *Asmcode(unsigned char **s, unsigned char *c);
int Asmname(unsigned char *s, unsigned char *c); int Asmname(unsigned char *s, unsigned char *c);
void Charput(int c); void Charput(int c);
int Delmacro(int mx); void Delmacro(int mx);
int Defdev(); int Defdev();
void Delstr(int sx); void Delstr(int sx);
void Error(int t, int l, char *s1, char *s2); void Error(int t, int l, char *s1, char *s2);

View file

@ -21,10 +21,6 @@
#include "misc.h" #include "misc.h"
#include "tab.h" #include "tab.h"
#if __minix && !__minix_vmd
#define initgroups(name, gid) (0)
#endif
static volatile int busy; /* Set when something is afoot, don't sleep! */ static volatile int busy; /* Set when something is afoot, don't sleep! */
static volatile int need_reload;/* Set if table reload required. */ static volatile int need_reload;/* Set if table reload required. */
static volatile int need_quit; /* Set if cron must exit. */ static volatile int need_quit; /* Set if cron must exit. */
@ -55,7 +51,7 @@ static void run_job(cronjob_t *job)
need_reload= 1; need_reload= 1;
} else { } else {
/* Bad error, halt processing AT jobs. */ /* Bad error, halt processing AT jobs. */
log(LOG_CRIT, "Can't rename %s: %s\n", cronlog(LOG_CRIT, "Can't rename %s: %s\n",
tab->file, strerror(errno)); tab->file, strerror(errno));
tab_reschedule(job); tab_reschedule(job);
} }
@ -65,13 +61,14 @@ static void run_job(cronjob_t *job)
need_reload= 1; need_reload= 1;
if (stat(tab->data, &st) < 0) { if (stat(tab->data, &st) < 0) {
log(LOG_ERR, "Can't stat %s: %s\n", cronlog(LOG_ERR, "Can't stat %s: %s\n",
tab->data, strerror(errno)); tab->data, strerror(errno));
tab_reschedule(job); tab_reschedule(job);
return; return;
} }
if ((pw= getpwuid(st.st_uid)) == nil) { if ((pw= getpwuid(st.st_uid)) == nil) {
log(LOG_ERR, "Unknown owner for uid %lu of AT job %s\n", cronlog(LOG_ERR,
"Unknown owner for uid %lu of AT job %s\n",
(unsigned long) st.st_uid, job->cmd); (unsigned long) st.st_uid, job->cmd);
tab_reschedule(job); tab_reschedule(job);
return; return;
@ -79,7 +76,7 @@ static void run_job(cronjob_t *job)
} else { } else {
pw= nil; pw= nil;
if (job->user != nil && (pw= getpwnam(job->user)) == nil) { if (job->user != nil && (pw= getpwnam(job->user)) == nil) {
log(LOG_ERR, "%s: Unknown user\n", job->user); cronlog(LOG_ERR, "%s: Unknown user\n", job->user);
tab_reschedule(job); tab_reschedule(job);
return; return;
} }
@ -88,7 +85,7 @@ static void run_job(cronjob_t *job)
if (need_mailer) { if (need_mailer) {
errfd[0]= -1; errfd[0]= -1;
if (pipe(errfd) < 0 || pipe(mailfd) < 0) { if (pipe(errfd) < 0 || pipe(mailfd) < 0) {
log(LOG_ERR, "pipe() call failed: %s\n", cronlog(LOG_ERR, "pipe() call failed: %s\n",
strerror(errno)); strerror(errno));
if (errfd[0] != -1) { if (errfd[0] != -1) {
close(errfd[0]); close(errfd[0]);
@ -101,7 +98,7 @@ static void run_job(cronjob_t *job)
fcntl(errfd[1], F_GETFD) | FD_CLOEXEC); fcntl(errfd[1], F_GETFD) | FD_CLOEXEC);
if ((pid= fork()) == -1) { if ((pid= fork()) == -1) {
log(LOG_ERR, "fork() call failed: %s\n", cronlog(LOG_ERR, "fork() call failed: %s\n",
strerror(errno)); strerror(errno));
close(errfd[0]); close(errfd[0]);
close(errfd[1]); close(errfd[1]);
@ -143,7 +140,7 @@ static void run_job(cronjob_t *job)
close(mailfd[0]); close(mailfd[0]);
close(errfd[1]); close(errfd[1]);
if (read(errfd[0], &errno, sizeof(errno)) > 0) { if (read(errfd[0], &errno, sizeof(errno)) > 0) {
log(LOG_ERR, "can't execute /usr/bin/mail: %s\n", cronlog(LOG_ERR, "can't execute /usr/bin/mail: %s\n",
strerror(errno)); strerror(errno));
close(errfd[0]); close(errfd[0]);
close(mailfd[1]); close(mailfd[1]);
@ -154,7 +151,7 @@ static void run_job(cronjob_t *job)
} }
if (pipe(errfd) < 0) { if (pipe(errfd) < 0) {
log(LOG_ERR, "pipe() call failed: %s\n", strerror(errno)); cronlog(LOG_ERR, "pipe() call failed: %s\n", strerror(errno));
if (need_mailer) close(mailfd[1]); if (need_mailer) close(mailfd[1]);
tab_reschedule(job); tab_reschedule(job);
return; return;
@ -162,7 +159,7 @@ static void run_job(cronjob_t *job)
(void) fcntl(errfd[1], F_SETFD, fcntl(errfd[1], F_GETFD) | FD_CLOEXEC); (void) fcntl(errfd[1], F_SETFD, fcntl(errfd[1], F_GETFD) | FD_CLOEXEC);
if ((pid= fork()) == -1) { if ((pid= fork()) == -1) {
log(LOG_ERR, "fork() call failed: %s\n", strerror(errno)); cronlog(LOG_ERR, "fork() call failed: %s\n", strerror(errno));
close(errfd[0]); close(errfd[0]);
close(errfd[1]); close(errfd[1]);
if (need_mailer) close(mailfd[1]); if (need_mailer) close(mailfd[1]);
@ -207,7 +204,8 @@ static void run_job(cronjob_t *job)
if (need_mailer) close(mailfd[1]); if (need_mailer) close(mailfd[1]);
close(errfd[1]); close(errfd[1]);
if (read(errfd[0], &errno, sizeof(errno)) > 0) { if (read(errfd[0], &errno, sizeof(errno)) > 0) {
log(LOG_ERR, "can't execute /bin/sh: %s\n", strerror(errno)); cronlog(LOG_ERR, "can't execute /bin/sh: %s\n",
strerror(errno));
close(errfd[0]); close(errfd[0]);
tab_reschedule(job); tab_reschedule(job);
return; return;
@ -256,13 +254,13 @@ static void load_crontabs(void)
tab_parse(tab, nil); tab_parse(tab, nil);
} }
if (ferror(pkgs)) { if (ferror(pkgs)) {
log(LOG_CRIT, "/usr/lib/packages: %s\n", cronlog(LOG_CRIT, "/usr/lib/packages: %s\n",
strerror(errno)); strerror(errno));
} }
fclose(pkgs); fclose(pkgs);
} else { } else {
if (errno != ENOENT) { if (errno != ENOENT) {
log(LOG_ERR, "/usr/lib/packages: %s\n", cronlog(LOG_ERR, "/usr/lib/packages: %s\n",
strerror(errno)); strerror(errno));
} }
} }

View file

@ -21,7 +21,7 @@ void *allocate(size_t len)
void *mem; void *mem;
if ((mem= malloc(len)) == nil) { if ((mem= malloc(len)) == nil) {
log(LOG_ALERT, "Out of memory, exiting\n"); cronlog(LOG_ALERT, "Out of memory, exiting\n");
exit(1); exit(1);
} }
alloc_count++; alloc_count++;
@ -44,7 +44,7 @@ void selectlog(enum logto where)
logto= where; logto= where;
} }
void log(int level, const char *fmt, ...) void cronlog(int level, const char *fmt, ...)
/* Like syslog(), but may go to stderr. */ /* Like syslog(), but may go to stderr. */
{ {
va_list ap; va_list ap;

View file

@ -33,7 +33,7 @@ enum log_dummy { LOG_ERR, LOG_CRIT, LOG_ALERT };
enum logto { SYSLOG, STDERR }; enum logto { SYSLOG, STDERR };
void selectlog(enum logto where); void selectlog(enum logto where);
void log(int level, const char *fmt, ...); void cronlog(int level, const char *fmt, ...);
#endif /* MISC__H */ #endif /* MISC__H */

View file

@ -150,7 +150,7 @@ void tab_reschedule(cronjob_t *job)
nodst_rtime= job->rtime= mktime(&tmptm); nodst_rtime= job->rtime= mktime(&tmptm);
if (job->rtime == -1) { if (job->rtime == -1) {
/* This should not happen. */ /* This should not happen. */
log(LOG_ERR, cronlog(LOG_ERR,
"mktime failed for %04d-%02d-%02d %02d:%02d:%02d", "mktime failed for %04d-%02d-%02d %02d:%02d:%02d",
1900+nexttm.tm_year, nexttm.tm_mon+1, 1900+nexttm.tm_year, nexttm.tm_mon+1,
nexttm.tm_mday, nexttm.tm_hour, nexttm.tm_mday, nexttm.tm_hour,
@ -175,7 +175,7 @@ void tab_reschedule(cronjob_t *job)
dst_rtime= job->rtime= mktime(&tmptm); dst_rtime= job->rtime= mktime(&tmptm);
if (job->rtime == -1) { if (job->rtime == -1) {
/* This should not happen. */ /* This should not happen. */
log(LOG_ERR, cronlog(LOG_ERR,
"mktime failed for %04d-%02d-%02d %02d:%02d:%02d\n", "mktime failed for %04d-%02d-%02d %02d:%02d:%02d\n",
1900+nexttm.tm_year, nexttm.tm_mon+1, 1900+nexttm.tm_year, nexttm.tm_mon+1,
nexttm.tm_mday, nexttm.tm_hour, nexttm.tm_mday, nexttm.tm_hour,
@ -309,7 +309,7 @@ static int range_parse(char *file, char *data, bitmap_t map,
p= data; p= data;
if (*p == 0) { if (*p == 0) {
log(LOG_ERR, "%s: not enough time fields\n", file); cronlog(LOG_ERR, "%s: not enough time fields\n", file);
return 0; return 0;
} }
@ -371,11 +371,12 @@ static int range_parse(char *file, char *data, bitmap_t map,
*p= end; *p= end;
return 1; return 1;
syntax: syntax:
log(LOG_ERR, "%s: field '%s': bad syntax for a %d-%d time field\n", cronlog(LOG_ERR, "%s: field '%s': bad syntax for a %d-%d time field\n",
file, data, min, max); file, data, min, max);
return 0; return 0;
range: range:
log(LOG_ERR, "%s: field '%s': values out of the %d-%d allowed range\n", cronlog(LOG_ERR,
"%s: field '%s': values out of the %d-%d allowed range\n",
file, data, min, max); file, data, min, max);
return 0; return 0;
} }
@ -401,7 +402,7 @@ void tab_parse(char *file, char *user)
/* Try to open the file. */ /* Try to open the file. */
if ((fd= open(file, O_RDONLY)) < 0 || fstat(fd, &st) < 0) { if ((fd= open(file, O_RDONLY)) < 0 || fstat(fd, &st) < 0) {
if (errno != ENOENT) { if (errno != ENOENT) {
log(LOG_ERR, "%s: %s\n", file, strerror(errno)); cronlog(LOG_ERR, "%s: %s\n", file, strerror(errno));
} }
if (fd != -1) close(fd); if (fd != -1) close(fd);
return; return;
@ -409,7 +410,7 @@ void tab_parse(char *file, char *user)
/* Forget it if the file is awfully big. */ /* Forget it if the file is awfully big. */
if (st.st_size > TAB_MAX) { if (st.st_size > TAB_MAX) {
log(LOG_ERR, "%s: %lu bytes is bigger than my %lu limit\n", cronlog(LOG_ERR, "%s: %lu bytes is bigger than my %lu limit\n",
file, file,
(unsigned long) st.st_size, (unsigned long) st.st_size,
(unsigned long) TAB_MAX); (unsigned long) TAB_MAX);
@ -443,7 +444,7 @@ void tab_parse(char *file, char *user)
n= 0; n= 0;
while (n < st.st_size) { while (n < st.st_size) {
if ((r = read(fd, tab->data + n, st.st_size - n)) < 0) { if ((r = read(fd, tab->data + n, st.st_size - n)) < 0) {
log(LOG_CRIT, "%s: %s", file, strerror(errno)); cronlog(LOG_CRIT, "%s: %s", file, strerror(errno));
close(fd); close(fd);
return; return;
} }
@ -453,7 +454,7 @@ void tab_parse(char *file, char *user)
close(fd); close(fd);
tab->data[n]= 0; tab->data[n]= 0;
if (strlen(tab->data) < n) { if (strlen(tab->data) < n) {
log(LOG_ERR, "%s contains a null character\n", file); cronlog(LOG_ERR, "%s contains a null character\n", file);
return; return;
} }
@ -539,7 +540,7 @@ void tab_parse(char *file, char *user)
break; break;
default: default:
usage: usage:
log(LOG_ERR, cronlog(LOG_ERR,
"%s: bad option -%c, good options are: -u username\n", "%s: bad option -%c, good options are: -u username\n",
file, q[-1]); file, q[-1]);
ok= 0; ok= 0;
@ -558,7 +559,8 @@ void tab_parse(char *file, char *user)
*/ */
while (*p != 0 && *p++ != '\n') {} while (*p != 0 && *p++ != '\n') {}
if (*p++ != '\t') { if (*p++ != '\t') {
log(LOG_ERR, "%s: contains an empty command\n", cronlog(LOG_ERR,
"%s: contains an empty command\n",
file); file);
ok= 0; ok= 0;
goto endtab; goto endtab;

View file

@ -16,10 +16,6 @@
#include "misc.h" #include "misc.h"
#include "tab.h" #include "tab.h"
#if __minix && !__minix_vmd
#define seteuid(uid) ((uid),0) /* Minix can't fiddle with uids. */
#endif
static int opentab(int uid, char *file, int how) static int opentab(int uid, char *file, int how)
/* Open a crontab file under the given uid. How is 'r' or 'w'. Return /* Open a crontab file under the given uid. How is 'r' or 'w'. Return
* the result of open(2). * the result of open(2).
@ -34,13 +30,6 @@ static int opentab(int uid, char *file, int how)
default: errno= EINVAL; return -1; default: errno= EINVAL; return -1;
} }
#if __minix && !__minix_vmd
/* Standard Minix has no saved uid, so use the lousy old access(). */
if (uid != 0) {
if (access(file, how == 'r' ? R_OK : W_OK) < 0) return -1;
}
#endif
safe_uid= geteuid(); safe_uid= geteuid();
seteuid(uid); seteuid(uid);
r= open(file, flags, 0666); r= open(file, flags, 0666);

View file

@ -7,7 +7,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <machine/partition.h> #include <machine/partition.h>
#include <minix/partition.h> #include <minix/partition.h>
#include <sys/ioc_disk.h> #include <sys/ioctl.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>

View file

@ -98,7 +98,7 @@ void closefd(fd_t *fdp)
static void timeout(int signum) static void timeout(int signum)
{ {
/* nothing to do, ioctl will be aborted automatically */ /* nothing to do, ioctl will be aborted automatically */
if (alarm(1) < 0) fatal("alarm(1)"); if (alarm(1) == (unsigned int)-1) fatal("alarm(1)");
} }
int opendev(network_t *np, fdtype_t fdtype, int compete) int opendev(network_t *np, fdtype_t fdtype, int compete)
@ -219,13 +219,13 @@ int opendev(network_t *np, fdtype_t fdtype, int compete)
* in case the driver isn't ready yet. * in case the driver isn't ready yet.
*/ */
if (signal(SIGALRM, timeout) == SIG_ERR) fatal("signal(SIGALRM)"); if (signal(SIGALRM, timeout) == SIG_ERR) fatal("signal(SIGALRM)");
if (alarm(1) < 0) fatal("alarm(1)"); if (alarm(1) == (unsigned int)-1) fatal("alarm(1)");
if (ioctl(np->fdp->fd, NWIOGETHSTAT, &ethstat) < 0) { if (ioctl(np->fdp->fd, NWIOGETHSTAT, &ethstat) < 0) {
/* Not an Ethernet. */ /* Not an Ethernet. */
close(fdp->fd); close(fdp->fd);
return 0; return 0;
} }
if (alarm(0) < 0) fatal("alarm(0)"); if (alarm(0) == (unsigned int)-1) fatal("alarm(0)");
np->eth= ethstat.nwes_addr; np->eth= ethstat.nwes_addr;
ethopt.nweo_flags= NWEO_COPY | NWEO_EN_LOC | NWEO_EN_BROAD ethopt.nweo_flags= NWEO_COPY | NWEO_EN_LOC | NWEO_EN_BROAD
| NWEO_REMANY | NWEO_TYPEANY | NWEO_RWDATALL; | NWEO_REMANY | NWEO_TYPEANY | NWEO_RWDATALL;

View file

@ -29,6 +29,7 @@
#include <net/gen/udp_hdr.h> #include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h> #include <net/gen/udp_io.h>
#include <net/gen/dhcp.h> #include <net/gen/dhcp.h>
#include <arpa/inet.h>
#include "arp.h" #include "arp.h"
#define EXTERN #define EXTERN
#include "dhcpd.h" #include "dhcpd.h"
@ -359,11 +360,12 @@ static void printdata(void)
strcpy(delta, "infinite"); strcpy(delta, "infinite");
} else } else
if (expire < now) { if (expire < now) {
sprintf(delta, "-%lu", now - expire); sprintf(delta, "-%llu", now - expire);
} else { } else {
sprintf(delta, "+%lu", expire - now); sprintf(delta, "+%llu", expire - now);
} }
printf("\t%-15s %8s ", inet_ntoa(entry.ip), delta); printf("\t%-15s %8s ", inet_ntoa(*(struct in_addr *)&entry.ip),
delta);
for (i= 0; i < entry.len; i++) { for (i= 0; i < entry.len; i++) {
printf("%02X", entry.clid[i]); printf("%02X", entry.clid[i]);
} }
@ -482,7 +484,7 @@ static size_t servdhcp(network_t *np, buf_t *bp, size_t dlen)
if (dyn) { if (dyn) {
/* A dynamic address must have a lease. */ /* A dynamic address must have a lease. */
fprintf(stderr, "%s: No lease set for address %s\n", fprintf(stderr, "%s: No lease set for address %s\n",
program, inet_ntoa(cip)); program, inet_ntoa(*(struct in_addr *)&cip));
exit(1); exit(1);
} }
lease= nil; lease= nil;
@ -528,7 +530,8 @@ static size_t servdhcp(network_t *np, buf_t *bp, size_t dlen)
for (i= 0; i < cilen; i++) { for (i= 0; i < cilen; i++) {
fprintf(stderr, "%02X", client[i]); fprintf(stderr, "%02X", client[i]);
} }
fprintf(stderr, " declines %s", inet_ntoa(cip)); fprintf(stderr, " declines %s",
inet_ntoa(*(struct in_addr *)&cip));
if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) { if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) {
fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata); fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata);
} }
@ -953,7 +956,7 @@ main:
/* Some weird sites use a hostname, not a client ID. */ /* Some weird sites use a hostname, not a client ID. */
if (np->hostname != nil) { if (np->hostname != nil) {
settag(bp->dhcp, DHCP_TAG_HOSTNAME, settag(bp->dhcp, DHCP_TAG_HOSTNAME,
np->hostname, strlen(np->hostname)); (void *)np->hostname, strlen(np->hostname));
} }
bp->udpio->uih_src_addr= np->ip; bp->udpio->uih_src_addr= np->ip;
@ -983,7 +986,7 @@ main:
printf("%s: Sent DHCP %s to %s\n", printf("%s: Sent DHCP %s to %s\n",
np->fdp->device, np->fdp->device,
dhcptypename(type), dhcptypename(type),
inet_ntoa(np->server)); inet_ntoa(*(struct in_addr *)&np->server));
if (debug >= 2) printdhcp(bp->dhcp); if (debug >= 2) printdhcp(bp->dhcp);
} }
} }
@ -1073,9 +1076,12 @@ main:
if (debug >= 1) { if (debug >= 1) {
printf("%s: Got a DHCP %s from %s", printf("%s: Got a DHCP %s from %s",
np->fdp->device, dhcptypename(type), inet_ntoa(server)); np->fdp->device, dhcptypename(type),
printf(relay != server ? " through %s\n" : "\n", inet_ntoa(*(struct in_addr *)&server));
inet_ntoa(relay)); if (relay != server)
printf(" through %s\n",
inet_ntoa(*(struct in_addr *)&relay));
else printf("\n");
if (debug >= 2) printdhcp(bp->dhcp); if (debug >= 2) printdhcp(bp->dhcp);
} }
@ -1136,7 +1142,8 @@ main:
make_arp(bp, np); make_arp(bp, np);
if (sendpacket(np, bp->eth, sizeof(arp46_t))) { if (sendpacket(np, bp->eth, sizeof(arp46_t))) {
if (debug >= 2) { if (debug >= 2) {
printf("Sent ARP for %s\n", inet_ntoa(np->ip)); printf("Sent ARP for %s\n",
inet_ntoa(*(struct in_addr *)&np->ip));
} }
} }
np->flags &= ~NF_CONFLICT; np->flags &= ~NF_CONFLICT;
@ -1222,9 +1229,10 @@ main:
np->delta= DELTA_FIRST; np->delta= DELTA_FIRST;
fprintf(stderr, "%s: Got a NAK from %s", fprintf(stderr, "%s: Got a NAK from %s",
program, inet_ntoa(server)); program, inet_ntoa(*(struct in_addr *)&server));
if (relay != server) { if (relay != server) {
fprintf(stderr, " through %s", inet_ntoa(relay)); fprintf(stderr, " through %s",
inet_ntoa(*(struct in_addr *)&relay));
} }
if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) { if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) {
fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata); fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata);
@ -1243,9 +1251,9 @@ main:
fprintf(stderr, "%s: %s: %s offered by ", fprintf(stderr, "%s: %s: %s offered by ",
program, program,
np->fdp->device, np->fdp->device,
inet_ntoa(np->ip)); inet_ntoa(*(struct in_addr *)&np->ip));
fprintf(stderr, "%s is already in use by %s\n", fprintf(stderr, "%s is already in use by %s\n",
inet_ntoa(np->server), inet_ntoa(*(struct in_addr *)&np->server),
ether_ntoa(&np->conflict)); ether_ntoa(&np->conflict));
} }
put_buf(&bp); put_buf(&bp);
@ -1270,7 +1278,8 @@ main:
if (sendpacket(np, bp->ip, sizeof(ip_hdr_t) + 16)) { if (sendpacket(np, bp->ip, sizeof(ip_hdr_t) + 16)) {
if (debug >= 2) { if (debug >= 2) {
printf("%s: Sent advert for %s to self\n", printf("%s: Sent advert for %s to self\n",
np->fdp->device, inet_ntoa(np->gateway)); np->fdp->device,
inet_ntoa(*(struct in_addr *)&np->gateway));
} }
} }
np->solicit= now + DELTA_ADV/2; np->solicit= now + DELTA_ADV/2;
@ -1320,7 +1329,8 @@ main:
if ((router= icmp_is_advert(bp)) != 0) { if ((router= icmp_is_advert(bp)) != 0) {
if (debug >= 2) { if (debug >= 2) {
printf("%s: Router advert received from %s\n", printf("%s: Router advert received from %s\n",
np->fdp->device, inet_ntoa(router)); np->fdp->device,
inet_ntoa(*(struct in_addr *)&router));
} }
np->solicit= NEVER; np->solicit= NEVER;
np->sol_ct= -1; np->sol_ct= -1;
@ -1369,8 +1379,10 @@ main:
if (debug >= 1) { if (debug >= 1) {
printf("%s: Got DHCP packet from %s to ", printf("%s: Got DHCP packet from %s to ",
np->fdp->device, inet_ntoa(bp->udpio->uih_src_addr)); np->fdp->device,
printf("%s\n", inet_ntoa(bp->udpio->uih_dst_addr)); inet_ntoa(*(struct in_addr *)&bp->udpio->uih_src_addr));
printf("%s\n",
inet_ntoa(*(struct in_addr *)&bp->udpio->uih_dst_addr));
if (debug >= 2) printdhcp(bp->dhcp); if (debug >= 2) printdhcp(bp->dhcp);
} }
@ -1381,7 +1393,8 @@ main:
if (debug >= 1) { if (debug >= 1) {
printf("%s: Sent DHCP packet to %s\n", printf("%s: Sent DHCP packet to %s\n",
np->fdp->device, np->fdp->device,
inet_ntoa(bp->udpio->uih_dst_addr)); inet_ntoa(*(struct in_addr *)
&bp->udpio->uih_dst_addr));
if (debug >= 2) printdhcp(bp->dhcp); if (debug >= 2) printdhcp(bp->dhcp);
} }
} }

View file

@ -168,6 +168,7 @@ void icmp_solicit(buf_t *bp)
void icmp_advert(buf_t *bp, network_t *np) void icmp_advert(buf_t *bp, network_t *np)
{ {
/* Fill in a router advert to be sent to my own interface. */ /* Fill in a router advert to be sent to my own interface. */
u32_t *data;
icmp_hdr_t *icmp= (icmp_hdr_t *) (bp->ip + 1); icmp_hdr_t *icmp= (icmp_hdr_t *) (bp->ip + 1);
bp->ip->ih_vers_ihl= 0x45; bp->ip->ih_vers_ihl= 0x45;
@ -178,8 +179,9 @@ void icmp_advert(buf_t *bp, network_t *np)
icmp->ih_hun.ihh_ram.iram_na= 1; icmp->ih_hun.ihh_ram.iram_na= 1;
icmp->ih_hun.ihh_ram.iram_aes= 2; icmp->ih_hun.ihh_ram.iram_aes= 2;
icmp->ih_hun.ihh_ram.iram_lt= htons(DELTA_ADV); icmp->ih_hun.ihh_ram.iram_lt= htons(DELTA_ADV);
((u32_t *) icmp->ih_dun.uhd_data)[0] = np->gateway; data = (u32_t *) icmp->ih_dun.uhd_data;
((u32_t *) icmp->ih_dun.uhd_data)[1] = htonl((u32_t) -9999); data[0] = np->gateway;
data[1] = htonl((u32_t) -9999);
icmp->ih_chksum= 0; icmp->ih_chksum= 0;
icmp->ih_chksum= ~oneC_sum(0, icmp, 16); icmp->ih_chksum= ~oneC_sum(0, icmp, 16);
} }

View file

@ -28,6 +28,7 @@
#include <net/gen/udp.h> #include <net/gen/udp.h>
#include <net/gen/udp_hdr.h> #include <net/gen/udp_hdr.h>
#include <net/gen/dhcp.h> #include <net/gen/dhcp.h>
#include <arpa/inet.h>
#include "dhcpd.h" #include "dhcpd.h"
#define doff(field) offsetof(dhcp_t, field) #define doff(field) offsetof(dhcp_t, field)
@ -59,7 +60,7 @@ static int name2ip(ipaddr_t *pip, const char *name, ipaddr_t ifip)
char *hn; char *hn;
/* Already an IP address? */ /* Already an IP address? */
if (inet_aton(name, pip)) return 1; if (inet_aton(name, (struct in_addr *)pip)) return 1;
/* In the hosts file? */ /* In the hosts file? */
while ((he= _gethostent()) != nil) { while ((he= _gethostent()) != nil) {
@ -130,7 +131,7 @@ static int cidr_aton(const char *cidr, ipaddr_t *addr, ipaddr_t *mask)
if ((slash= strchr(cidr, '/')) == nil) return 0; if ((slash= strchr(cidr, '/')) == nil) return 0;
*slash++= 0; *slash++= 0;
ok= inet_aton(cidr, &a); ok= inet_aton(cidr, (struct in_addr *)&a);
len= strtoul(slash, &check, 10); len= strtoul(slash, &check, 10);
if (check == slash || *check != 0 || len > 32) ok= 0; if (check == slash || *check != 0 || len > 32) ok= 0;
@ -153,8 +154,9 @@ char *cidr_ntoa(ipaddr_t addr, ipaddr_t mask)
testmask= (testmask << 1) & 0xFFFFFFFFUL; testmask= (testmask << 1) & 0xFFFFFFFFUL;
} }
sprintf(result, "%s/%-2d", inet_ntoa(addr), n); sprintf(result, "%s/%-2d", inet_ntoa(*(struct in_addr *)&addr), n);
if (n == -1) strcpy(strchr(result, '/')+1, inet_ntoa(mask)); if (n == -1) strcpy(strchr(result, '/')+1,
inet_ntoa(*(struct in_addr *)&mask));
return result; return result;
} }
@ -576,7 +578,7 @@ int makedhcp(dhcp_t *dp, u8_t *class, size_t calen, u8_t *client, size_t cilen,
) { ) {
config_t *atname= cmd->next->next; config_t *atname= cmd->next->next;
if (ifno != -1) atname= atname->next; if (ifno != -1) atname= atname->next;
name= atname->word; name= (char *)atname->word;
if (name2ip(&hip, name, ifip) && (ip == 0 || ip == hip)) { if (name2ip(&hip, name, ifip) && (ip == 0 || ip == hip)) {
d= ntohl(hip) ^ ntohl(ifip); d= ntohl(hip) ^ ntohl(ifip);
@ -897,7 +899,7 @@ void printdhcp(dhcp_t *dp)
case TT_IP: { case TT_IP: {
ipaddr_t ip; ipaddr_t ip;
memcpy(&ip, data+i, sizeof(ip)); memcpy(&ip, data+i, sizeof(ip));
printf(" %s", inet_ntoa(ip)); printf(" %s", inet_ntoa(*(struct in_addr *)&ip));
i += sizeof(ip); i += sizeof(ip);
break;} break;}
case TT_NUMBER: { case TT_NUMBER: {

View file

@ -605,7 +605,7 @@ void change_partition(struct part_entry *entry)
} }
sec_to_hst(low, &entry->start_head, &entry->start_sec, &entry->start_cyl); sec_to_hst(low, &entry->start_head, &entry->start_sec, &entry->start_cyl);
sec_to_hst(high, &entry->last_head, &entry->last_sec, &entry->last_cyl); sec_to_hst(high, &entry->last_head, &entry->last_sec, &entry->last_cyl);
printf("Base of partition changed to %ld, size changed to %ld\n", printf("Base of partition changed to %u, size changed to %u\n",
entry->lowsec, entry->size); entry->lowsec, entry->size);
/* Accept the MINIX partition type. Usually ignore foreign types, so this /* Accept the MINIX partition type. Usually ignore foreign types, so this
@ -755,17 +755,17 @@ void adj_base(struct part_entry *pe)
return; return;
if (pe->lowsec + adj < 1) if (pe->lowsec + adj < 1)
printf( printf(
"\t\tThat would make the base %lu and too small\n", pe->lowsec + adj); "\t\tThat would make the base %u and too small\n", pe->lowsec + adj);
else if (pe->size - adj < 1) else if (pe->size - adj < 1)
printf( printf(
"\t\tThat would make the size %lu and too small\n", pe->size - adj); "\t\tThat would make the size %u and too small\n", pe->size - adj);
else else
break; break;
} }
pe->lowsec += adj; pe->lowsec += adj;
pe->size -= adj; pe->size -= adj;
sec_to_hst(pe->lowsec, &pe->start_head, &pe->start_sec, &pe->start_cyl); sec_to_hst(pe->lowsec, &pe->start_head, &pe->start_sec, &pe->start_cyl);
printf("Base of partition adjusted to %ld, size adjusted to %ld\n", printf("Base of partition adjusted to %u, size adjusted to %u\n",
pe->lowsec, pe->size); pe->lowsec, pe->size);
} }
@ -780,13 +780,13 @@ void adj_size(struct part_entry *pe)
if (!get_an_int("\tEnter adjustment to size (an integer): ", &adj)) if (!get_an_int("\tEnter adjustment to size (an integer): ", &adj))
return; return;
if (pe->size + adj >= 1) break; if (pe->size + adj >= 1) break;
printf("\t\tThat would make the size %lu and too small \n", printf("\t\tThat would make the size %u and too small \n",
pe->size + adj); pe->size + adj);
} }
pe->size += adj; pe->size += adj;
sec_to_hst(pe->lowsec + pe->size - 1, sec_to_hst(pe->lowsec + pe->size - 1,
&pe->last_head, &pe->last_sec, &pe->last_cyl); &pe->last_head, &pe->last_sec, &pe->last_cyl);
printf("Size of partition adjusted to %ld\n", pe->size); printf("Size of partition adjusted to %u\n", pe->size);
} }
struct part_entry *ask_partition() struct part_entry *ask_partition()

View file

@ -316,7 +316,7 @@ read_password(const char *prompt, char *pwbuf, size_t pwbuf_len)
tcflag_t saved_flags; tcflag_t saved_flags;
int nopwd; int nopwd;
fprintf(stderr, prompt); fprintf(stderr, "%s", prompt);
if (tcgetattr(STDIN_FILENO, &tios) != 0) if (tcgetattr(STDIN_FILENO, &tios) != 0)
return (fgets(pwbuf, pwbuf_len, stdin) == NULL); return (fgets(pwbuf, pwbuf_len, stdin) == NULL);

View file

@ -122,7 +122,7 @@ void format_track(int ffd, unsigned type, unsigned cyl, unsigned head)
track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE; track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE;
if (lseek(ffd, track_pos, SEEK_SET) == -1) { if (lseek(ffd, track_pos, SEEK_SET) == -1) {
fprintf(stderr, fprintf(stderr,
"format: seeking to cyl %u, head %u (pos %d) failed: %s\n", "format: seeking to cyl %u, head %u (pos %lld) failed: %s\n",
cyl, head, track_pos, strerror(errno)); cyl, head, track_pos, strerror(errno));
exit(1); exit(1);
} }
@ -154,7 +154,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head)
track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE; track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE;
if (lseek(vfd, track_pos, SEEK_SET) == -1) { if (lseek(vfd, track_pos, SEEK_SET) == -1) {
fprintf(stderr, fprintf(stderr,
"format: seeking to cyl %u, head %u (pos %d) failed: %s\n", "format: seeking to cyl %u, head %u (pos %lld) failed: %s\n",
cyl, head, track_pos, strerror(errno)); cyl, head, track_pos, strerror(errno));
exit(1); exit(1);
} }
@ -167,7 +167,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head)
for (sector= 0; sector < nr_sectors; sector++) { for (sector= 0; sector < nr_sectors; sector++) {
if (lseek(vfd, track_pos, SEEK_SET) == -1) { if (lseek(vfd, track_pos, SEEK_SET) == -1) {
fprintf(stderr, fprintf(stderr,
"format: seeking to cyl %u, head %u, sector %u (pos %d) failed: %s\n", "format: seeking to cyl %u, head %u, sector %u (pos %lld) failed: %s\n",
cyl, head, sector, track_pos, strerror(errno)); cyl, head, sector, track_pos, strerror(errno));
exit(1); exit(1);
} }
@ -175,7 +175,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head)
switch (read(vfd, buf, SECTOR_SIZE)) { switch (read(vfd, buf, SECTOR_SIZE)) {
case -1: case -1:
fprintf(stderr, fprintf(stderr,
"format: bad sector at cyl %u, head %u, sector %u (pos %d)\n", "format: bad sector at cyl %u, head %u, sector %u (pos %lld)\n",
cyl, head, sector, track_pos); cyl, head, sector, track_pos);
bad_count++; bad_count++;
break; break;
@ -183,7 +183,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head)
/* Fine. */ /* Fine. */
break; break;
default: default:
fprintf(stderr, "format: short read at pos %d\n", fprintf(stderr, "format: short read at pos %lld\n",
track_pos); track_pos);
bad_count++; bad_count++;
} }

View file

@ -645,7 +645,7 @@ void chksuper()
if(maxsize <= 0) if(maxsize <= 0)
maxsize = LONG_MAX; maxsize = LONG_MAX;
if (sb.s_max_size != maxsize) { if (sb.s_max_size != maxsize) {
printf("warning: expected max size to be %d ", maxsize); printf("warning: expected max size to be %lld ", maxsize);
printf("instead of %d\n", sb.s_max_size); printf("instead of %d\n", sb.s_max_size);
} }
@ -681,7 +681,7 @@ char **clist;
ino = bit; ino = bit;
do { do {
devread(inoblock(ino), inooff(ino), (char *) ip, INODE_SIZE); devread(inoblock(ino), inooff(ino), (char *) ip, INODE_SIZE);
printf("inode %u:\n", ino); printf("inode %llu:\n", ino);
printf(" mode = %6o", ip->i_mode); printf(" mode = %6o", ip->i_mode);
if (input(buf, 80)) ip->i_mode = atoo(buf); if (input(buf, 80)) ip->i_mode = atoo(buf);
printf(" nlinks = %6u", ip->i_nlinks); printf(" nlinks = %6u", ip->i_nlinks);
@ -798,11 +798,12 @@ bit_nr phys;
(!repair || automatic || yes("stop this listing"))) (!repair || automatic || yes("stop this listing")))
*report = 0; *report = 0;
else { else {
if (*report) if (*report) {
if ((w1 & 1) && !(w2 & 1)) if ((w1 & 1) && !(w2 & 1))
printf("%s %d is missing\n", type, bit); printf("%s %d is missing\n", type, bit);
else if (!(w1 & 1) && (w2 & 1)) else if (!(w1 & 1) && (w2 & 1))
printf("%s %d is not free\n", type, bit); printf("%s %d is not free\n", type, bit);
}
} }
} }
@ -853,7 +854,7 @@ void chkilist()
devread(inoblock(ino), inooff(ino), (char *) &mode, devread(inoblock(ino), inooff(ino), (char *) &mode,
sizeof(mode)); sizeof(mode));
if (mode != I_NOT_ALLOC) { if (mode != I_NOT_ALLOC) {
printf("mode inode %u not cleared", ino); printf("mode inode %llu not cleared", ino);
if (yes(". clear")) devwrite(inoblock(ino), if (yes(". clear")) devwrite(inoblock(ino),
inooff(ino), nullbuf, INODE_SIZE); inooff(ino), nullbuf, INODE_SIZE);
} }
@ -879,7 +880,7 @@ void counterror(ino_t ino)
} }
devread(inoblock(ino), inooff(ino), (char *) &inode, INODE_SIZE); devread(inoblock(ino), inooff(ino), (char *) &inode, INODE_SIZE);
count[ino] += inode.i_nlinks; /* it was already subtracted; add it back */ count[ino] += inode.i_nlinks; /* it was already subtracted; add it back */
printf("%5u %5u %5u", ino, (unsigned) inode.i_nlinks, count[ino]); printf("%5llu %5u %5u", ino, (unsigned) inode.i_nlinks, count[ino]);
if (yes(" adjust")) { if (yes(" adjust")) {
if ((inode.i_nlinks = count[ino]) == 0) { if ((inode.i_nlinks = count[ino]) == 0) {
fatal("internal error (counterror)"); fatal("internal error (counterror)");
@ -939,7 +940,7 @@ void list(ino_t ino, d_inode *ip)
firstlist = 0; firstlist = 0;
printf(" inode permission link size name\n"); printf(" inode permission link size name\n");
} }
printf("%6u ", ino); printf("%6llu ", ino);
switch (ip->i_mode & I_TYPE) { switch (ip->i_mode & I_TYPE) {
case I_REGULAR: putchar('-'); break; case I_REGULAR: putchar('-'); break;
case I_DIRECTORY: putchar('d'); break; case I_DIRECTORY: putchar('d'); break;
@ -1023,11 +1024,12 @@ int chkdots(ino_t ino, off_t pos, dir_struct *dp, ino_t exp)
char printable_name[4 * MFS_NAME_MAX + 1]; char printable_name[4 * MFS_NAME_MAX + 1];
if (dp->d_inum != exp) { if (dp->d_inum != exp) {
make_printable_name(printable_name, dp->mfs_d_name, sizeof(dp->mfs_d_name)); make_printable_name(printable_name, dp->mfs_d_name,
sizeof(dp->mfs_d_name));
printf("bad %s in ", printable_name); printf("bad %s in ", printable_name);
printpath(1, 0); printpath(1, 0);
printf("%s is linked to %u ", printable_name, dp->d_inum); printf("%s is linked to %u ", printable_name, dp->d_inum);
printf("instead of %u)", exp); printf("instead of %llu)", exp);
setbit(spec_imap, (bit_nr) ino); setbit(spec_imap, (bit_nr) ino);
setbit(spec_imap, (bit_nr) dp->d_inum); setbit(spec_imap, (bit_nr) dp->d_inum);
setbit(spec_imap, (bit_nr) exp); setbit(spec_imap, (bit_nr) exp);
@ -1038,8 +1040,9 @@ int chkdots(ino_t ino, off_t pos, dir_struct *dp, ino_t exp)
return(0); return(0);
} }
} else if (pos != (dp->mfs_d_name[1] ? DIR_ENTRY_SIZE : 0)) { } else if (pos != (dp->mfs_d_name[1] ? DIR_ENTRY_SIZE : 0)) {
make_printable_name(printable_name, dp->mfs_d_name, sizeof(dp->mfs_d_name)); make_printable_name(printable_name, dp->mfs_d_name,
printf("warning: %s has offset %d in ", printable_name, pos); sizeof(dp->mfs_d_name));
printf("warning: %s has offset %lld in ", printable_name, pos);
printpath(1, 0); printpath(1, 0);
printf("%s is linked to %u)\n", printable_name, dp->d_inum); printf("%s is linked to %u)\n", printable_name, dp->d_inum);
setbit(spec_imap, (bit_nr) ino); setbit(spec_imap, (bit_nr) ino);
@ -1206,7 +1209,7 @@ off_t pos;
case 2: printf("DOUBLE INDIRECT"); break; case 2: printf("DOUBLE INDIRECT"); break;
default: printf("VERY INDIRECT"); default: printf("VERY INDIRECT");
} }
printf(", pos = %d)\n", pos); printf(", pos = %lld)\n", pos);
} }
/* Found the given zone in the given inode. Check it, and if ok, mark it /* Found the given zone in the given inode. Check it, and if ok, mark it
@ -1425,7 +1428,7 @@ int chkinode(ino_t ino, d_inode *ip)
{ {
if (ino == ROOT_INODE && (ip->i_mode & I_TYPE) != I_DIRECTORY) { if (ino == ROOT_INODE && (ip->i_mode & I_TYPE) != I_DIRECTORY) {
printf("root inode is not a directory "); printf("root inode is not a directory ");
printf("(ino = %u, mode = %o)\n", ino, ip->i_mode); printf("(ino = %llu, mode = %o)\n", ino, ip->i_mode);
fatal(""); fatal("");
} }
if (ip->i_nlinks == 0) { if (ip->i_nlinks == 0) {
@ -1460,7 +1463,7 @@ dir_struct *dp;
stk.st_next = ftop; stk.st_next = ftop;
ftop = &stk; ftop = &stk;
if (bitset(spec_imap, (bit_nr) ino)) { if (bitset(spec_imap, (bit_nr) ino)) {
printf("found inode %u: ", ino); printf("found inode %llu: ", ino);
printpath(0, 1); printpath(0, 1);
} }
visited = bitset(imap, (bit_nr) ino); visited = bitset(imap, (bit_nr) ino);

View file

@ -16,6 +16,7 @@
* that copyright notice. * that copyright notice.
*/ */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <arpa/nameser.h> #include <arpa/nameser.h>
@ -30,12 +31,14 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/ioc_net.h> #include <sys/ioc_net.h>
#include <net/netlib.h> #include <net/netlib.h>
#include <net/gen/in.h> #include <net/gen/in.h>
#include <net/gen/tcp.h> #include <net/gen/tcp.h>
#include <net/gen/tcp_io.h> #include <net/gen/tcp_io.h>
#include <arpa/inet.h>
extern int h_errno; extern int h_errno;
@ -387,7 +390,7 @@ gethostinfo(name)
cp[-1] = '.'; cp[-1] = '.';
return (hp); return (hp);
} }
if (n == 0 && (cp = __hostalias(name))) { if (n == 0 && (cp = (char *)__hostalias(name))) {
if (verbose) if (verbose)
printf("Aliased to \"%s\"\n", cp); printf("Aliased to \"%s\"\n", cp);
_res.options |= RES_DEFNAMES; _res.options |= RES_DEFNAMES;
@ -432,6 +435,7 @@ getdomaininfo(name, domain)
static int static int
getinfo(name, domain, type) getinfo(name, domain, type)
char *name, *domain; char *name, *domain;
int type;
{ {
HEADER *hp; HEADER *hp;
@ -605,13 +609,14 @@ pr_rr(cp, msg, file, filter)
else else
doprint = 0; doprint = 0;
if (doprint) if (doprint) {
if (verbose) if (verbose)
fprintf(file,"%s\t%d%s\t%s", fprintf(file,"%s\t%d%s\t%s",
name, ttl, pr_class(class), pr_type(type)); name, ttl, pr_class(class), pr_type(type));
else { else {
fprintf(file,"%s%s %s",name, pr_class(class), pr_type(type)); fprintf(file,"%s%s %s",name, pr_class(class), pr_type(type));
} }
}
if (verbose) if (verbose)
punc = '\t'; punc = '\t';
else else
@ -742,14 +747,14 @@ pr_rr(cp, msg, file, filter)
cp += sizeof(u_long); cp += sizeof(u_long);
proto = *cp++; proto = *cp++;
protop = getprotobynumber(proto); protop = getprotobynumber(proto);
if (doprint) if (doprint) {
if (protop) if (protop)
fprintf(file,"%c%s %s", punc, fprintf(file,"%c%s %s", punc,
inet_ntoa(inaddr), protop->p_name); inet_ntoa(inaddr), protop->p_name);
else else
fprintf(file,"%c%s %d", punc, fprintf(file,"%c%s %d", punc,
inet_ntoa(inaddr), proto); inet_ntoa(inaddr), proto);
}
n = 0; n = 0;
while (cp < cp1 + dlen) { while (cp < cp1 + dlen) {
c = *cp++; c = *cp++;
@ -759,11 +764,12 @@ pr_rr(cp, msg, file, filter)
if (protop) if (protop)
servp = getservbyport (htons(n), servp = getservbyport (htons(n),
protop->p_name); protop->p_name);
if (doprint) if (doprint) {
if (servp) if (servp)
fprintf(file, " %s", servp->s_name); fprintf(file, " %s", servp->s_name);
else else
fprintf(file, " %d", n); fprintf(file, " %d", n);
}
} }
c <<= 1; c <<= 1;
} while (++n & 07); } while (++n & 07);
@ -776,7 +782,7 @@ pr_rr(cp, msg, file, filter)
cp += dlen; cp += dlen;
} }
if (cp != cp1 + dlen) if (cp != cp1 + dlen)
fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen); fprintf(file,"packet size error (%p != %p)\n", cp, cp1+dlen);
if (doprint) if (doprint)
fprintf(file,"\n"); fprintf(file,"\n");
return (cp); return (cp);
@ -985,7 +991,7 @@ ListHosts(namePtr, queryType)
*/ */
msglen = res_mkquery(QUERY, namePtr, C_IN, T_NS, msglen = res_mkquery(QUERY, namePtr, C_IN, T_NS,
(char *)0, 0, (struct rrec *)0, (char *)0, 0, 0,
(char *)&buf, sizeof(buf)); (char *)&buf, sizeof(buf));
if (msglen < 0) { if (msglen < 0) {
@ -1133,7 +1139,7 @@ again:
* *
*/ */
msglen = res_mkquery(QUERY, namePtr, getclass, T_AXFR, msglen = res_mkquery(QUERY, namePtr, getclass, T_AXFR,
(char *)0, 0, (struct rrec *)0, (char *)0, 0, 0,
(char *) &buf, sizeof(buf)); (char *) &buf, sizeof(buf));
if (msglen < 0) { if (msglen < 0) {
if (_res.options & RES_DEBUG) { if (_res.options & RES_DEBUG) {
@ -1172,7 +1178,8 @@ again:
return ERROR; return ERROR;
} }
if (_res.options & RES_DEBUG || verbose) if (_res.options & RES_DEBUG || verbose)
printf("Trying %s\n", inet_ntoa(tcpconf.nwtc_remaddr)); printf("Trying %s\n", inet_ntoa(*(struct in_addr *)
&tcpconf.nwtc_remaddr));
clopt.nwtcl_flags= 0; clopt.nwtcl_flags= 0;
result= ioctl(tcp_fd, NWIOTCPCONN, &clopt); result= ioctl(tcp_fd, NWIOTCPCONN, &clopt);
if (result == 0) if (result == 0)

View file

@ -29,6 +29,7 @@ Created: Jan 27, 1992 by Philip Homburg
#include <netdb.h> #include <netdb.h>
#include <net/gen/socket.h> #include <net/gen/socket.h>
#include <arpa/inet.h>
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <resolv.h> #include <resolv.h>
#include <net/gen/dhcp.h> #include <net/gen/dhcp.h>
@ -181,7 +182,7 @@ char *argv[];
if (do_ip) if (do_ip)
{ {
printf("%s%s", first_print ? "" : " ", printf("%s%s", first_print ? "" : " ",
inet_ntoa(nwio_ipconf.nwic_ipaddr)); inet_ntoa(*(struct in_addr *)&nwio_ipconf.nwic_ipaddr));
first_print= 0; first_print= 0;
} }
if (do_asc_ip || do_hostname) if (do_asc_ip || do_hostname)
@ -256,7 +257,8 @@ char *argv[];
else else
{ {
/* No host name anywhere. Use the IP address. */ /* No host name anywhere. Use the IP address. */
hostname= inet_ntoa(nwio_ipconf.nwic_ipaddr); hostname= inet_ntoa(*(struct in_addr *)
&nwio_ipconf.nwic_ipaddr);
domain= NULL; domain= NULL;
} }

View file

@ -17,6 +17,7 @@ ifconfig.c
#include <net/gen/in.h> #include <net/gen/in.h>
#include <net/gen/ip_io.h> #include <net/gen/ip_io.h>
#include <net/gen/inet.h> #include <net/gen/inet.h>
#include <arpa/inet.h>
#if __STDC__ #if __STDC__
#define PROTO(x,y) x y #define PROTO(x,y) x y
@ -36,6 +37,7 @@ PROTO (int main, (int argc, char *argv[]) );
char *prog_name; char *prog_name;
int
main(argc, argv) main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@ -167,12 +169,14 @@ char *argv[];
else else
{ {
printf("%s: address %s", device_s, printf("%s: address %s", device_s,
inet_ntoa(ipconf.nwic_ipaddr)); inet_ntoa(*(struct in_addr *)
&ipconf.nwic_ipaddr));
if (ipconf.nwic_flags & NWIC_NETMASK_SET) if (ipconf.nwic_flags & NWIC_NETMASK_SET)
{ {
printf(" netmask %s", printf(" netmask %s",
inet_ntoa(ipconf.nwic_netmask)); inet_ntoa(*(struct in_addr *)
&ipconf.nwic_netmask));
} }
#ifdef NWIC_MTU_SET #ifdef NWIC_MTU_SET
if (ipconf.nwic_mtu) if (ipconf.nwic_mtu)

View file

@ -331,7 +331,7 @@ void parse()
/* Scan through the file looking for starting lines */ /* Scan through the file looking for starting lines */
if ((ch = fgetc(zin)) == EOF) if ((ch = fgetc(zin)) == EOF)
stop(); /* Get first char on the line */ stop(); /* Get first char on the line */
if (ch != '#') if (ch != '#') {
if (proc) { /* If not # and we're processing */ if (proc) { /* If not # and we're processing */
(void)putchar(ch); /* then print the line */ (void)putchar(ch); /* then print the line */
Print; Print;
@ -340,6 +340,7 @@ void parse()
Goto; /* else just skip the line */ Goto; /* else just skip the line */
continue; continue;
} }
}
ch = fgetarg(zin, word); /* Get the word after the # */ ch = fgetarg(zin, word); /* Get the word after the # */

View file

@ -32,6 +32,7 @@
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/sem.h> #include <sys/sem.h>
#include <err.h>
/* remove _() stuff */ /* remove _() stuff */
#define _(a) a #define _(a) a
@ -343,7 +344,7 @@ void do_shm (char format)
break; break;
default: default:
printf("0x%08x ",ipcp->KEY ); printf("0x%08lx ",ipcp->KEY );
if (pw) if (pw)
printf ("%-10d %-10.10s", shmid, pw->pw_name); printf ("%-10d %-10.10s", shmid, pw->pw_name);
else else
@ -450,7 +451,7 @@ void do_sem (char format)
break; break;
default: default:
printf("0x%08x ", ipcp->KEY); printf("0x%08lx ", ipcp->KEY);
if (pw) if (pw)
printf ("%-10d %-10.10s", semid, pw->pw_name); printf ("%-10d %-10.10s", semid, pw->pw_name);
else else

View file

@ -33,6 +33,7 @@
#include <net/gen/udp.h> #include <net/gen/udp.h>
#include <net/gen/udp_hdr.h> #include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h> #include <net/gen/udp_io.h>
#include <arpa/inet.h>
#define MAX_SOLICITATIONS 3 /* # router solicitations. */ #define MAX_SOLICITATIONS 3 /* # router solicitations. */
#define SOLICITATION_INTERVAL 3 /* Secs between solicitate retries. */ #define SOLICITATION_INTERVAL 3 /* Secs between solicitate retries. */
@ -127,7 +128,7 @@ char *addr2name(ipaddr_t host)
return hostent == nil ? inet_ntoa(host) : hostent->h_name; return hostent == nil ? inet_ntoa(host) : hostent->h_name;
} }
#else #else
#define addr2name(host) inet_ntoa(host) #define addr2name(host) inet_ntoa(*(struct in_addr *)&(host))
#endif #endif
void print_table(void) void print_table(void)

View file

@ -374,9 +374,10 @@ char *path;
dir_ptr = (struct dir_entry *) Hs_Vol_Desc->root_dir_entry; dir_ptr = (struct dir_entry *) Hs_Vol_Desc->root_dir_entry;
/* If we look for the root we already have the right entry */ /* If we look for the root we already have the right entry */
if (path[0] == '/') if (path[0] == '/') {
if (strlen(path) == 1) return dir_ptr; if (strlen(path) == 1) return dir_ptr;
else name_index = 1; /* first name in path */ else name_index = 1; /* first name in path */
}
/* Keep searching for the path elements until all are found */ /* Keep searching for the path elements until all are found */
while (!last_in_path) while (!last_in_path)

View file

@ -142,7 +142,7 @@ int lp;
char buf[BUFSIZ]; char buf[BUFSIZ];
int count, column, line, ncols = 80, nlines = 66; int count, column, line, ncols = 80, nlines = 66;
int flush(void) void flush(void)
/* Copy the characters in the output buffer to the printer, with retries if /* Copy the characters in the output buffer to the printer, with retries if
* out of paper. * out of paper.
*/ */

View file

@ -199,8 +199,8 @@ SCSI tape drive %s:\n\
(long) mtget.mt_fileno, (long) mtget.mt_fileno,
(long) mtget.mt_blkno, (long) mtget.mt_blkno,
(long) mtget.mt_resid); (long) mtget.mt_resid);
printf(mtget.mt_blksiz == 0 ? "variable\n" : "%d\n", if (mtget.mt_blksiz == 0) printf("variable\n");
mtget.mt_blksiz); else printf("%d\n", mtget.mt_blksiz);
} }
} }
if (r < 0) { if (r < 0) {

View file

@ -42,6 +42,7 @@ static const char version[] = "2.7";
#include <net/gen/udp_hdr.h> #include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h> #include <net/gen/udp_io.h>
#include <net/gen/dhcp.h> #include <net/gen/dhcp.h>
#include <arpa/inet.h>
#include <paths.h> #include <paths.h>
#include <minix/paths.h> #include <minix/paths.h>
@ -133,6 +134,11 @@ static char *nowgmt(void)
return timegmt(now); return timegmt(now);
} }
static char *my_ntoa(ipaddr_t addr)
{
return inet_ntoa(*(struct in_addr *)&addr);
}
#define PC(n) ((void) sizeof(char [sizeof(*(n)) == 1]), (char *) (n)) #define PC(n) ((void) sizeof(char [sizeof(*(n)) == 1]), (char *) (n))
#define namecpy(n1, n2) strcpy(PC(n1), PC(n2)) #define namecpy(n1, n2) strcpy(PC(n1), PC(n2))
#define namecat(n1, n2) strcat(PC(n1), PC(n2)) #define namecat(n1, n2) strcat(PC(n1), PC(n2))
@ -306,7 +312,7 @@ static int print_qrr(dns_t *dp, size_t size, u8_t *cp0, int q)
switch (*ep++) { switch (*ep++) {
case 'i': case 'i':
if (cp + sizeof(u32_t) > rlim) return -1; if (cp + sizeof(u32_t) > rlim) return -1;
printf(" %s", inet_ntoa(upack32(cp))); printf(" %s", my_ntoa(upack32(cp)));
cp += sizeof(u32_t); cp += sizeof(u32_t);
break; break;
case 'l': case 'l':
@ -820,7 +826,7 @@ static void init_config(ipaddr_t ifip)
if (debug >= 2) { if (debug >= 2) {
printf("%s: I am nonamed %s at %s:%u\n", printf("%s: I am nonamed %s at %s:%u\n",
nowgmt(), version, inet_ntoa(my_ip), ntohs(my_port)); nowgmt(), version, my_ntoa(my_ip), ntohs(my_port));
} }
httl= HTONL(HTTL); httl= HTONL(HTTL);
@ -1090,7 +1096,7 @@ static int query_chaos(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen)
/* pack16(cp, htonl(RDLENGTH)) */ /* pack16(cp, htonl(RDLENGTH)) */
cp += sizeof(u16_t); cp += sizeof(u16_t);
sprintf((char *) cp + 1, "nonamed %s at %s:%u", sprintf((char *) cp + 1, "nonamed %s at %s:%u",
version, inet_ntoa(my_ip), ntohs(my_port)); version, my_ntoa(my_ip), ntohs(my_port));
r= strlen((char *) cp + 1) + 1; r= strlen((char *) cp + 1) + 1;
pack16(cp - sizeof(u16_t), htons(r)); pack16(cp - sizeof(u16_t), htons(r));
*cp= r-1; *cp= r-1;
@ -1347,7 +1353,7 @@ static void refresh_cache(void)
if (debug >= 1) { if (debug >= 1) {
printf("Refresh to %s:%u:\n", printf("Refresh to %s:%u:\n",
inet_ntoa(current_named()), ntohs(named_port)); my_ntoa(current_named()), ntohs(named_port));
dns_tell(0, &udp.dns, dlen); dns_tell(0, &udp.dns, dlen);
} }
ulen= offsetof(udp_dns_t, dns) + dlen; ulen= offsetof(udp_dns_t, dns) + dlen;
@ -1389,7 +1395,7 @@ static int job_read_udp(void *data, int expired)
if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(HEADER))) return 1; if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(HEADER))) return 1;
if (debug >= 1) { if (debug >= 1) {
printf("%s:%u UDP ", inet_ntoa(udp.hdr.uih_src_addr), printf("%s:%u UDP ", my_ntoa(udp.hdr.uih_src_addr),
ntohs(udp.hdr.uih_src_port)); ntohs(udp.hdr.uih_src_port));
dns_tell(0, &udp.dns, dlen); dns_tell(0, &udp.dns, dlen);
} }
@ -1414,7 +1420,7 @@ static int job_read_udp(void *data, int expired)
i_named= i; i_named= i;
if (debug >= 1) { if (debug >= 1) {
printf("Current named = %s\n", printf("Current named = %s\n",
inet_ntoa(current_named())); my_ntoa(current_named()));
} }
stop_searching(); stop_searching();
force_expire(job_find_named); force_expire(job_find_named);
@ -1442,7 +1448,7 @@ static int job_read_udp(void *data, int expired)
udp.dns.hdr.id= id; udp.dns.hdr.id= id;
udp.hdr.uih_dst_addr= ip; udp.hdr.uih_dst_addr= ip;
udp.hdr.uih_dst_port= port; udp.hdr.uih_dst_port= port;
if (debug >= 1) printf("To client %s:%u\n", inet_ntoa(ip), ntohs(port)); if (debug >= 1) printf("To client %s:%u\n", my_ntoa(ip), ntohs(port));
} else { } else {
/* A query. */ /* A query. */
if (udp.dns.hdr.qdcount != HTONS(1)) return 1; if (udp.dns.hdr.qdcount != HTONS(1)) return 1;
@ -1450,8 +1456,8 @@ static int job_read_udp(void *data, int expired)
if(localonly) { if(localonly) {
/* Check if it's a local query. */ /* Check if it's a local query. */
if(ntohl(udp.hdr.uih_src_addr) != LOCALHOST) { if(ntohl(udp.hdr.uih_src_addr) != LOCALHOST) {
syslog(LOG_WARNING, "nonamed: dropped query from %s", syslog(LOG_WARNING, "nonamed: dropped query from %s",
inet_ntoa(udp.hdr.uih_src_addr)); my_ntoa(udp.hdr.uih_src_addr));
return 1; return 1;
} }
} }
@ -1466,7 +1472,7 @@ static int job_read_udp(void *data, int expired)
/* Send an UDP DNS reply. */ /* Send an UDP DNS reply. */
if (debug >= 1) { if (debug >= 1) {
printf("%s:%u UDP ", inet_ntoa(udp.hdr.uih_dst_addr), printf("%s:%u UDP ", my_ntoa(udp.hdr.uih_dst_addr),
ntohs(udp.hdr.uih_dst_port)); ntohs(udp.hdr.uih_dst_port));
dns_tell(0, &udp.dns, dlen); dns_tell(0, &udp.dns, dlen);
} }
@ -1482,7 +1488,7 @@ static int job_read_udp(void *data, int expired)
} }
if (debug >= 1) { if (debug >= 1) {
printf("To named %s:%u\n", printf("To named %s:%u\n",
inet_ntoa(current_named()), ntohs(named_port)); my_ntoa(current_named()), ntohs(named_port));
} }
} }
} }
@ -1703,7 +1709,7 @@ static void tcp_dns_tell(int fd, u8_t *buf)
if (ioctl(fd, NWIOGTCPCONF, &tcpconf) < 0) { if (ioctl(fd, NWIOGTCPCONF, &tcpconf) < 0) {
printf("??\?:?? TCP "); printf("??\?:?? TCP ");
} else { } else {
printf("%s:%u TCP ", inet_ntoa(tcpconf.nwtc_remaddr), printf("%s:%u TCP ", my_ntoa(tcpconf.nwtc_remaddr),
ntohs(tcpconf.nwtc_remport)); ntohs(tcpconf.nwtc_remport));
} }
dns_tell(0, oct2dns(buf + sizeof(u16_t)), ntohs(upack16(buf))); dns_tell(0, oct2dns(buf + sizeof(u16_t)), ntohs(upack16(buf)));
@ -1975,7 +1981,7 @@ static void named_probe(ipaddr_t ip)
pack16(udp.dns.data+1, HTONS(T_NS)); pack16(udp.dns.data+1, HTONS(T_NS));
pack16(udp.dns.data+3, HTONS(C_IN)); pack16(udp.dns.data+3, HTONS(C_IN));
if (debug >= 1) { if (debug >= 1) {
printf("PROBE %s ", inet_ntoa(ip)); printf("PROBE %s ", my_ntoa(ip));
dns_tell(0, &udp.dns, dlen); dns_tell(0, &udp.dns, dlen);
} }

View file

@ -1806,7 +1806,7 @@ void m_dump(int ev, object_t *op)
pe->sysind, pe->sysind,
chs[0], chs[1], chs[2]); chs[0], chs[1], chs[2]);
dos2chs(&pe->last_head, chs); dos2chs(&pe->last_head, chs);
printf("%6d%5d%4d%10lu%10ld%9lu", printf("%6d%5d%4d%10u%10u%9u",
chs[0], chs[1], chs[2], chs[0], chs[1], chs[2],
pe->lowsec, pe->lowsec,
howend == SIZE ? pe->size : pe->size + pe->lowsec - 1, howend == SIZE ? pe->size : pe->size + pe->lowsec - 1,

View file

@ -191,7 +191,7 @@ void show_part(struct part_entry *p)
printf("%3d ", (n-1) / 2); printf("%3d ", (n-1) / 2);
show_chs(p->lowsec); show_chs(p->lowsec);
show_chs(p->lowsec + p->size - 1); show_chs(p->lowsec + p->size - 1);
printf(" %8lu %8lu %7lu\n", p->lowsec, p->size, p->size / 2); printf(" %8u %8u %7u\n", p->lowsec, p->size, p->size / 2);
} }
void usage(void) void usage(void)
@ -373,7 +373,7 @@ void distribute(void)
if (pe->bootind & EXIST_FLAG) { if (pe->bootind & EXIST_FLAG) {
if (base > pe->lowsec) { if (base > pe->lowsec) {
fprintf(stderr, fprintf(stderr,
"%s: fixed partition %ld is preceded by too big partitions/holes\n", "%s: fixed partition %u is preceded by too big partitions/holes\n",
arg0, ((pe - table) - 1) / 2); arg0, ((pe - table) - 1) / 2);
exit(1); exit(1);
} }

View file

@ -2,8 +2,6 @@
vmd/cmd/simple/pr_routes.c vmd/cmd/simple/pr_routes.c
*/ */
#define _POSIX_C_SOURCE 2
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <errno.h> #include <errno.h>
@ -21,6 +19,7 @@ vmd/cmd/simple/pr_routes.c
#include <net/gen/route.h> #include <net/gen/route.h>
#include <netdb.h> #include <netdb.h>
#include <net/gen/inet.h> #include <net/gen/inet.h>
#include <arpa/inet.h>
#define N_IF 64 /* More than enough? */ #define N_IF 64 /* More than enough? */
@ -192,9 +191,10 @@ static char *cidr2a(ipaddr_t addr, ipaddr_t mask)
testmask= (testmask << 1) & 0xFFFFFFFF; testmask= (testmask << 1) & 0xFFFFFFFF;
} }
sprintf(result, "%s/%-2d", inet_ntoa(addr), n); sprintf(result, "%s/%-2d", inet_ntoa(*(struct in_addr *)&addr), n);
if (n == -1) if (n == -1)
strcpy(strchr(result, '/')+1, inet_ntoa(mask)); strcpy(strchr(result, '/')+1,
inet_ntoa(*(struct in_addr *)&mask));
return result; return result;
} }
@ -207,7 +207,8 @@ static void print_route(nwio_route_t *route)
printf("%*s ", if_width, printf("%*s ", if_width,
ifname ? ifname : get_ifname(route->nwr_ifaddr)); ifname ? ifname : get_ifname(route->nwr_ifaddr));
printf("%*s ", dest_width, cidr2a(route->nwr_dest, route->nwr_netmask)); printf("%*s ", dest_width, cidr2a(route->nwr_dest, route->nwr_netmask));
printf("%*s ", gateway_width, inet_ntoa(route->nwr_gateway)); printf("%*s ", gateway_width,
inet_ntoa(*(struct in_addr *)&route->nwr_gateway));
printf("%*lu ", dist_width, (unsigned long) route->nwr_dist); printf("%*lu ", dist_width, (unsigned long) route->nwr_dist);
printf("%*ld ", pref_width, (long) route->nwr_pref); printf("%*ld ", pref_width, (long) route->nwr_pref);
printf("%*lu", mtu_width, (long) route->nwr_mtu); printf("%*lu", mtu_width, (long) route->nwr_mtu);
@ -259,7 +260,8 @@ static void fill_iftab(void)
if (iftab[j] == iftab[i]) if (iftab[j] == iftab[i])
{ {
fatal("duplicate address in ip%d and ip%d: %s", fatal("duplicate address in ip%d and ip%d: %s",
i, j, inet_ntoa(iftab[i])); i, j,
inet_ntoa(*(struct in_addr *)&iftab[i]));
} }
} }
@ -280,7 +282,7 @@ static char *get_ifname(ipaddr_t addr)
return name; return name;
} }
return inet_ntoa(addr); return inet_ntoa(*(struct in_addr *)&addr);
} }
static void fatal(char *fmt, ...) static void fatal(char *fmt, ...)

View file

@ -1,7 +1,7 @@
#include <minix/paths.h> #include <minix/paths.h>
#include <sys/ioc_memory.h> #include <sys/ioctl.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -36,6 +36,7 @@ Changed: Dec 11, 2000 by Kees J. Bot
#include <net/gen/if_ether.h> #include <net/gen/if_ether.h>
#include <net/gen/ip_io.h> #include <net/gen/ip_io.h>
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <arpa/inet.h>
#define MAX_RARP_RETRIES 5 #define MAX_RARP_RETRIES 5
#define RARP_TIMEOUT 5 #define RARP_TIMEOUT 5
@ -143,7 +144,8 @@ static void rarp_reply(ethernet_t *ep, char *hostname, ipaddr_t ip_addr,
if (debug >= 1) { if (debug >= 1) {
printf("%s: Replying %s (%s) to %s\n", printf("%s: Replying %s (%s) to %s\n",
ethdev(ep->n), inet_ntoa(ip_addr), hostname, ether_ntoa(&eth_addr)); ethdev(ep->n), inet_ntoa(*(struct in_addr *)&ip_addr), hostname,
ether_ntoa(&eth_addr));
} }
(void) write(ep->eth_fd, &rarp46, sizeof(rarp46)); (void) write(ep->eth_fd, &rarp46, sizeof(rarp46));
} }
@ -290,8 +292,8 @@ int main(int argc, char **argv)
close(fd); close(fd);
if (debug >= 1) { if (debug >= 1) {
printf("%s: IP address is %s / ", printf("%s: IP address is %s / ",
ipdev(ep->n), inet_ntoa(ep->ip_addr)); ipdev(ep->n), inet_ntoa(*(struct in_addr *)&ep->ip_addr));
printf("%s\n", inet_ntoa(ep->ip_mask)); printf("%s\n", inet_ntoa(*(struct in_addr *)&ep->ip_mask));
} }
} }

View file

@ -220,7 +220,7 @@ int main(int argc, char **argv)
if (nbytes > 0) { if (nbytes > 0) {
off_t kBpts; off_t kBpts;
fprintf(stderr, "%d kB / %ld.%ld s = ", fprintf(stderr, "%lld kB / %ld.%ld s = ",
(nbytes + 512) / 1024, (nbytes + 512) / 1024,
tenthsec / 10, tenthsec % 10); tenthsec / 10, tenthsec % 10);
if (tenthsec < 5) if (tenthsec < 5)
@ -230,12 +230,12 @@ int main(int argc, char **argv)
seconds = (tenthsec + 5) / 10; seconds = (tenthsec + 5) / 10;
kBpts= (nbytes + 512L * seconds) kBpts= (nbytes + 512L * seconds)
/ (1024L * seconds); / (1024L * seconds);
fprintf(stderr, "%d kB/s\n", kBpts); fprintf(stderr, "%lld kB/s\n", kBpts);
} else { } else {
kBpts= (100 * nbytes + 512L * tenthsec) kBpts= (100 * nbytes + 512L * tenthsec)
/ (1024L * tenthsec); / (1024L * tenthsec);
fprintf(stderr, "%d.%d kB/s\n", fprintf(stderr, "%lld.%d kB/s\n",
kBpts/10, kBpts%10); kBpts/10, (int)(kBpts%10));
} }
} }
} }
@ -246,10 +246,10 @@ int main(int argc, char **argv)
tenthms= (tenthsec * 1000 + nseeks/2) / nseeks; tenthms= (tenthsec * 1000 + nseeks/2) / nseeks;
fprintf(stderr, fprintf(stderr,
"%d seeks / %ld.%ld s = %ld seeks/s = %d.%d ms/seek\n", "%lld seeks / %ld.%ld s = %lld seeks/s = %lld.%d ms/seek\n",
nseeks, tenthsec / 10, tenthsec % 10, nseeks, tenthsec / 10, tenthsec % 10,
(nseeks * 10 + tenthsec/2) / tenthsec, (nseeks * 10 + tenthsec/2) / tenthsec,
tenthms / 10, tenthms % 10); tenthms / 10, (int)(tenthms % 10));
for (rpm= 3600; rpm <= 7200; rpm+= 1800) { for (rpm= 3600; rpm <= 7200; rpm+= 1800) {
int rotms = (10000L / 2 * 60 + rpm/2) / rpm; int rotms = (10000L / 2 * 60 + rpm/2) / rpm;
@ -263,8 +263,9 @@ int main(int argc, char **argv)
} else { } else {
fprintf(stderr, ", "); fprintf(stderr, ", ");
} }
fprintf(stderr, "%d.%d ms (%d rpm)", fprintf(stderr, "%lld.%d ms (%d rpm)",
(tenthms - rotms) / 10, (tenthms - rotms) % 10, (tenthms - rotms) / 10,
(int)((tenthms - rotms) % 10),
rpm); rpm);
} }
if (disc) fputc('\n', stdout); if (disc) fputc('\n', stdout);

View file

@ -1208,8 +1208,10 @@ void apply_mkold(const char *file, const char *err)
return; return;
} }
fprintf(stderr, "made %s look old", file); fprintf(stderr, "made %s look old", file);
fprintf(stderr, err == nil ? "\n" : " due to a remote problem: %s\n", if (err != nil)
err); fprintf(stderr, " due to a remote problem: %s\n", err);
else
fprintf(stderr, "\n");
} }
void apply_chmod(const char *file, mode_t mode, uid_t uid, gid_t gid, int talk) void apply_chmod(const char *file, mode_t mode, uid_t uid, gid_t gid, int talk)

View file

@ -152,7 +152,7 @@ unsigned char text_read_ub(void *addr)
vaddr= (unsigned long)addr; vaddr= (unsigned long)addr;
vaddr &= ~TRAP_BIT; vaddr &= ~TRAP_BIT;
v= ptrace(T_READB_INS, victim_pid, vaddr, 0); v= ptrace(T_READB_INS, victim_pid, (void *)vaddr, 0);
if (v < 0) if (v < 0)
{ {
fprintf(stderr, fprintf(stderr,
@ -180,7 +180,7 @@ void text_write_ub(void *addr, unsigned char value)
vaddr= (unsigned long)addr; vaddr= (unsigned long)addr;
vaddr &= ~TRAP_BIT; vaddr &= ~TRAP_BIT;
v= ptrace(T_WRITEB_INS, victim_pid, vaddr, value); v= ptrace(T_WRITEB_INS, victim_pid, (void *)vaddr, value);
if (v < 0) if (v < 0)
{ {
fprintf(stderr, fprintf(stderr,

View file

@ -1429,7 +1429,7 @@ int main(int argc, char **argv)
startprocess(slave, s_mach, s_dir, 0); startprocess(slave, s_mach, s_dir, 0);
} else { } else {
/* synctree machine1:dir1 machine2:dir2 */ /* synctree machine1:dir1 machine2:dir2 */
if (pipe(m2m) < 0) perrx(pipe); if (pipe(m2m) < 0) perrx("pipe");
switch (s_pid= fork()) { switch (s_pid= fork()) {
case -1: case -1:

View file

@ -22,6 +22,8 @@ tcpd.c
#include <netdb.h> #include <netdb.h>
#include <net/gen/tcp.h> #include <net/gen/tcp.h>
#include <net/gen/tcp_io.h> #include <net/gen/tcp_io.h>
#include <arpa/inet.h>
#include <minix/minlib.h>
/* This program can be compiled to be paranoid, i.e. check incoming connection /* This program can be compiled to be paranoid, i.e. check incoming connection
* according to an access file, or to trust anyone. The much smaller "trust * according to an access file, or to trust anyone. The much smaller "trust
@ -285,7 +287,7 @@ int main(int argc, char **argv)
if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) { if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) {
fprintf(stderr, "%s %s: Connection from %s:%u\n", fprintf(stderr, "%s %s: Connection from %s:%u\n",
arg0, service, arg0, service,
inet_ntoa(tcpconf.nwtc_remaddr), inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr),
ntohs(tcpconf.nwtc_remport)); ntohs(tcpconf.nwtc_remport));
} }
/* All is well, no need to stall. */ /* All is well, no need to stall. */

View file

@ -1,10 +1,9 @@
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= tcpdp PROG= tcpdp
.PATH: ${NETBSDSRCDIR}/minix/commands/tcpd
SRCS= tcpd.c SRCS= tcpd.c
CPPFLAGS+= -DPARANOID=1 CPPFLAGS+= -DPARANOID=1
MAN= MAN=
.PATH: ${NETBSDSRCDIR}/commands/tcpd
.include <bsd.prog.mk> .include <bsd.prog.mk>

View file

@ -1,312 +0,0 @@
/*
tcpd.c
*/
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <minix/config.h>
#include <minix/paths.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <net/hton.h>
#include <net/netlib.h>
#include <net/gen/in.h>
#include <net/gen/inet.h>
#include <netdb.h>
#include <net/gen/tcp.h>
#include <net/gen/tcp_io.h>
/* This program can be compiled to be paranoid, i.e. check incoming connection
* according to an access file, or to trust anyone. The much smaller "trust
* 'em" binary will call the paranoid version if the access file exists.
*/
static char *arg0, *service;
static unsigned nchildren;
static void report(const char *label)
{
int err= errno;
fprintf(stderr, "%s %s: %s: %s\n", arg0, service, label, strerror(err));
errno= err;
}
static void sigchld(int sig)
{
while (waitpid(0, NULL, WNOHANG) > 0) {
if (nchildren > 0) nchildren--;
}
}
static void release(int *fd)
{
if (*fd != -1) {
close(*fd);
*fd= -1;
}
}
static void usage(void)
{
fprintf(stderr,
"Usage: %s [-d] [-m maxclients] service program [arg ...]\n",
arg0);
exit(1);
}
int main(int argc, char **argv)
{
tcpport_t port;
int last_failed = 0;
struct nwio_tcpcl tcplistenopt;
struct nwio_tcpconf tcpconf;
struct nwio_tcpopt tcpopt;
char *tcp_device;
struct servent *servent;
int tcp_fd, client_fd, r;
int pfd[2];
unsigned stall= 0;
struct sigaction sa;
sigset_t chldmask, chldunmask, oldmask;
char **progv;
#if !PARANOID
# define debug 0
# define max_children ((unsigned) -1)
arg0= argv[0];
/* Switch to the paranoid version of me if there are flags, or if
* there is an access file.
*/
if (argv[1][0] == '-' || access(_PATH_SERVACCES, F_OK) == 0) {
execv("/usr/bin/tcpdp", argv);
report("tcpdp");
exit(1);
}
if (argc < 3) usage();
service= argv[1];
progv= argv+2;
#else /* PARANOID */
int debug, i;
unsigned max_children;
arg0= argv[0];
debug= 0;
max_children= -1;
i= 1;
while (i < argc && argv[i][0] == '-') {
char *opt= argv[i++] + 1;
unsigned long m;
char *end;
if (*opt == '-' && opt[1] == 0) break; /* -- */
while (*opt != 0) switch (*opt++) {
case 'd':
debug= 1;
break;
case 'm':
if (*opt == 0) {
if (i == argc) usage();
opt= argv[i++];
}
m= strtoul(opt, &end, 10);
if (m <= 0 || m > UINT_MAX || *end != 0) usage();
max_children= m;
opt= "";
break;
default:
usage();
}
}
service= argv[i++];
progv= argv+i;
if (i >= argc) usage();
#endif
/* The interface to start the service on. */
if ((tcp_device= getenv("TCP_DEVICE")) == NULL) tcp_device= TCP_DEVICE;
/* Let SIGCHLD interrupt whatever I'm doing. */
sigemptyset(&chldmask);
sigaddset(&chldmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &chldmask, &oldmask);
chldunmask= oldmask;
sigdelset(&chldunmask, SIGCHLD);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = sigchld;
sigaction(SIGCHLD, &sa, NULL);
/* Open a socket to the service I'm to serve. */
if ((servent= getservbyname(service, "tcp")) == NULL) {
unsigned long p;
char *end;
p= strtoul(service, &end, 0);
if (p <= 0 || p > 0xFFFF || *end != 0) {
fprintf(stderr, "%s: %s: Unknown service\n",
arg0, service);
exit(1);
}
port= htons((tcpport_t) p);
} else {
port= servent->s_port;
if (debug)
{
fprintf(stderr, "%s %s: listening to port %u\n",
arg0, service, ntohs(port));
}
}
/* No client yet. */
client_fd= -1;
while (1) {
if ((tcp_fd= open(tcp_device, O_RDWR)) < 0) {
report(tcp_device);
#if 0
if (errno == ENOENT || errno == ENODEV
|| errno == ENXIO) {
exit(1);
}
#endif
last_failed = 1;
goto bad;
}
if(last_failed)
fprintf(stderr, "%s %s: %s: Ok\n",
arg0, service, tcp_device);
last_failed = 0;
tcpconf.nwtc_flags= NWTC_LP_SET | NWTC_UNSET_RA | NWTC_UNSET_RP;
tcpconf.nwtc_locport= port;
if (ioctl(tcp_fd, NWIOSTCPCONF, &tcpconf) < 0) {
report("Can't configure TCP channel");
exit(1);
}
tcpopt.nwto_flags= NWTO_DEL_RST;
if (ioctl(tcp_fd, NWIOSTCPOPT, &tcpopt) < 0) {
report("Can't set TCP options");
exit(1);
}
if (client_fd != -1) {
/* We have a client, so start a server for it. */
tcpopt.nwto_flags= 0;
(void) ioctl(client_fd, NWIOSTCPOPT, &tcpopt);
fflush(NULL);
/* Create a pipe to serve as an error indicator. */
if (pipe(pfd) < 0) {
report("pipe");
goto bad;
}
(void) fcntl(pfd[1], F_SETFD,
fcntl(pfd[1], F_GETFD) | FD_CLOEXEC);
/* Fork and exec. */
switch (fork()) {
case -1:
report("fork");
close(pfd[0]);
close(pfd[1]);
goto bad;
case 0:
close(tcp_fd);
close(pfd[0]);
#if PARANOID
/* Check if access to this service allowed. */
if (ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0
&& tcpconf.nwtc_remaddr != tcpconf.nwtc_locaddr
&& !servxcheck(tcpconf.nwtc_remaddr, service, NULL)
) {
exit(1);
}
#endif
sigprocmask(SIG_SETMASK, &oldmask, NULL);
dup2(client_fd, 0);
dup2(client_fd, 1);
close(client_fd);
execvp(progv[0], progv);
report(progv[0]);
write(pfd[1], &errno, sizeof(errno));
exit(1);
default:
nchildren++;
release(&client_fd);
close(pfd[1]);
r= read(pfd[0], &errno, sizeof(errno));
close(pfd[0]);
if (r != 0) goto bad;
break;
}
}
while (nchildren >= max_children) {
/* Too many clients, wait for one to die off. */
sigsuspend(&chldunmask);
}
/* Wait for a new connection. */
sigprocmask(SIG_UNBLOCK, &chldmask, NULL);
tcplistenopt.nwtcl_flags= 0;
while (ioctl(tcp_fd, NWIOTCPLISTEN, &tcplistenopt) < 0) {
if (errno != EINTR) {
if (errno != EAGAIN || debug) {
report("Unable to listen");
}
goto bad;
}
}
sigprocmask(SIG_BLOCK, &chldmask, NULL);
/* We got a connection. */
client_fd= tcp_fd;
tcp_fd= -1;
if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) {
fprintf(stderr, "%s %s: Connection from %s:%u\n",
arg0, service,
inet_ntoa(tcpconf.nwtc_remaddr),
ntohs(tcpconf.nwtc_remport));
}
/* All is well, no need to stall. */
stall= 0;
continue;
bad:
/* All is not well, release resources. */
release(&tcp_fd);
release(&client_fd);
/* Wait a bit if this happens more than once. */
if (stall != 0) {
if (debug) {
fprintf(stderr, "%s %s: stalling %u second%s\n",
arg0, service,
stall, stall == 1 ? "" : "s");
}
sleep(stall);
stall <<= 1;
} else {
stall= 1;
}
}
}

View file

@ -31,6 +31,7 @@ Created: June 1995 by Philip Homburg <philip@f-mnx.phicoh.com>
#include <inet/generic/type.h> #include <inet/generic/type.h>
#include <inet/generic/tcp.h> #include <inet/generic/tcp.h>
#include <inet/generic/tcp_int.h> #include <inet/generic/tcp_int.h>
#include <arpa/inet.h>
u32_t system_hz; u32_t system_hz;
char *prog_name; char *prog_name;
@ -179,7 +180,7 @@ void print_conn(int i, clock_t now)
addr_str= hostent->h_name; addr_str= hostent->h_name;
} }
else else
addr_str= inet_ntoa(a1); addr_str= inet_ntoa(*(struct in_addr *)&a1);
printf(" %s:", addr_str); printf(" %s:", addr_str);
if (p1 == 0) if (p1 == 0)
@ -205,7 +206,7 @@ void print_conn(int i, clock_t now)
addr_str= hostent->h_name; addr_str= hostent->h_name;
} }
else else
addr_str= inet_ntoa(a2); addr_str= inet_ntoa(*(struct in_addr *)&a2);
printf("%s:", addr_str); printf("%s:", addr_str);
if (p2 == 0) if (p2 == 0)
@ -225,7 +226,7 @@ void print_conn(int i, clock_t now)
case TCS_CLOSED: printf("CLOSED"); case TCS_CLOSED: printf("CLOSED");
if (tcp_conn->tc_senddis >= now) if (tcp_conn->tc_senddis >= now)
{ {
printf("(time wait %d s)", printf("(time wait %lu s)",
(tcp_conn->tc_senddis-now)/system_hz); (tcp_conn->tc_senddis-now)/system_hz);
} }
no_verbose= 1; no_verbose= 1;

View file

@ -21,6 +21,7 @@ ttn.c
#include <netdb.h> #include <netdb.h>
#include <net/gen/tcp.h> #include <net/gen/tcp.h>
#include <net/gen/tcp_io.h> #include <net/gen/tcp_io.h>
#include <arpa/inet.h>
#include "ttn.h" #include "ttn.h"
#if __STDC__ #if __STDC__
@ -122,7 +123,7 @@ int main(int argc, char *argv[])
} }
fprintf(stderr, "Connecting to %s:%u...\n", fprintf(stderr, "Connecting to %s:%u...\n",
inet_ntoa(host), ntohs(port)); inet_ntoa(*(struct in_addr *)&host), ntohs(port));
tcp_device= getenv("TCP_DEVICE"); tcp_device= getenv("TCP_DEVICE");
if (tcp_device == NULL) if (tcp_device == NULL)

View file

@ -35,6 +35,7 @@
#include <net/gen/socket.h> #include <net/gen/socket.h>
#include <netdb.h> #include <netdb.h>
#include <net/gen/inet.h> #include <net/gen/inet.h>
#include <arpa/inet.h>
#include "telnetd.h" #include "telnetd.h"
#if 0 #if 0
@ -92,7 +93,7 @@ char *hostname;
sizeof(tcpconf.nwtc_remaddr), AF_INET)) != NULL) { sizeof(tcpconf.nwtc_remaddr), AF_INET)) != NULL) {
hostname = hostent->h_name; hostname = hostent->h_name;
} else { } else {
hostname = inet_ntoa(tcpconf.nwtc_remaddr); hostname = inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr);
} }
/* Try allocating a PTY. */ /* Try allocating a PTY. */

View file

@ -30,6 +30,7 @@ Created: March 2001 by Philip Homburg <philip@f-mnx.phicoh.com>
#include <inet/generic/event.h> #include <inet/generic/event.h>
#include <inet/generic/type.h> #include <inet/generic/type.h>
#include <inet/generic/udp_int.h> #include <inet/generic/udp_int.h>
#include <arpa/inet.h>
char *prog_name; char *prog_name;
udp_fd_t udp_fd_table[UDP_FD_NR]; udp_fd_t udp_fd_table[UDP_FD_NR];
@ -265,7 +266,8 @@ void print_fd(int i, clock_t now)
locaddr_str= hostent->h_name; locaddr_str= hostent->h_name;
} }
else else
locaddr_str= inet_ntoa(udp_port->up_ipaddr); locaddr_str=
inet_ntoa(*(struct in_addr *)&udp_port->up_ipaddr);
} }
else if (nwuo_flags & NWUO_EN_BROAD) else if (nwuo_flags & NWUO_EN_BROAD)
locaddr_str= "255.255.255.255"; locaddr_str= "255.255.255.255";
@ -298,7 +300,8 @@ void print_fd(int i, clock_t now)
remaddr_str= hostent->h_name; remaddr_str= hostent->h_name;
} }
else else
remaddr_str= inet_ntoa(uf_udpopt.nwuo_remaddr); remaddr_str=
inet_ntoa(*(struct in_addr *)&uf_udpopt.nwuo_remaddr);
printf("%s:", remaddr_str); printf("%s:", remaddr_str);
if (!(nwuo_flags & NWUO_RP_SET)) if (!(nwuo_flags & NWUO_RP_SET))

View file

@ -1042,7 +1042,7 @@ void canit()
raw_wbuf(strlen(canistr), canistr); raw_wbuf(strlen(canistr), canistr);
purgeline(); purgeline();
#else #else
printf(canistr); printf("%s", canistr);
Lleft=0; /* Do read next time ... */ Lleft=0; /* Do read next time ... */
fflush(stdout); fflush(stdout);
#endif #endif

View file

@ -630,7 +630,7 @@ int wctxpn(char *name)
while (q < (txbuf + 1024)) while (q < (txbuf + 1024))
*q++ = 0; *q++ = 0;
if (!Ascii && (in!=stdin) && *name && fstat(fileno(in), &f)!= -1) if (!Ascii && (in!=stdin) && *name && fstat(fileno(in), &f)!= -1)
sprintf(p, "%llu %o %o 0 %d %ld", f.st_size, f.st_mtime, sprintf(p, "%llu %llo %o 0 %d %ld", f.st_size, f.st_mtime,
f.st_mode, Filesleft, Totalleft); f.st_mode, Filesleft, Totalleft);
Totalleft -= f.st_size; Totalleft -= f.st_size;
if (--Filesleft <= 0) if (--Filesleft <= 0)
@ -1010,7 +1010,7 @@ void canit()
raw_wbuf(strlen(canistr), canistr); raw_wbuf(strlen(canistr), canistr);
purgeline(); purgeline();
#else #else
printf(canistr); printf("%s", canistr);
fflush(stdout); fflush(stdout);
#endif #endif
} }
@ -1379,7 +1379,7 @@ gotack:
if (Test) { if (Test) {
if ( --tleft) if ( --tleft)
while (tcount < 20000) { while (tcount < 20000) {
printf(qbf); fflush(stdout); printf("%s", qbf); fflush(stdout);
tcount += strlen(qbf); tcount += strlen(qbf);
#ifdef READCHECK #ifdef READCHECK
while (rdchk(iofd)) { while (rdchk(iofd)) {

View file

@ -8,7 +8,7 @@ ptrace \- process trace
#include <sys/types.h> #include <sys/types.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
long ptrace(int \fIreq\fP, pid_t \fIpid\fP, long \fIaddr\fP, long \fIdata\fP) long ptrace(int \fIreq\fP, pid_t \fIpid\fP, void *\fIaddr\fP, long \fIdata\fP)
.ft R .ft R
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION