BINDIR?=/usr/bin
-# BJG too many warnings here
-NOGCCERROR?= yes
-NOCLANGERROR?= yes
-
.include "../Makefile.inc"
#include <net/gen/route.h>
#include <net/gen/socket.h>
#include <net/gen/ip_io.h>
+#include <arpa/inet.h>
static char *prog_name;
static enum { ADD, DEL } action;
{
if (parse_cidr(destination_str, &destination, &netmask))
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)
destination= netent->n_net;
else /* class D is multicast ... */
{
fprintf(stderr, "%s: Warning: Martian address '%s'\n",
- prog_name, inet_ntoa(destination));
+ prog_name,
+ inet_ntoa(*(struct in_addr *)&destination));
defaultmask= htonl(0xffffffff);
}
if (destination & ~defaultmask)
{
if (cidr)
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,
netmask_str);
printf("%s %s route to %s ",
action == ADD ? "adding" : "deleting",
itab ? "input" : "output",
- inet_ntoa(destination));
- printf("with netmask %s ", inet_ntoa(netmask));
- printf("using gateway %s", inet_ntoa(gateway));
+ inet_ntoa(*(struct in_addr *)&destination));
+ printf("with netmask %s ",
+ inet_ntoa(*(struct in_addr *)&netmask));
+ printf("using gateway %s",
+ inet_ntoa(*(struct in_addr *)&gateway));
if (itab && action == ADD)
printf(" at distance %d", metric);
printf("\n");
*/
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->h_addrtype != AF_INET) return 0;
if (hostent->h_length != sizeof(*addr)) return 0;
*slash++= 0;
ok= 1;
- if (!inet_aton(cidr, &a))
+ if (!inet_aton(cidr, (struct in_addr *)&a))
ok= 0;
len= strtoul(slash, &check, 10);
#include <net/gen/arp_io.h>
+#include <arpa/inet.h>
+
char *progname;
static int ipfd= -1;
static int do_setuid= 0;
else
he= NULL;
if (he)
- printf("%s (%s)", he->h_name, inet_ntoa(ipaddr));
+ printf("%s (%s)", he->h_name,
+ inet_ntoa(*(struct in_addr *)&ipaddr));
else
- printf("%s", inet_ntoa(ipaddr));
+ printf("%s", inet_ntoa(*(struct in_addr *)&ipaddr));
if (!arpp)
{
printf(" -- no entry\n");
continue;
}
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));
}
}
print_one(ipaddr, NULL, 0);
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));
}
if (r == -1 && errno != ENOENT)
{
fatal("unable to delete entry for host %s: %s",
- inet_ntoa(ipaddr),
+ inet_ntoa(*(struct in_addr *)&ipaddr),
errno == EINVAL ? "incomplete entry" :
strerror(errno));
}
ipaddr_t ipaddr;
struct hostent *he;
- if (inet_aton(hostname, &ipaddr) == 0)
+ if (inet_aton(hostname, (struct in_addr *)&ipaddr) == 0)
{
he= gethostbyname(hostname);
if (!he)
int i, c, mask, ltim, year, lday = NODAY;
char buf[64], job[30], pastjob[35], *dp, *sp;
struct tm *p;
- long clk;
+ time_t clk;
FILE *fp;
char pwd[PATH_MAX+1];
* 4. This notice may not be removed or altered.
*/
+#include <stdlib.h>
#include <stdio.h>
#ifdef UNIX
#include "cawf.h"
#include <sys/stat.h>
+#include <unistd.h>
#ifndef UNIX
#include <io.h>
#include <process.h>
+#ifndef __minix
/*
Newsgroups: mod.std.unix
Subject: public domain AT&T getopt source
}
return(c);
}
+#endif /* !__minix */
* Delmacro(mx) - delete macro
*/
-int Delmacro(int mx) {
+void Delmacro(int mx) {
/* macro index mx */
unsigned char buf[MAXLINE]; /* error message buffer */
int i, j; /* temporary indexes */
if (*s4)
s4++;
}
- while (*s1++ = *s4++)
+ while ((*s1++ = *s4++))
;
if (*s2 == 'h' && *(s2+1) == 'y')
(void) Findhy(buf, i, 1);
unsigned char *Asmcode(unsigned char **s, unsigned char *c);
int Asmname(unsigned char *s, unsigned char *c);
void Charput(int c);
-int Delmacro(int mx);
+void Delmacro(int mx);
int Defdev();
void Delstr(int sx);
void Error(int t, int l, char *s1, char *s2);
#include "misc.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 need_reload;/* Set if table reload required. */
static volatile int need_quit; /* Set if cron must exit. */
need_reload= 1;
} else {
/* 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_reschedule(job);
}
need_reload= 1;
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_reschedule(job);
return;
}
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);
tab_reschedule(job);
return;
} else {
pw= 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);
return;
}
if (need_mailer) {
errfd[0]= -1;
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));
if (errfd[0] != -1) {
close(errfd[0]);
fcntl(errfd[1], F_GETFD) | FD_CLOEXEC);
if ((pid= fork()) == -1) {
- log(LOG_ERR, "fork() call failed: %s\n",
+ cronlog(LOG_ERR, "fork() call failed: %s\n",
strerror(errno));
close(errfd[0]);
close(errfd[1]);
close(mailfd[0]);
close(errfd[1]);
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));
close(errfd[0]);
close(mailfd[1]);
}
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]);
tab_reschedule(job);
return;
(void) fcntl(errfd[1], F_SETFD, fcntl(errfd[1], F_GETFD) | FD_CLOEXEC);
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[1]);
if (need_mailer) close(mailfd[1]);
if (need_mailer) close(mailfd[1]);
close(errfd[1]);
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]);
tab_reschedule(job);
return;
tab_parse(tab, nil);
}
if (ferror(pkgs)) {
- log(LOG_CRIT, "/usr/lib/packages: %s\n",
+ cronlog(LOG_CRIT, "/usr/lib/packages: %s\n",
strerror(errno));
}
fclose(pkgs);
} else {
if (errno != ENOENT) {
- log(LOG_ERR, "/usr/lib/packages: %s\n",
+ cronlog(LOG_ERR, "/usr/lib/packages: %s\n",
strerror(errno));
}
}
void *mem;
if ((mem= malloc(len)) == nil) {
- log(LOG_ALERT, "Out of memory, exiting\n");
+ cronlog(LOG_ALERT, "Out of memory, exiting\n");
exit(1);
}
alloc_count++;
logto= where;
}
-void log(int level, const char *fmt, ...)
+void cronlog(int level, const char *fmt, ...)
/* Like syslog(), but may go to stderr. */
{
va_list ap;
enum logto { SYSLOG, STDERR };
void selectlog(enum logto where);
-void log(int level, const char *fmt, ...);
+void cronlog(int level, const char *fmt, ...);
#endif /* MISC__H */
nodst_rtime= job->rtime= mktime(&tmptm);
if (job->rtime == -1) {
/* This should not happen. */
- log(LOG_ERR,
+ cronlog(LOG_ERR,
"mktime failed for %04d-%02d-%02d %02d:%02d:%02d",
1900+nexttm.tm_year, nexttm.tm_mon+1,
nexttm.tm_mday, nexttm.tm_hour,
dst_rtime= job->rtime= mktime(&tmptm);
if (job->rtime == -1) {
/* This should not happen. */
- log(LOG_ERR,
+ cronlog(LOG_ERR,
"mktime failed for %04d-%02d-%02d %02d:%02d:%02d\n",
1900+nexttm.tm_year, nexttm.tm_mon+1,
nexttm.tm_mday, nexttm.tm_hour,
p= data;
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;
}
*p= end;
return 1;
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);
return 0;
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);
return 0;
}
/* Try to open the file. */
if ((fd= open(file, O_RDONLY)) < 0 || fstat(fd, &st) < 0) {
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);
return;
/* Forget it if the file is awfully big. */
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,
(unsigned long) st.st_size,
(unsigned long) TAB_MAX);
n= 0;
while (n < st.st_size) {
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);
return;
}
close(fd);
tab->data[n]= 0;
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;
}
break;
default:
usage:
- log(LOG_ERR,
+ cronlog(LOG_ERR,
"%s: bad option -%c, good options are: -u username\n",
file, q[-1]);
ok= 0;
*/
while (*p != 0 && *p++ != '\n') {}
if (*p++ != '\t') {
- log(LOG_ERR, "%s: contains an empty command\n",
+ cronlog(LOG_ERR,
+ "%s: contains an empty command\n",
file);
ok= 0;
goto endtab;
#include "misc.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)
/* Open a crontab file under the given uid. How is 'r' or 'w'. Return
* the result of open(2).
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();
seteuid(uid);
r= open(file, flags, 0666);
#include <sys/stat.h>
#include <machine/partition.h>
#include <minix/partition.h>
-#include <sys/ioc_disk.h>
+#include <sys/ioctl.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
static void timeout(int signum)
{
/* 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)
* in case the driver isn't ready yet.
*/
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, ðstat) < 0) {
/* Not an Ethernet. */
close(fdp->fd);
return 0;
}
- if (alarm(0) < 0) fatal("alarm(0)");
+ if (alarm(0) == (unsigned int)-1) fatal("alarm(0)");
np->eth= ethstat.nwes_addr;
ethopt.nweo_flags= NWEO_COPY | NWEO_EN_LOC | NWEO_EN_BROAD
| NWEO_REMANY | NWEO_TYPEANY | NWEO_RWDATALL;
#include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h>
#include <net/gen/dhcp.h>
+#include <arpa/inet.h>
#include "arp.h"
#define EXTERN
#include "dhcpd.h"
strcpy(delta, "infinite");
} else
if (expire < now) {
- sprintf(delta, "-%lu", now - expire);
+ sprintf(delta, "-%llu", now - expire);
} 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++) {
printf("%02X", entry.clid[i]);
}
if (dyn) {
/* A dynamic address must have a lease. */
fprintf(stderr, "%s: No lease set for address %s\n",
- program, inet_ntoa(cip));
+ program, inet_ntoa(*(struct in_addr *)&cip));
exit(1);
}
lease= nil;
for (i= 0; i < cilen; 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)) {
fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata);
}
/* Some weird sites use a hostname, not a client ID. */
if (np->hostname != nil) {
settag(bp->dhcp, DHCP_TAG_HOSTNAME,
- np->hostname, strlen(np->hostname));
+ (void *)np->hostname, strlen(np->hostname));
}
bp->udpio->uih_src_addr= np->ip;
printf("%s: Sent DHCP %s to %s\n",
np->fdp->device,
dhcptypename(type),
- inet_ntoa(np->server));
+ inet_ntoa(*(struct in_addr *)&np->server));
if (debug >= 2) printdhcp(bp->dhcp);
}
}
if (debug >= 1) {
printf("%s: Got a DHCP %s from %s",
- np->fdp->device, dhcptypename(type), inet_ntoa(server));
- printf(relay != server ? " through %s\n" : "\n",
- inet_ntoa(relay));
+ np->fdp->device, dhcptypename(type),
+ inet_ntoa(*(struct in_addr *)&server));
+ if (relay != server)
+ printf(" through %s\n",
+ inet_ntoa(*(struct in_addr *)&relay));
+ else printf("\n");
if (debug >= 2) printdhcp(bp->dhcp);
}
make_arp(bp, np);
if (sendpacket(np, bp->eth, sizeof(arp46_t))) {
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->delta= DELTA_FIRST;
fprintf(stderr, "%s: Got a NAK from %s",
- program, inet_ntoa(server));
+ program, inet_ntoa(*(struct in_addr *)&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)) {
fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata);
fprintf(stderr, "%s: %s: %s offered by ",
program,
np->fdp->device,
- inet_ntoa(np->ip));
+ inet_ntoa(*(struct in_addr *)&np->ip));
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));
}
put_buf(&bp);
if (sendpacket(np, bp->ip, sizeof(ip_hdr_t) + 16)) {
if (debug >= 2) {
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;
if ((router= icmp_is_advert(bp)) != 0) {
if (debug >= 2) {
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->sol_ct= -1;
if (debug >= 1) {
printf("%s: Got DHCP packet from %s to ",
- np->fdp->device, inet_ntoa(bp->udpio->uih_src_addr));
- printf("%s\n", inet_ntoa(bp->udpio->uih_dst_addr));
+ np->fdp->device,
+ 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 >= 1) {
printf("%s: Sent DHCP packet to %s\n",
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);
}
}
void icmp_advert(buf_t *bp, network_t *np)
{
/* 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);
bp->ip->ih_vers_ihl= 0x45;
icmp->ih_hun.ihh_ram.iram_na= 1;
icmp->ih_hun.ihh_ram.iram_aes= 2;
icmp->ih_hun.ihh_ram.iram_lt= htons(DELTA_ADV);
- ((u32_t *) icmp->ih_dun.uhd_data)[0] = np->gateway;
- ((u32_t *) icmp->ih_dun.uhd_data)[1] = htonl((u32_t) -9999);
+ data = (u32_t *) icmp->ih_dun.uhd_data;
+ data[0] = np->gateway;
+ data[1] = htonl((u32_t) -9999);
icmp->ih_chksum= 0;
icmp->ih_chksum= ~oneC_sum(0, icmp, 16);
}
#include <net/gen/udp.h>
#include <net/gen/udp_hdr.h>
#include <net/gen/dhcp.h>
+#include <arpa/inet.h>
#include "dhcpd.h"
#define doff(field) offsetof(dhcp_t, field)
char *hn;
/* 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? */
while ((he= _gethostent()) != nil) {
if ((slash= strchr(cidr, '/')) == nil) return 0;
*slash++= 0;
- ok= inet_aton(cidr, &a);
+ ok= inet_aton(cidr, (struct in_addr *)&a);
len= strtoul(slash, &check, 10);
if (check == slash || *check != 0 || len > 32) ok= 0;
testmask= (testmask << 1) & 0xFFFFFFFFUL;
}
- sprintf(result, "%s/%-2d", inet_ntoa(addr), n);
- if (n == -1) strcpy(strchr(result, '/')+1, inet_ntoa(mask));
+ sprintf(result, "%s/%-2d", inet_ntoa(*(struct in_addr *)&addr), n);
+ if (n == -1) strcpy(strchr(result, '/')+1,
+ inet_ntoa(*(struct in_addr *)&mask));
return result;
}
) {
config_t *atname= cmd->next->next;
if (ifno != -1) atname= atname->next;
- name= atname->word;
+ name= (char *)atname->word;
if (name2ip(&hip, name, ifip) && (ip == 0 || ip == hip)) {
d= ntohl(hip) ^ ntohl(ifip);
case TT_IP: {
ipaddr_t ip;
memcpy(&ip, data+i, sizeof(ip));
- printf(" %s", inet_ntoa(ip));
+ printf(" %s", inet_ntoa(*(struct in_addr *)&ip));
i += sizeof(ip);
break;}
case TT_NUMBER: {
}
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);
- 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);
/* Accept the MINIX partition type. Usually ignore foreign types, so this
return;
if (pe->lowsec + adj < 1)
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)
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
break;
}
pe->lowsec += adj;
pe->size -= adj;
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);
}
if (!get_an_int("\tEnter adjustment to size (an integer): ", &adj))
return;
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;
sec_to_hst(pe->lowsec + pe->size - 1,
&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()
tcflag_t saved_flags;
int nopwd;
- fprintf(stderr, prompt);
+ fprintf(stderr, "%s", prompt);
if (tcgetattr(STDIN_FILENO, &tios) != 0)
return (fgets(pwbuf, pwbuf_len, stdin) == NULL);
track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE;
if (lseek(ffd, track_pos, SEEK_SET) == -1) {
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));
exit(1);
}
track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE;
if (lseek(vfd, track_pos, SEEK_SET) == -1) {
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));
exit(1);
}
for (sector= 0; sector < nr_sectors; sector++) {
if (lseek(vfd, track_pos, SEEK_SET) == -1) {
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));
exit(1);
}
switch (read(vfd, buf, SECTOR_SIZE)) {
case -1:
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);
bad_count++;
break;
/* Fine. */
break;
default:
- fprintf(stderr, "format: short read at pos %d\n",
+ fprintf(stderr, "format: short read at pos %lld\n",
track_pos);
bad_count++;
}
if(maxsize <= 0)
maxsize = LONG_MAX;
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);
}
ino = bit;
do {
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);
if (input(buf, 80)) ip->i_mode = atoo(buf);
printf(" nlinks = %6u", ip->i_nlinks);
(!repair || automatic || yes("stop this listing")))
*report = 0;
else {
- if (*report)
+ if (*report) {
if ((w1 & 1) && !(w2 & 1))
printf("%s %d is missing\n", type, bit);
else if (!(w1 & 1) && (w2 & 1))
printf("%s %d is not free\n", type, bit);
+ }
}
}
devread(inoblock(ino), inooff(ino), (char *) &mode,
sizeof(mode));
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),
inooff(ino), nullbuf, INODE_SIZE);
}
}
devread(inoblock(ino), inooff(ino), (char *) &inode, INODE_SIZE);
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 ((inode.i_nlinks = count[ino]) == 0) {
fatal("internal error (counterror)");
firstlist = 0;
printf(" inode permission link size name\n");
}
- printf("%6u ", ino);
+ printf("%6llu ", ino);
switch (ip->i_mode & I_TYPE) {
case I_REGULAR: putchar('-'); break;
case I_DIRECTORY: putchar('d'); break;
char printable_name[4 * MFS_NAME_MAX + 1];
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);
printpath(1, 0);
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) dp->d_inum);
setbit(spec_imap, (bit_nr) exp);
return(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));
- printf("warning: %s has offset %d in ", printable_name, pos);
+ make_printable_name(printable_name, dp->mfs_d_name,
+ sizeof(dp->mfs_d_name));
+ printf("warning: %s has offset %lld in ", printable_name, pos);
printpath(1, 0);
printf("%s is linked to %u)\n", printable_name, dp->d_inum);
setbit(spec_imap, (bit_nr) ino);
case 2: printf("DOUBLE INDIRECT"); break;
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
{
if (ino == ROOT_INODE && (ip->i_mode & I_TYPE) != I_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("");
}
if (ip->i_nlinks == 0) {
stk.st_next = ftop;
ftop = &stk;
if (bitset(spec_imap, (bit_nr) ino)) {
- printf("found inode %u: ", ino);
+ printf("found inode %llu: ", ino);
printpath(0, 1);
}
visited = bitset(imap, (bit_nr) ino);
* that copyright notice.
*/
+#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <arpa/nameser.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/ioc_net.h>
#include <net/netlib.h>
#include <net/gen/in.h>
#include <net/gen/tcp.h>
#include <net/gen/tcp_io.h>
+#include <arpa/inet.h>
extern int h_errno;
cp[-1] = '.';
return (hp);
}
- if (n == 0 && (cp = __hostalias(name))) {
+ if (n == 0 && (cp = (char *)__hostalias(name))) {
if (verbose)
printf("Aliased to \"%s\"\n", cp);
_res.options |= RES_DEFNAMES;
static int
getinfo(name, domain, type)
char *name, *domain;
+ int type;
{
HEADER *hp;
else
doprint = 0;
- if (doprint)
+ if (doprint) {
if (verbose)
fprintf(file,"%s\t%d%s\t%s",
name, ttl, pr_class(class), pr_type(type));
else {
fprintf(file,"%s%s %s",name, pr_class(class), pr_type(type));
}
+ }
if (verbose)
punc = '\t';
else
cp += sizeof(u_long);
proto = *cp++;
protop = getprotobynumber(proto);
- if (doprint)
+ if (doprint) {
if (protop)
fprintf(file,"%c%s %s", punc,
inet_ntoa(inaddr), protop->p_name);
else
fprintf(file,"%c%s %d", punc,
inet_ntoa(inaddr), proto);
-
+ }
n = 0;
while (cp < cp1 + dlen) {
c = *cp++;
if (protop)
servp = getservbyport (htons(n),
protop->p_name);
- if (doprint)
+ if (doprint) {
if (servp)
fprintf(file, " %s", servp->s_name);
else
fprintf(file, " %d", n);
+ }
}
c <<= 1;
} while (++n & 07);
cp += 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)
fprintf(file,"\n");
return (cp);
*/
msglen = res_mkquery(QUERY, namePtr, C_IN, T_NS,
- (char *)0, 0, (struct rrec *)0,
+ (char *)0, 0, 0,
(char *)&buf, sizeof(buf));
if (msglen < 0) {
*
*/
msglen = res_mkquery(QUERY, namePtr, getclass, T_AXFR,
- (char *)0, 0, (struct rrec *)0,
+ (char *)0, 0, 0,
(char *) &buf, sizeof(buf));
if (msglen < 0) {
if (_res.options & RES_DEBUG) {
return ERROR;
}
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;
result= ioctl(tcp_fd, NWIOTCPCONN, &clopt);
if (result == 0)
#include <netdb.h>
#include <net/gen/socket.h>
+#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <net/gen/dhcp.h>
if (do_ip)
{
printf("%s%s", first_print ? "" : " ",
- inet_ntoa(nwio_ipconf.nwic_ipaddr));
+ inet_ntoa(*(struct in_addr *)&nwio_ipconf.nwic_ipaddr));
first_print= 0;
}
if (do_asc_ip || do_hostname)
else
{
/* 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;
}
#include <net/gen/in.h>
#include <net/gen/ip_io.h>
#include <net/gen/inet.h>
+#include <arpa/inet.h>
#if __STDC__
#define PROTO(x,y) x y
char *prog_name;
+int
main(argc, argv)
int argc;
char *argv[];
else
{
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)
{
printf(" netmask %s",
- inet_ntoa(ipconf.nwic_netmask));
+ inet_ntoa(*(struct in_addr *)
+ &ipconf.nwic_netmask));
}
#ifdef NWIC_MTU_SET
if (ipconf.nwic_mtu)
/* Scan through the file looking for starting lines */
if ((ch = fgetc(zin)) == EOF)
stop(); /* Get first char on the line */
- if (ch != '#')
+ if (ch != '#') {
if (proc) { /* If not # and we're processing */
(void)putchar(ch); /* then print the line */
Print;
Goto; /* else just skip the line */
continue;
}
+ }
ch = fgetarg(zin, word); /* Get the word after the # */
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
+#include <err.h>
/* remove _() stuff */
#define _(a) a
break;
default:
- printf("0x%08x ",ipcp->KEY );
+ printf("0x%08lx ",ipcp->KEY );
if (pw)
printf ("%-10d %-10.10s", shmid, pw->pw_name);
else
break;
default:
- printf("0x%08x ", ipcp->KEY);
+ printf("0x%08lx ", ipcp->KEY);
if (pw)
printf ("%-10d %-10.10s", semid, pw->pw_name);
else
#include <net/gen/udp.h>
#include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h>
+#include <arpa/inet.h>
#define MAX_SOLICITATIONS 3 /* # router solicitations. */
#define SOLICITATION_INTERVAL 3 /* Secs between solicitate retries. */
return hostent == nil ? inet_ntoa(host) : hostent->h_name;
}
#else
-#define addr2name(host) inet_ntoa(host)
+#define addr2name(host) inet_ntoa(*(struct in_addr *)&(host))
#endif
void print_table(void)
dir_ptr = (struct dir_entry *) Hs_Vol_Desc->root_dir_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;
else name_index = 1; /* first name in path */
+ }
/* Keep searching for the path elements until all are found */
while (!last_in_path)
char buf[BUFSIZ];
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
* out of paper.
*/
(long) mtget.mt_fileno,
(long) mtget.mt_blkno,
(long) mtget.mt_resid);
- printf(mtget.mt_blksiz == 0 ? "variable\n" : "%d\n",
- mtget.mt_blksiz);
+ if (mtget.mt_blksiz == 0) printf("variable\n");
+ else printf("%d\n", mtget.mt_blksiz);
}
}
if (r < 0) {
#include <net/gen/udp_hdr.h>
#include <net/gen/udp_io.h>
#include <net/gen/dhcp.h>
+#include <arpa/inet.h>
#include <paths.h>
#include <minix/paths.h>
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 namecpy(n1, n2) strcpy(PC(n1), PC(n2))
#define namecat(n1, n2) strcat(PC(n1), PC(n2))
switch (*ep++) {
case 'i':
if (cp + sizeof(u32_t) > rlim) return -1;
- printf(" %s", inet_ntoa(upack32(cp)));
+ printf(" %s", my_ntoa(upack32(cp)));
cp += sizeof(u32_t);
break;
case 'l':
if (debug >= 2) {
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);
/* pack16(cp, htonl(RDLENGTH)) */
cp += sizeof(u16_t);
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;
pack16(cp - sizeof(u16_t), htons(r));
*cp= r-1;
if (debug >= 1) {
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);
}
ulen= offsetof(udp_dns_t, dns) + dlen;
if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(HEADER))) return 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));
dns_tell(0, &udp.dns, dlen);
}
i_named= i;
if (debug >= 1) {
printf("Current named = %s\n",
- inet_ntoa(current_named()));
+ my_ntoa(current_named()));
}
stop_searching();
force_expire(job_find_named);
udp.dns.hdr.id= id;
udp.hdr.uih_dst_addr= ip;
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 {
/* A query. */
if (udp.dns.hdr.qdcount != HTONS(1)) return 1;
if(localonly) {
/* Check if it's a local query. */
if(ntohl(udp.hdr.uih_src_addr) != LOCALHOST) {
- syslog(LOG_WARNING, "nonamed: dropped query from %s",
- inet_ntoa(udp.hdr.uih_src_addr));
+ syslog(LOG_WARNING, "nonamed: dropped query from %s",
+ my_ntoa(udp.hdr.uih_src_addr));
return 1;
}
}
/* Send an UDP DNS reply. */
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));
dns_tell(0, &udp.dns, dlen);
}
}
if (debug >= 1) {
printf("To named %s:%u\n",
- inet_ntoa(current_named()), ntohs(named_port));
+ my_ntoa(current_named()), ntohs(named_port));
}
}
}
if (ioctl(fd, NWIOGTCPCONF, &tcpconf) < 0) {
printf("??\?:?? TCP ");
} else {
- printf("%s:%u TCP ", inet_ntoa(tcpconf.nwtc_remaddr),
+ printf("%s:%u TCP ", my_ntoa(tcpconf.nwtc_remaddr),
ntohs(tcpconf.nwtc_remport));
}
dns_tell(0, oct2dns(buf + sizeof(u16_t)), ntohs(upack16(buf)));
pack16(udp.dns.data+1, HTONS(T_NS));
pack16(udp.dns.data+3, HTONS(C_IN));
if (debug >= 1) {
- printf("PROBE %s ", inet_ntoa(ip));
+ printf("PROBE %s ", my_ntoa(ip));
dns_tell(0, &udp.dns, dlen);
}
pe->sysind,
chs[0], chs[1], chs[2]);
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],
pe->lowsec,
howend == SIZE ? pe->size : pe->size + pe->lowsec - 1,
printf("%3d ", (n-1) / 2);
show_chs(p->lowsec);
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)
if (pe->bootind & EXIST_FLAG) {
if (base > pe->lowsec) {
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);
exit(1);
}
vmd/cmd/simple/pr_routes.c
*/
-#define _POSIX_C_SOURCE 2
-
#include <sys/types.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <net/gen/route.h>
#include <netdb.h>
#include <net/gen/inet.h>
+#include <arpa/inet.h>
#define N_IF 64 /* More than enough? */
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)
- strcpy(strchr(result, '/')+1, inet_ntoa(mask));
+ strcpy(strchr(result, '/')+1,
+ inet_ntoa(*(struct in_addr *)&mask));
return result;
}
printf("%*s ", if_width,
ifname ? ifname : get_ifname(route->nwr_ifaddr));
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("%*ld ", pref_width, (long) route->nwr_pref);
printf("%*lu", mtu_width, (long) route->nwr_mtu);
if (iftab[j] == iftab[i])
{
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]));
}
}
return name;
}
- return inet_ntoa(addr);
+ return inet_ntoa(*(struct in_addr *)&addr);
}
static void fatal(char *fmt, ...)
#include <minix/paths.h>
-#include <sys/ioc_memory.h>
+#include <sys/ioctl.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <net/gen/if_ether.h>
#include <net/gen/ip_io.h>
#include <arpa/nameser.h>
+#include <arpa/inet.h>
#define MAX_RARP_RETRIES 5
#define RARP_TIMEOUT 5
if (debug >= 1) {
printf("%s: Replying %s (%s) to %s\n",
- ethdev(ep->n), inet_ntoa(ip_addr), hostname, ether_ntoa(ð_addr));
+ ethdev(ep->n), inet_ntoa(*(struct in_addr *)&ip_addr), hostname,
+ ether_ntoa(ð_addr));
}
(void) write(ep->eth_fd, &rarp46, sizeof(rarp46));
}
close(fd);
if (debug >= 1) {
printf("%s: IP address is %s / ",
- ipdev(ep->n), inet_ntoa(ep->ip_addr));
- printf("%s\n", inet_ntoa(ep->ip_mask));
+ ipdev(ep->n), inet_ntoa(*(struct in_addr *)&ep->ip_addr));
+ printf("%s\n", inet_ntoa(*(struct in_addr *)&ep->ip_mask));
}
}
if (nbytes > 0) {
off_t kBpts;
- fprintf(stderr, "%d kB / %ld.%ld s = ",
+ fprintf(stderr, "%lld kB / %ld.%ld s = ",
(nbytes + 512) / 1024,
tenthsec / 10, tenthsec % 10);
if (tenthsec < 5)
seconds = (tenthsec + 5) / 10;
kBpts= (nbytes + 512L * seconds)
/ (1024L * seconds);
- fprintf(stderr, "%d kB/s\n", kBpts);
+ fprintf(stderr, "%lld kB/s\n", kBpts);
} else {
kBpts= (100 * nbytes + 512L * tenthsec)
/ (1024L * tenthsec);
- fprintf(stderr, "%d.%d kB/s\n",
- kBpts/10, kBpts%10);
+ fprintf(stderr, "%lld.%d kB/s\n",
+ kBpts/10, (int)(kBpts%10));
}
}
}
tenthms= (tenthsec * 1000 + nseeks/2) / nseeks;
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 * 10 + tenthsec/2) / tenthsec,
- tenthms / 10, tenthms % 10);
+ tenthms / 10, (int)(tenthms % 10));
for (rpm= 3600; rpm <= 7200; rpm+= 1800) {
int rotms = (10000L / 2 * 60 + rpm/2) / rpm;
} else {
fprintf(stderr, ", ");
}
- fprintf(stderr, "%d.%d ms (%d rpm)",
- (tenthms - rotms) / 10, (tenthms - rotms) % 10,
+ fprintf(stderr, "%lld.%d ms (%d rpm)",
+ (tenthms - rotms) / 10,
+ (int)((tenthms - rotms) % 10),
rpm);
}
if (disc) fputc('\n', stdout);
return;
}
fprintf(stderr, "made %s look old", file);
- fprintf(stderr, err == nil ? "\n" : " due to a remote problem: %s\n",
- err);
+ if (err != nil)
+ 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)
vaddr= (unsigned long)addr;
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)
{
fprintf(stderr,
vaddr= (unsigned long)addr;
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)
{
fprintf(stderr,
startprocess(slave, s_mach, s_dir, 0);
} else {
/* synctree machine1:dir1 machine2:dir2 */
- if (pipe(m2m) < 0) perrx(pipe);
+ if (pipe(m2m) < 0) perrx("pipe");
switch (s_pid= fork()) {
case -1:
#include <netdb.h>
#include <net/gen/tcp.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
* according to an access file, or to trust anyone. The much smaller "trust
if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) {
fprintf(stderr, "%s %s: Connection from %s:%u\n",
arg0, service,
- inet_ntoa(tcpconf.nwtc_remaddr),
+ inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr),
ntohs(tcpconf.nwtc_remport));
}
/* All is well, no need to stall. */
.include <bsd.own.mk>
PROG= tcpdp
+.PATH: ${NETBSDSRCDIR}/minix/commands/tcpd
SRCS= tcpd.c
CPPFLAGS+= -DPARANOID=1
MAN=
-.PATH: ${NETBSDSRCDIR}/commands/tcpd
-
.include <bsd.prog.mk>
+++ /dev/null
-/*
-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;
- }
- }
-}
#include <inet/generic/type.h>
#include <inet/generic/tcp.h>
#include <inet/generic/tcp_int.h>
+#include <arpa/inet.h>
u32_t system_hz;
char *prog_name;
addr_str= hostent->h_name;
}
else
- addr_str= inet_ntoa(a1);
+ addr_str= inet_ntoa(*(struct in_addr *)&a1);
printf(" %s:", addr_str);
if (p1 == 0)
addr_str= hostent->h_name;
}
else
- addr_str= inet_ntoa(a2);
+ addr_str= inet_ntoa(*(struct in_addr *)&a2);
printf("%s:", addr_str);
if (p2 == 0)
case TCS_CLOSED: printf("CLOSED");
if (tcp_conn->tc_senddis >= now)
{
- printf("(time wait %d s)",
+ printf("(time wait %lu s)",
(tcp_conn->tc_senddis-now)/system_hz);
}
no_verbose= 1;
#include <netdb.h>
#include <net/gen/tcp.h>
#include <net/gen/tcp_io.h>
+#include <arpa/inet.h>
#include "ttn.h"
#if __STDC__
}
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");
if (tcp_device == NULL)
#include <net/gen/socket.h>
#include <netdb.h>
#include <net/gen/inet.h>
+#include <arpa/inet.h>
#include "telnetd.h"
#if 0
sizeof(tcpconf.nwtc_remaddr), AF_INET)) != NULL) {
hostname = hostent->h_name;
} else {
- hostname = inet_ntoa(tcpconf.nwtc_remaddr);
+ hostname = inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr);
}
/* Try allocating a PTY. */
#include <inet/generic/event.h>
#include <inet/generic/type.h>
#include <inet/generic/udp_int.h>
+#include <arpa/inet.h>
char *prog_name;
udp_fd_t udp_fd_table[UDP_FD_NR];
locaddr_str= hostent->h_name;
}
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)
locaddr_str= "255.255.255.255";
remaddr_str= hostent->h_name;
}
else
- remaddr_str= inet_ntoa(uf_udpopt.nwuo_remaddr);
+ remaddr_str=
+ inet_ntoa(*(struct in_addr *)&uf_udpopt.nwuo_remaddr);
printf("%s:", remaddr_str);
if (!(nwuo_flags & NWUO_RP_SET))
raw_wbuf(strlen(canistr), canistr);
purgeline();
#else
- printf(canistr);
+ printf("%s", canistr);
Lleft=0; /* Do read next time ... */
fflush(stdout);
#endif
while (q < (txbuf + 1024))
*q++ = 0;
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);
Totalleft -= f.st_size;
if (--Filesleft <= 0)
raw_wbuf(strlen(canistr), canistr);
purgeline();
#else
- printf(canistr);
+ printf("%s", canistr);
fflush(stdout);
#endif
}
if (Test) {
if ( --tleft)
while (tcount < 20000) {
- printf(qbf); fflush(stdout);
+ printf("%s", qbf); fflush(stdout);
tcount += strlen(qbf);
#ifdef READCHECK
while (rdchk(iofd)) {
#include <sys/types.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
.fi
.SH DESCRIPTION