style, indent, and ANSI-fy.
This commit is contained in:
parent
9ce1f92af7
commit
1c038e6834
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: alloc.c,v 1.21 2006/01/25 18:27:23 christos Exp $ */
|
||||
/* $NetBSD: alloc.c,v 1.22 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993
|
||||
|
@ -145,10 +145,11 @@ struct fl {
|
|||
|
||||
#ifdef HEAP_VARIABLE
|
||||
static char *top, *heapstart, *heaplimit;
|
||||
void setheap(void *start, void *limit)
|
||||
void
|
||||
setheap(void *start, void *limit)
|
||||
{
|
||||
heapstart = top = start;
|
||||
heaplimit = limit;
|
||||
heapstart = top = start;
|
||||
heaplimit = limit;
|
||||
}
|
||||
#define HEAP_START heapstart
|
||||
#define HEAP_LIMIT heaplimit
|
||||
|
@ -157,7 +158,7 @@ void setheap(void *start, void *limit)
|
|||
extern char end[];
|
||||
#define HEAP_START end
|
||||
#endif
|
||||
static char *top = (char*)HEAP_START;
|
||||
static char *top = (char *)HEAP_START;
|
||||
#endif /* HEAP_VARIABLE */
|
||||
|
||||
void *
|
||||
|
@ -188,11 +189,11 @@ alloc(size_t size)
|
|||
|
||||
if ((*f)->size < bestsize) {
|
||||
/* keep best fit */
|
||||
bestf = f;
|
||||
bestsize = (*f)->size;
|
||||
}
|
||||
}
|
||||
f = &((*f)->next);
|
||||
bestf = f;
|
||||
bestsize = (*f)->size;
|
||||
}
|
||||
}
|
||||
f = &((*f)->next);
|
||||
}
|
||||
|
||||
/* no match in freelist if bestsize unchanged */
|
||||
|
@ -200,25 +201,25 @@ alloc(size_t size)
|
|||
#endif
|
||||
|
||||
if (failed) { /* nothing found */
|
||||
/*
|
||||
/*
|
||||
* allocate from heap, keep chunk len in
|
||||
* first word
|
||||
*/
|
||||
help = top;
|
||||
help = top;
|
||||
|
||||
/* make _sure_ the region can hold a struct fl. */
|
||||
if (size < ALIGN(sizeof (struct fl *)))
|
||||
size = ALIGN(sizeof (struct fl *));
|
||||
top += ALIGN(sizeof(unsigned)) + ALIGN(size);
|
||||
#ifdef HEAP_LIMIT
|
||||
if (top > (char*)HEAP_LIMIT)
|
||||
panic("heap full (0x%lx+%zu)", help, size);
|
||||
if (top > (char *)HEAP_LIMIT)
|
||||
panic("heap full (0x%lx+%zu)", help, size);
|
||||
#endif
|
||||
*(unsigned *)(void *)help = (unsigned)ALIGN(size);
|
||||
#ifdef ALLOC_TRACE
|
||||
printf("=%lx\n", (u_long)help + ALIGN(sizeof(unsigned)));
|
||||
#endif
|
||||
return(help + ALIGN(sizeof(unsigned)));
|
||||
return help + ALIGN(sizeof(unsigned));
|
||||
}
|
||||
|
||||
/* we take the best fit */
|
||||
|
@ -227,14 +228,14 @@ alloc(size_t size)
|
|||
#ifndef ALLOC_FIRST_FIT
|
||||
found:
|
||||
#endif
|
||||
/* remove from freelist */
|
||||
help = (char *)(void *)*f;
|
||||
/* remove from freelist */
|
||||
help = (char *)(void *)*f;
|
||||
*f = (*f)->next;
|
||||
#ifdef ALLOC_TRACE
|
||||
printf("=%lx (origsize %u)\n", (u_long)help + ALIGN(sizeof(unsigned)),
|
||||
*(unsigned *)help);
|
||||
#endif
|
||||
return(help + ALIGN(sizeof(unsigned)));
|
||||
return help + ALIGN(sizeof(unsigned));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -242,14 +243,15 @@ void
|
|||
dealloc(void *ptr, size_t size)
|
||||
{
|
||||
struct fl *f =
|
||||
(struct fl *)(void *)((char*)(void *)ptr - ALIGN(sizeof(unsigned)));
|
||||
(struct fl *)(void *)((char *)(void *)ptr - ALIGN(sizeof(unsigned)));
|
||||
#ifdef ALLOC_TRACE
|
||||
printf("dealloc(%lx, %zu) (origsize %u)\n", (u_long)ptr, size, f->size);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
if (size > (size_t)f->size)
|
||||
printf("dealloc %u bytes @%lx, should be <=%u\n",
|
||||
size, (u_long)ptr, f->size);
|
||||
if (size > (size_t)f->size) {
|
||||
printf("dealloc %u bytes @%lx, should be <=%u\n",
|
||||
size, (u_long)ptr, f->size);
|
||||
}
|
||||
|
||||
if (ptr < (void *)HEAP_START)
|
||||
printf("dealloc: %lx before start of heap.\n", (u_long)ptr);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: arp.c,v 1.27 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: arp.c,v 1.28 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -63,7 +63,7 @@
|
|||
* to resolving internet addresses. Field names used correspond to
|
||||
* RFC 826.
|
||||
*/
|
||||
struct ether_arp {
|
||||
struct ether_arp {
|
||||
struct arphdr ea_hdr; /* fixed-size header */
|
||||
u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
|
||||
u_int8_t arp_spa[4]; /* sender protocol address */
|
||||
|
@ -94,9 +94,7 @@ static ssize_t arprecv __P((struct iodesc *, void *, size_t, time_t));
|
|||
|
||||
/* Broadcast an ARP packet, asking who has addr on interface d */
|
||||
u_char *
|
||||
arpwhohas(d, addr)
|
||||
struct iodesc *d;
|
||||
struct in_addr addr;
|
||||
arpwhohas(struct iodesc *d, struct in_addr addr)
|
||||
{
|
||||
int i;
|
||||
struct ether_arp *ah;
|
||||
|
@ -119,7 +117,7 @@ arpwhohas(d, addr)
|
|||
/* Try for cached answer first */
|
||||
for (i = 0, al = arp_list; i < arp_num; ++i, ++al)
|
||||
if (addr.s_addr == al->addr.s_addr)
|
||||
return (al->ea);
|
||||
return al->ea;
|
||||
|
||||
/* Don't overflow cache */
|
||||
if (arp_num > ARP_NUM - 1) {
|
||||
|
@ -129,10 +127,10 @@ arpwhohas(d, addr)
|
|||
|
||||
#ifdef ARP_DEBUG
|
||||
if (debug)
|
||||
printf("arpwhohas: send request for %s\n", inet_ntoa(addr));
|
||||
printf("arpwhohas: send request for %s\n", inet_ntoa(addr));
|
||||
#endif
|
||||
|
||||
bzero((char*)&wbuf.data, sizeof(wbuf.data));
|
||||
bzero((char *)&wbuf.data, sizeof(wbuf.data));
|
||||
ah = &wbuf.data.arp;
|
||||
ah->arp_hrd = htons(ARPHRD_ETHER);
|
||||
ah->arp_pro = htons(ETHERTYPE_IP);
|
||||
|
@ -168,14 +166,11 @@ arpwhohas(d, addr)
|
|||
MACPY(ah->arp_sha, al->ea);
|
||||
++arp_num;
|
||||
|
||||
return (al->ea);
|
||||
return al->ea;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
arpsend(d, pkt, len)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
arpsend(struct iodesc *d, void *pkt, size_t len)
|
||||
{
|
||||
|
||||
#ifdef ARP_DEBUG
|
||||
|
@ -183,7 +178,7 @@ arpsend(d, pkt, len)
|
|||
printf("arpsend: called\n");
|
||||
#endif
|
||||
|
||||
return (sendether(d, pkt, len, bcea, ETHERTYPE_ARP));
|
||||
return sendether(d, pkt, len, bcea, ETHERTYPE_ARP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -191,11 +186,7 @@ arpsend(d, pkt, len)
|
|||
* else -1 (and errno == 0)
|
||||
*/
|
||||
static ssize_t
|
||||
arprecv(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
arprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
ssize_t n;
|
||||
struct ether_arp *ah;
|
||||
|
@ -213,7 +204,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad len=%ld\n", (signed long) n);
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (etype != ETHERTYPE_ARP) {
|
||||
|
@ -221,7 +212,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("not arp type=%d\n", etype);
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Ethernet address now checked in readether() */
|
||||
|
@ -236,7 +227,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad hrd/pro/hln/pln\n");
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ah->arp_op == htons(ARPOP_REQUEST)) {
|
||||
|
@ -245,7 +236,7 @@ arprecv(d, pkt, len, tleft)
|
|||
printf("is request\n");
|
||||
#endif
|
||||
arp_reply(d, ah);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ah->arp_op != htons(ARPOP_REPLY)) {
|
||||
|
@ -253,7 +244,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("not ARP reply\n");
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Is the reply from the source we want? */
|
||||
|
@ -264,7 +255,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("unwanted address\n");
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
/* We don't care who the reply was sent to. */
|
||||
|
||||
|
@ -273,7 +264,7 @@ arprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("got it\n");
|
||||
#endif
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -281,9 +272,7 @@ arprecv(d, pkt, len, tleft)
|
|||
* Notes: Re-uses buffer. Pad to length = 46.
|
||||
*/
|
||||
void
|
||||
arp_reply(d, pkt)
|
||||
struct iodesc *d;
|
||||
void *pkt; /* the request */
|
||||
arp_reply(struct iodesc *d, void *pkt)
|
||||
{
|
||||
struct ether_arp *arp = pkt;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bcopy.c,v 1.10 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: bcopy.c,v 1.11 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -40,10 +40,7 @@
|
|||
* This is designed to be small, not fast.
|
||||
*/
|
||||
void
|
||||
bcopy(s1, s2, n)
|
||||
const void *s1;
|
||||
void *s2;
|
||||
size_t n;
|
||||
bcopy(const void *s1, void *s2, size_t n)
|
||||
{
|
||||
const char *f = s1;
|
||||
char *t = s2;
|
||||
|
@ -53,7 +50,8 @@ bcopy(s1, s2, n)
|
|||
t += n;
|
||||
while (n-- > 0)
|
||||
*--t = *--f;
|
||||
} else
|
||||
} else {
|
||||
while (n-- > 0)
|
||||
*t++ = *f++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootp.c,v 1.30 2007/10/01 13:15:06 martin Exp $ */
|
||||
/* $NetBSD: bootp.c,v 1.31 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -91,8 +91,7 @@ int bootp_flags;
|
|||
|
||||
/* Fetch required bootp information */
|
||||
void
|
||||
bootp(sock)
|
||||
int sock;
|
||||
bootp(int sock)
|
||||
{
|
||||
struct iodesc *d;
|
||||
struct bootp *bp;
|
||||
|
@ -271,10 +270,7 @@ bootp(sock)
|
|||
|
||||
/* Transmit a bootp request */
|
||||
static ssize_t
|
||||
bootpsend(d, pkt, len)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
bootpsend(struct iodesc *d, void *pkt, size_t len)
|
||||
{
|
||||
struct bootp *bp;
|
||||
|
||||
|
@ -291,15 +287,11 @@ bootpsend(d, pkt, len)
|
|||
printf("bootpsend: calling sendudp\n");
|
||||
#endif
|
||||
|
||||
return (sendudp(d, pkt, len));
|
||||
return sendudp(d, pkt, len);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
bootprecv(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
bootprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
ssize_t n;
|
||||
struct bootp *bp;
|
||||
|
@ -352,16 +344,14 @@ bootprecv(d, pkt, len, tleft)
|
|||
else
|
||||
printf("bootprecv: unknown vendor 0x%lx\n", (long)bp->bp_vend);
|
||||
|
||||
return (n);
|
||||
return n;
|
||||
bad:
|
||||
errno = 0;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
vend_rfc1048(cp, len)
|
||||
u_char *cp;
|
||||
u_int len;
|
||||
vend_rfc1048(u_char *cp, u_int len)
|
||||
{
|
||||
u_char *ep;
|
||||
int size;
|
||||
|
@ -403,7 +393,7 @@ vend_rfc1048(cp, len)
|
|||
#ifdef SUPPORT_DHCP
|
||||
if (tag == TAG_DHCP_MSGTYPE) {
|
||||
if (*cp != expected_dhcpmsgtype)
|
||||
return (-1);
|
||||
return -1;
|
||||
dhcp_ok = 1;
|
||||
}
|
||||
if (tag == TAG_SERVERID) {
|
||||
|
@ -419,13 +409,12 @@ vend_rfc1048(cp, len)
|
|||
#endif
|
||||
cp += size;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef BOOTP_VEND_CMU
|
||||
static void
|
||||
vend_cmu(cp)
|
||||
u_char *cp;
|
||||
vend_cmu(u_char *cp)
|
||||
{
|
||||
struct cmu_vend *vp;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootp.h,v 1.7 2002/03/20 23:10:39 thorpej Exp $ */
|
||||
/* $NetBSD: bootp.h,v 1.8 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
|
||||
|
@ -41,7 +41,7 @@ struct bootp {
|
|||
#else
|
||||
#define BOOTP_VENDSIZE 64
|
||||
#endif
|
||||
unsigned char bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */
|
||||
unsigned char bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -64,7 +64,6 @@ struct bootp {
|
|||
*/
|
||||
#define VM_RFC1048 { 99, 130, 83, 99 }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* RFC1048 tag values used to specify what information is being supplied in
|
||||
|
@ -108,13 +107,13 @@ struct bootp {
|
|||
#define TAG_END ((unsigned char) 255)
|
||||
|
||||
#ifdef SUPPORT_DHCP
|
||||
#define DHCPDISCOVER 1
|
||||
#define DHCPOFFER 2
|
||||
#define DHCPREQUEST 3
|
||||
#define DHCPDECLINE 4
|
||||
#define DHCPACK 5
|
||||
#define DHCPNAK 6
|
||||
#define DHCPRELEASE 7
|
||||
#define DHCPDISCOVER 1
|
||||
#define DHCPOFFER 2
|
||||
#define DHCPREQUEST 3
|
||||
#define DHCPDECLINE 4
|
||||
#define DHCPACK 5
|
||||
#define DHCPNAK 6
|
||||
#define DHCPRELEASE 7
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bootparam.c,v 1.15 2003/03/19 17:18:07 drochner Exp $ */
|
||||
/* $NetBSD: bootparam.c,v 1.16 2007/11/24 13:20:53 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Gordon W. Ross
|
||||
|
@ -85,11 +85,11 @@ struct xdr_inaddr {
|
|||
int32_t addr[4];
|
||||
};
|
||||
|
||||
int xdr_inaddr_encode __P((char **p, struct in_addr ia));
|
||||
int xdr_inaddr_decode __P((char **p, struct in_addr *ia));
|
||||
int xdr_inaddr_encode __P((char **, struct in_addr));
|
||||
int xdr_inaddr_decode __P((char **, struct in_addr *));
|
||||
|
||||
int xdr_string_encode __P((char **p, char *str, int len));
|
||||
int xdr_string_decode __P((char **p, char *str, int *len_p));
|
||||
int xdr_string_encode __P((char **, char *, int));
|
||||
int xdr_string_decode __P((char **, char *, int *));
|
||||
|
||||
|
||||
/*
|
||||
|
@ -108,8 +108,7 @@ int xdr_string_decode __P((char **p, char *str, int *len_p));
|
|||
* know about us (don't want to broadcast a getport call).
|
||||
*/
|
||||
int
|
||||
bp_whoami(sockfd)
|
||||
int sockfd;
|
||||
bp_whoami(int sockfd)
|
||||
{
|
||||
/* RPC structures for PMAPPROC_CALLIT */
|
||||
struct args {
|
||||
|
@ -142,7 +141,7 @@ bp_whoami(sockfd)
|
|||
|
||||
if (!(d = socktodesc(sockfd))) {
|
||||
RPC_PRINTF(("bp_whoami: bad socket. %d\n", sockfd));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
args = &sdata.d;
|
||||
repl = &rdata.d;
|
||||
|
@ -154,13 +153,13 @@ bp_whoami(sockfd)
|
|||
args->vers = htonl(BOOTPARAM_VERS);
|
||||
args->proc = htonl(BOOTPARAM_WHOAMI);
|
||||
args->arglen = htonl(sizeof(struct xdr_inaddr));
|
||||
send_tail = (char*) &args->xina;
|
||||
send_tail = (char *)&args->xina;
|
||||
|
||||
/*
|
||||
* append encapsulated data (client IP address)
|
||||
*/
|
||||
if (xdr_inaddr_encode(&send_tail, myip))
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
/* RPC: portmap/callit */
|
||||
d->myport = htons(--rpc_port);
|
||||
|
@ -168,11 +167,11 @@ bp_whoami(sockfd)
|
|||
/* rpc_call will set d->destport */
|
||||
|
||||
len = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_CALLIT,
|
||||
args, send_tail - (char*)args,
|
||||
args, send_tail - (char *)args,
|
||||
repl, sizeof(*repl));
|
||||
if (len < 8) {
|
||||
printf("bootparamd: 'whoami' call failed\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save bootparam server address (from IP header). */
|
||||
|
@ -200,32 +199,32 @@ bp_whoami(sockfd)
|
|||
x = ntohl(repl->encap_len);
|
||||
if (len < x) {
|
||||
printf("bp_whoami: short reply, %d < %d\n", len, x);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
recv_head = (char*) repl->capsule;
|
||||
recv_head = (char *)repl->capsule;
|
||||
|
||||
/* client name */
|
||||
hostnamelen = MAXHOSTNAMELEN-1;
|
||||
if (xdr_string_decode(&recv_head, hostname, &hostnamelen)) {
|
||||
RPC_PRINTF(("bp_whoami: bad hostname\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* domain name */
|
||||
domainnamelen = MAXHOSTNAMELEN-1;
|
||||
if (xdr_string_decode(&recv_head, domainname, &domainnamelen)) {
|
||||
RPC_PRINTF(("bp_whoami: bad domainname\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* gateway address */
|
||||
if (xdr_inaddr_decode(&recv_head, &gateip)) {
|
||||
RPC_PRINTF(("bp_whoami: bad gateway\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* success */
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,11 +236,7 @@ bp_whoami(sockfd)
|
|||
* server pathname
|
||||
*/
|
||||
int
|
||||
bp_getfile(sockfd, key, serv_addr, pathname)
|
||||
int sockfd;
|
||||
char *key;
|
||||
char *pathname;
|
||||
struct in_addr *serv_addr;
|
||||
bp_getfile(int sockfd, char *key, struct in_addr *serv_addr, char *pathname)
|
||||
{
|
||||
struct {
|
||||
n_long h[RPC_HEADER_WORDS];
|
||||
|
@ -259,11 +254,11 @@ bp_getfile(sockfd, key, serv_addr, pathname)
|
|||
|
||||
if (!(d = socktodesc(sockfd))) {
|
||||
RPC_PRINTF(("bp_getfile: bad socket. %d\n", sockfd));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_tail = (char*) sdata.d;
|
||||
recv_head = (char*) rdata.d;
|
||||
send_tail = (char *)sdata.d;
|
||||
recv_head = (char *)rdata.d;
|
||||
|
||||
/*
|
||||
* Build request message.
|
||||
|
@ -272,30 +267,30 @@ bp_getfile(sockfd, key, serv_addr, pathname)
|
|||
/* client name (hostname) */
|
||||
if (xdr_string_encode(&send_tail, hostname, hostnamelen)) {
|
||||
RPC_PRINTF(("bp_getfile: bad client\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* key name (root or swap) */
|
||||
if (xdr_string_encode(&send_tail, key, strlen(key))) {
|
||||
RPC_PRINTF(("bp_getfile: bad key\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* RPC: bootparam/getfile */
|
||||
d->myport = htons(--rpc_port);
|
||||
d->destip = bp_server_addr;
|
||||
d->destip = bp_server_addr;
|
||||
/* rpc_call will set d->destport */
|
||||
|
||||
rlen = rpc_call(d,
|
||||
BOOTPARAM_PROG, BOOTPARAM_VERS, BOOTPARAM_GETFILE,
|
||||
sdata.d, send_tail - (char*)sdata.d,
|
||||
sdata.d, send_tail - (char *)sdata.d,
|
||||
rdata.d, sizeof(rdata.d));
|
||||
if (rlen < 4) {
|
||||
RPC_PRINTF(("bp_getfile: short reply\n"));
|
||||
errno = EBADRPC;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
recv_head = (char*) rdata.d;
|
||||
recv_head = (char *)rdata.d;
|
||||
|
||||
/*
|
||||
* Parse result message.
|
||||
|
@ -305,24 +300,24 @@ bp_getfile(sockfd, key, serv_addr, pathname)
|
|||
sn_len = FNAME_SIZE-1;
|
||||
if (xdr_string_decode(&recv_head, serv_name, &sn_len)) {
|
||||
RPC_PRINTF(("bp_getfile: bad server name\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* server IP address (mountd/NFS) */
|
||||
if (xdr_inaddr_decode(&recv_head, serv_addr)) {
|
||||
RPC_PRINTF(("bp_getfile: bad server addr\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* server pathname */
|
||||
path_len = MAXPATHLEN-1;
|
||||
path_len = MAXPATHLEN - 1;
|
||||
if (xdr_string_decode(&recv_head, pathname, &path_len)) {
|
||||
RPC_PRINTF(("bp_getfile: bad server path\n"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* success */
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,17 +328,14 @@ bp_getfile(sockfd, key, serv_addr, pathname)
|
|||
|
||||
|
||||
int
|
||||
xdr_string_encode(pkt, str, len)
|
||||
char **pkt;
|
||||
char *str;
|
||||
int len;
|
||||
xdr_string_encode(char **pkt, char *str, int len)
|
||||
{
|
||||
u_int32_t *lenp;
|
||||
char *datap;
|
||||
int padlen = (len + 3) & ~3; /* padded length */
|
||||
|
||||
/* The data will be int aligned. */
|
||||
lenp = (u_int32_t*) *pkt;
|
||||
lenp = (u_int32_t *)*pkt;
|
||||
*pkt += sizeof(*lenp);
|
||||
*lenp = htonl(len);
|
||||
|
||||
|
@ -351,14 +343,12 @@ xdr_string_encode(pkt, str, len)
|
|||
*pkt += padlen;
|
||||
bcopy(str, datap, len);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* len_p: bufsize - 1 */
|
||||
int
|
||||
xdr_string_decode(pkt, str, len_p)
|
||||
char **pkt;
|
||||
char *str;
|
||||
int *len_p; /* bufsize - 1 */
|
||||
xdr_string_decode(char **pkt, char *str, int *len_p)
|
||||
{
|
||||
u_int32_t *lenp;
|
||||
char *datap;
|
||||
|
@ -366,7 +356,7 @@ xdr_string_decode(pkt, str, len_p)
|
|||
int plen; /* padded length */
|
||||
|
||||
/* The data will be int aligned. */
|
||||
lenp = (u_int32_t*) *pkt;
|
||||
lenp = (u_int32_t *)*pkt;
|
||||
*pkt += sizeof(*lenp);
|
||||
slen = ntohl(*lenp);
|
||||
plen = (slen + 3) & ~3;
|
||||
|
@ -380,14 +370,13 @@ xdr_string_decode(pkt, str, len_p)
|
|||
str[slen] = '\0';
|
||||
*len_p = slen;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ia: network order */
|
||||
int
|
||||
xdr_inaddr_encode(pkt, ia)
|
||||
char **pkt;
|
||||
struct in_addr ia; /* network order */
|
||||
xdr_inaddr_encode(char **pkt, struct in_addr ia)
|
||||
{
|
||||
struct xdr_inaddr *xi;
|
||||
u_char *cp;
|
||||
|
@ -398,7 +387,7 @@ xdr_inaddr_encode(pkt, ia)
|
|||
} uia;
|
||||
|
||||
/* The data will be int aligned. */
|
||||
xi = (struct xdr_inaddr *) *pkt;
|
||||
xi = (struct xdr_inaddr *)*pkt;
|
||||
*pkt += sizeof(*xi);
|
||||
xi->atype = htonl(1);
|
||||
uia.l = ia.s_addr;
|
||||
|
@ -414,13 +403,12 @@ xdr_inaddr_encode(pkt, ia)
|
|||
*ip++ = htonl((unsigned int)*cp++);
|
||||
*ip++ = htonl((unsigned int)*cp++);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ia: network order */
|
||||
int
|
||||
xdr_inaddr_decode(pkt, ia)
|
||||
char **pkt;
|
||||
struct in_addr *ia; /* network order */
|
||||
xdr_inaddr_decode(char **pkt, struct in_addr *ia)
|
||||
{
|
||||
struct xdr_inaddr *xi;
|
||||
u_char *cp;
|
||||
|
@ -431,12 +419,12 @@ xdr_inaddr_decode(pkt, ia)
|
|||
} uia;
|
||||
|
||||
/* The data will be int aligned. */
|
||||
xi = (struct xdr_inaddr *) *pkt;
|
||||
xi = (struct xdr_inaddr *)*pkt;
|
||||
*pkt += sizeof(*xi);
|
||||
if (xi->atype != htonl(1)) {
|
||||
RPC_PRINTF(("xdr_inaddr_decode: bad addrtype=%d\n",
|
||||
ntohl(xi->atype)));
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cp = uia.c;
|
||||
|
@ -452,5 +440,5 @@ xdr_inaddr_decode(pkt, ia)
|
|||
*cp++ = ntohl(*ip++);
|
||||
ia->s_addr = uia.l;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* $NetBSD: bootparam.h,v 1.3 1998/01/05 19:19:41 perry Exp $ */
|
||||
|
||||
int bp_whoami(int sock);
|
||||
int bp_getfile(int sock, char *key, struct in_addr *addrp, char *path);
|
||||
/* $NetBSD: bootparam.h,v 1.4 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
int bp_whoami(int);
|
||||
int bp_getfile(int, char *, struct in_addr *, char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: byteorder.c,v 1.2 2001/10/31 20:19:52 thorpej Exp $ */
|
||||
/* $NetBSD: byteorder.c,v 1.3 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
|
@ -62,7 +62,7 @@ sa_htobe16(uint16_t val)
|
|||
un.bytes[1] = val & 0xff;
|
||||
un.bytes[0] = (val >> 8) & 0xff;
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
@ -73,7 +73,7 @@ sa_htole16(uint16_t val)
|
|||
un.bytes[0] = val & 0xff;
|
||||
un.bytes[1] = (val >> 8) & 0xff;
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
@ -84,7 +84,7 @@ sa_be16toh(uint16_t val)
|
|||
un.val = val;
|
||||
|
||||
return ((un.bytes[0] << 8) |
|
||||
un.bytes[1]);
|
||||
un.bytes[1]);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
@ -95,7 +95,7 @@ sa_le16toh(uint16_t val)
|
|||
un.val = val;
|
||||
|
||||
return ((un.bytes[1] << 8) |
|
||||
un.bytes[0]);
|
||||
un.bytes[0]);
|
||||
}
|
||||
|
||||
/* 32-bit */
|
||||
|
@ -110,7 +110,7 @@ sa_htobe32(uint32_t val)
|
|||
un.bytes[1] = (val >> 16) & 0xff;
|
||||
un.bytes[0] = (val >> 24) & 0xff;
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -123,7 +123,7 @@ sa_htole32(uint32_t val)
|
|||
un.bytes[2] = (val >> 16) & 0xff;
|
||||
un.bytes[3] = (val >> 24) & 0xff;
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -134,9 +134,9 @@ sa_be32toh(uint32_t val)
|
|||
un.val = val;
|
||||
|
||||
return ((un.bytes[0] << 24) |
|
||||
(un.bytes[1] << 16) |
|
||||
(un.bytes[2] << 8) |
|
||||
un.bytes[3]);
|
||||
(un.bytes[1] << 16) |
|
||||
(un.bytes[2] << 8) |
|
||||
un.bytes[3]);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -147,9 +147,9 @@ sa_le32toh(uint32_t val)
|
|||
un.val = val;
|
||||
|
||||
return ((un.bytes[3] << 24) |
|
||||
(un.bytes[2] << 16) |
|
||||
(un.bytes[1] << 8) |
|
||||
un.bytes[0]);
|
||||
(un.bytes[2] << 16) |
|
||||
(un.bytes[1] << 8) |
|
||||
un.bytes[0]);
|
||||
}
|
||||
|
||||
/* 64-bit */
|
||||
|
@ -162,7 +162,7 @@ sa_htobe64(uint64_t val)
|
|||
un.words[BE64_HI] = sa_htobe32(val >> 32);
|
||||
un.words[BE64_LO] = sa_htobe32(val & 0xffffffffU);
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -173,7 +173,7 @@ sa_htole64(uint64_t val)
|
|||
un.words[LE64_HI] = sa_htole32(val >> 32);
|
||||
un.words[LE64_LO] = sa_htole32(val & 0xffffffffU);
|
||||
|
||||
return (un.val);
|
||||
return un.val;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -189,7 +189,7 @@ sa_be64toh(uint64_t val)
|
|||
rv = (((uint64_t)un.words[BE64_HI]) << 32) |
|
||||
un.words[BE64_LO];
|
||||
|
||||
return (rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
|
@ -205,5 +205,5 @@ sa_le64toh(uint64_t val)
|
|||
rv = (((uint64_t)un.words[LE64_HI]) << 32) |
|
||||
un.words[LE64_LO];
|
||||
|
||||
return (rv);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bzero.c,v 1.3 1999/11/13 21:17:56 thorpej Exp $ */
|
||||
/* $NetBSD: bzero.c,v 1.4 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -36,9 +36,7 @@
|
|||
#undef bzero /* in case of LIBSA_USE_MEMSET */
|
||||
|
||||
void
|
||||
bzero(dstv, length)
|
||||
void *dstv;
|
||||
size_t length;
|
||||
bzero(void *dstv, size_t length)
|
||||
{
|
||||
u_char *dst = dstv;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd9660.c,v 1.22 2007/03/05 14:49:04 he Exp $ */
|
||||
/* $NetBSD: cd9660.c,v 1.23 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Wolfgang Solfrank.
|
||||
|
@ -182,7 +182,7 @@ cd9660_open(const char *path, struct open_file *f)
|
|||
twiddle();
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
buf_size, buf, &nread);
|
||||
buf_size, buf, &nread);
|
||||
if (rc)
|
||||
goto out;
|
||||
if (nread != buf_size) {
|
||||
|
@ -223,9 +223,12 @@ cd9660_open(const char *path, struct open_file *f)
|
|||
}
|
||||
}
|
||||
|
||||
/* Now bno has the start of the directory that supposedly contains the file */
|
||||
/*
|
||||
* Now bno has the start of the directory that supposedly
|
||||
* contains the file
|
||||
*/
|
||||
bno--;
|
||||
dsize = 1; /* Something stupid, but > 0 XXX */
|
||||
dsize = 1; /* Something stupid, but > 0 XXX */
|
||||
for (psize = 0; psize < dsize;) {
|
||||
if (!(psize % ISO_DEFAULT_BLOCK_SIZE)) {
|
||||
bno++;
|
||||
|
@ -233,9 +236,9 @@ cd9660_open(const char *path, struct open_file *f)
|
|||
twiddle();
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE,
|
||||
buf, &nread);
|
||||
cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE,
|
||||
buf, &nread);
|
||||
if (rc)
|
||||
goto out;
|
||||
if (nread != ISO_DEFAULT_BLOCK_SIZE) {
|
||||
|
@ -256,7 +259,8 @@ cd9660_open(const char *path, struct open_file *f)
|
|||
if (dirmatch(path, dp))
|
||||
break;
|
||||
psize += isonum_711(dp->length);
|
||||
dp = (struct iso_directory_record *)((char *)dp + isonum_711(dp->length));
|
||||
dp = (struct iso_directory_record *)
|
||||
((char *)dp + isonum_711(dp->length));
|
||||
}
|
||||
|
||||
if (psize >= dsize) {
|
||||
|
@ -320,7 +324,7 @@ cd9660_read(struct open_file *f, void *start, size_t size, size_t *resid)
|
|||
twiddle();
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE, dp, &nread);
|
||||
ISO_DEFAULT_BLOCK_SIZE, dp, &nread);
|
||||
if (rc)
|
||||
return rc;
|
||||
if (nread != ISO_DEFAULT_BLOCK_SIZE)
|
||||
|
@ -349,6 +353,7 @@ cd9660_read(struct open_file *f, void *start, size_t size, size_t *resid)
|
|||
int
|
||||
cd9660_write(struct open_file *f, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
|
||||
return EROFS;
|
||||
}
|
||||
#endif /* !defined(LIBSA_NO_FS_WRITE) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: checkpasswd.c,v 1.7 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: checkpasswd.c,v 1.8 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -37,8 +37,7 @@
|
|||
#include "stand.h"
|
||||
|
||||
char *
|
||||
getpass(prompt)
|
||||
const char *prompt;
|
||||
getpass(const char *prompt)
|
||||
{
|
||||
int c;
|
||||
char *lp;
|
||||
|
@ -46,13 +45,13 @@ getpass(prompt)
|
|||
|
||||
printf(prompt);
|
||||
|
||||
for (lp = buf;;)
|
||||
for (lp = buf;;) {
|
||||
switch (c = getchar() & 0177) {
|
||||
case '\n':
|
||||
case '\r':
|
||||
*lp = '\0';
|
||||
putchar('\n');
|
||||
return (buf);
|
||||
return buf;
|
||||
case '\b':
|
||||
case '\177':
|
||||
if (lp > buf) {
|
||||
|
@ -87,7 +86,9 @@ getpass(prompt)
|
|||
default:
|
||||
*lp++ = c;
|
||||
putchar('*');
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
@ -98,6 +99,7 @@ char bootpasswd[16] = {'\0'}; /* into data segment! */
|
|||
int
|
||||
checkpasswd(void)
|
||||
{
|
||||
|
||||
return check_password(bootpasswd);
|
||||
}
|
||||
|
||||
|
@ -113,7 +115,7 @@ check_password(const char *password)
|
|||
if (password[i])
|
||||
break;
|
||||
if (i == 16)
|
||||
return (1); /* no password set */
|
||||
return 1; /* no password set */
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
passwd = getpass("Password: ");
|
||||
|
@ -121,10 +123,9 @@ check_password(const char *password)
|
|||
MD5Update(&md5ctx, passwd, strlen(passwd));
|
||||
MD5Final(pwdigest, &md5ctx);
|
||||
if (memcmp(pwdigest, password, 16) == 0)
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* failed */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: close.c,v 1.12 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: close.c,v 1.13 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -64,11 +64,10 @@
|
|||
|
||||
int
|
||||
#ifndef __INTERNAL_LIBSA_CREAD
|
||||
close(fd)
|
||||
close(int fd)
|
||||
#else
|
||||
oclose(fd)
|
||||
oclose(int fd)
|
||||
#endif
|
||||
int fd;
|
||||
{
|
||||
struct open_file *f = &files[fd];
|
||||
int err1 = 0, err2 = 0;
|
||||
|
@ -76,7 +75,7 @@ oclose(fd)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
|
@ -94,11 +93,11 @@ oclose(fd)
|
|||
f->f_flags = 0;
|
||||
if (err1) {
|
||||
errno = err1;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (err2) {
|
||||
errno = err2;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: closeall.c,v 1.4 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: closeall.c,v 1.5 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -63,11 +63,11 @@
|
|||
#include "stand.h"
|
||||
|
||||
void
|
||||
closeall()
|
||||
closeall(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SOPEN_MAX; i++)
|
||||
if (files[i].f_flags != 0)
|
||||
(void)close(i);
|
||||
for (i = 0; i < SOPEN_MAX; i++)
|
||||
if (files[i].f_flags != 0)
|
||||
(void)close(i);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cread.c,v 1.18 2006/01/25 18:27:23 christos Exp $ */
|
||||
/* $NetBSD: cread.c,v 1.19 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -92,37 +92,31 @@ void zmemcpy __P((unsigned char *, unsigned char *, unsigned int));
|
|||
*/
|
||||
|
||||
void *
|
||||
zcalloc (opaque, items, size)
|
||||
void *opaque;
|
||||
unsigned items;
|
||||
unsigned size;
|
||||
zcalloc(void *opaque, unsigned int items, unsigned int size)
|
||||
{
|
||||
return(alloc(items * size));
|
||||
|
||||
return alloc(items * size);
|
||||
}
|
||||
|
||||
void
|
||||
zcfree (opaque, ptr)
|
||||
void *opaque;
|
||||
void *ptr;
|
||||
zcfree(void *opaque, void *ptr)
|
||||
{
|
||||
|
||||
dealloc(ptr, 0); /* XXX works only with modified allocator */
|
||||
}
|
||||
|
||||
void
|
||||
zmemcpy(dest, source, len)
|
||||
unsigned char *dest;
|
||||
unsigned char *source;
|
||||
unsigned int len;
|
||||
zmemcpy(unsigned char *dest, unsigned char *source, unsigned int len)
|
||||
{
|
||||
|
||||
bcopy(source, dest, len);
|
||||
}
|
||||
|
||||
static int
|
||||
get_byte(s)
|
||||
struct sd *s;
|
||||
get_byte(struct sd *s)
|
||||
{
|
||||
if (s->z_eof)
|
||||
return (EOF);
|
||||
return EOF;
|
||||
|
||||
if (s->stream.avail_in == 0) {
|
||||
int got;
|
||||
|
@ -131,7 +125,8 @@ get_byte(s)
|
|||
got = oread(s->fd, s->inbuf, Z_BUFSIZE);
|
||||
if (got <= 0) {
|
||||
s->z_eof = 1;
|
||||
if (errno) s->z_err = Z_ERRNO;
|
||||
if (errno)
|
||||
s->z_err = Z_ERRNO;
|
||||
return EOF;
|
||||
}
|
||||
s->stream.avail_in = got;
|
||||
|
@ -142,24 +137,23 @@ get_byte(s)
|
|||
}
|
||||
|
||||
static unsigned long
|
||||
getLong (s)
|
||||
struct sd *s;
|
||||
getLong(struct sd *s)
|
||||
{
|
||||
unsigned long x = (unsigned long)get_byte(s);
|
||||
unsigned long x;
|
||||
int c;
|
||||
|
||||
x = (unsigned long)get_byte(s);
|
||||
x += ((unsigned long)get_byte(s)) << 8;
|
||||
x += ((unsigned long)get_byte(s)) << 16;
|
||||
c = get_byte(s);
|
||||
if (c == EOF)
|
||||
s->z_err = Z_DATA_ERROR;
|
||||
x += ((unsigned long)c)<<24;
|
||||
x += ((unsigned long)c) << 24;
|
||||
return x;
|
||||
}
|
||||
|
||||
static void
|
||||
check_header(s)
|
||||
struct sd *s;
|
||||
check_header(struct sd *s)
|
||||
{
|
||||
int method; /* method byte */
|
||||
int flags; /* flags byte */
|
||||
|
@ -206,15 +200,18 @@ check_header(s)
|
|||
len = (unsigned int)get_byte(s);
|
||||
len += ((unsigned int)get_byte(s)) << 8;
|
||||
/* len is garbage if EOF but the loop below will quit anyway */
|
||||
while (len-- != 0 && get_byte(s) != EOF) /*void*/;
|
||||
while (len-- != 0 && get_byte(s) != EOF)
|
||||
/*void*/;
|
||||
}
|
||||
if ((flags & ORIG_NAME) != 0) {
|
||||
/* skip the original file name */
|
||||
while ((c = get_byte(s)) != 0 && c != EOF) /*void*/;
|
||||
while ((c = get_byte(s)) != 0 && c != EOF)
|
||||
/*void*/;
|
||||
}
|
||||
if ((flags & COMMENT) != 0) {
|
||||
/* skip the .gz file comment */
|
||||
while ((c = get_byte(s)) != 0 && c != EOF) /*void*/;
|
||||
while ((c = get_byte(s)) != 0 && c != EOF)
|
||||
/*void*/;
|
||||
}
|
||||
if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
|
||||
for (len = 0; len < 2; len++)
|
||||
|
@ -228,16 +225,14 @@ check_header(s)
|
|||
*/
|
||||
|
||||
int
|
||||
open(fname, mode)
|
||||
const char *fname;
|
||||
int mode;
|
||||
open(const char *fname, int mode)
|
||||
{
|
||||
int fd;
|
||||
struct sd *s = 0;
|
||||
|
||||
if (((fd = oopen(fname, mode)) == -1) || (mode != 0))
|
||||
/* compression only for read */
|
||||
return (fd);
|
||||
return fd;
|
||||
|
||||
ss[fd] = s = alloc(sizeof(struct sd));
|
||||
if (s == 0)
|
||||
|
@ -247,7 +242,7 @@ open(fname, mode)
|
|||
if (inflateInit2(&(s->stream), -15) != Z_OK)
|
||||
goto errout;
|
||||
|
||||
s->stream.next_in = s->inbuf = (unsigned char*)alloc(Z_BUFSIZE);
|
||||
s->stream.next_in = s->inbuf = (unsigned char *)alloc(Z_BUFSIZE);
|
||||
if (s->inbuf == 0) {
|
||||
inflateEnd(&(s->stream));
|
||||
goto errout;
|
||||
|
@ -255,18 +250,17 @@ open(fname, mode)
|
|||
|
||||
s->fd = fd;
|
||||
check_header(s); /* skip the .gz header */
|
||||
return (fd);
|
||||
return fd;
|
||||
|
||||
errout:
|
||||
if (s != 0)
|
||||
dealloc(s, sizeof(struct sd));
|
||||
oclose(fd);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
close(fd)
|
||||
int fd;
|
||||
close(int fd)
|
||||
{
|
||||
struct open_file *f;
|
||||
struct sd *s;
|
||||
|
@ -274,13 +268,13 @@ close(fd)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
f = &files[fd];
|
||||
|
||||
if ((f->f_flags & F_READ) == 0)
|
||||
return (oclose(fd));
|
||||
return oclose(fd);
|
||||
|
||||
s = ss[fd];
|
||||
|
||||
|
@ -289,14 +283,11 @@ close(fd)
|
|||
dealloc(s->inbuf, Z_BUFSIZE);
|
||||
dealloc(s, sizeof(struct sd));
|
||||
|
||||
return (oclose(fd));
|
||||
return oclose(fd);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
read(fd, buf, len)
|
||||
int fd;
|
||||
void *buf;
|
||||
size_t len;
|
||||
read(int fd, void *buf, size_t len)
|
||||
{
|
||||
struct sd *s;
|
||||
unsigned char *start = buf; /* starting point for crc computation */
|
||||
|
@ -304,9 +295,9 @@ read(fd, buf, len)
|
|||
s = ss[fd];
|
||||
|
||||
if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)
|
||||
return (-1);
|
||||
return -1;
|
||||
if (s->z_err == Z_STREAM_END)
|
||||
return (0); /* EOF */
|
||||
return 0; /* EOF */
|
||||
|
||||
s->stream.next_out = buf;
|
||||
s->stream.avail_out = len;
|
||||
|
@ -329,9 +320,9 @@ read(fd, buf, len)
|
|||
if (s->stream.avail_out > 0) {
|
||||
int got;
|
||||
got = oread(s->fd, s->stream.next_out,
|
||||
s->stream.avail_out);
|
||||
s->stream.avail_out);
|
||||
if (got == -1)
|
||||
return (got);
|
||||
return got;
|
||||
s->stream.avail_out -= got;
|
||||
}
|
||||
return (int)(len - s->stream.avail_out);
|
||||
|
@ -378,16 +369,13 @@ read(fd, buf, len)
|
|||
}
|
||||
|
||||
s->crc = crc32(s->crc, start,
|
||||
(unsigned int)(s->stream.next_out - start));
|
||||
(unsigned int)(s->stream.next_out - start));
|
||||
|
||||
return (int)(len - s->stream.avail_out);
|
||||
}
|
||||
|
||||
off_t
|
||||
lseek(fd, offset, where)
|
||||
int fd;
|
||||
off_t offset;
|
||||
int where;
|
||||
lseek(int fd, off_t offset, int where)
|
||||
{
|
||||
struct open_file *f;
|
||||
struct sd *s;
|
||||
|
@ -395,13 +383,13 @@ lseek(fd, offset, where)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
f = &files[fd];
|
||||
|
||||
if ((f->f_flags & F_READ) == 0)
|
||||
return (olseek(fd, offset, where));
|
||||
return olseek(fd, offset, where);
|
||||
|
||||
s = ss[fd];
|
||||
|
||||
|
@ -411,12 +399,12 @@ lseek(fd, offset, where)
|
|||
/* make sure the lookahead buffer is invalid */
|
||||
s->stream.avail_in = 0;
|
||||
}
|
||||
return (res);
|
||||
return res;
|
||||
}
|
||||
|
||||
switch(where) {
|
||||
case SEEK_CUR:
|
||||
offset += s->stream.total_out;
|
||||
offset += s->stream.total_out;
|
||||
case SEEK_SET:
|
||||
/* if seek backwards, simply start from the beginning */
|
||||
if (offset < s->stream.total_out) {
|
||||
|
@ -425,7 +413,7 @@ lseek(fd, offset, where)
|
|||
|
||||
res = olseek(fd, 0, SEEK_SET);
|
||||
if(res == (off_t)-1)
|
||||
return(res);
|
||||
return res;
|
||||
/* ??? perhaps fallback to close / open */
|
||||
|
||||
inflateEnd(&(s->stream));
|
||||
|
@ -440,7 +428,7 @@ lseek(fd, offset, where)
|
|||
check_header(s); /* skip the .gz header */
|
||||
}
|
||||
|
||||
/* to seek forwards, throw away data */
|
||||
/* to seek forwards, throw away data */
|
||||
if (offset > s->stream.total_out) {
|
||||
off_t toskip = offset - s->stream.total_out;
|
||||
|
||||
|
@ -448,10 +436,12 @@ lseek(fd, offset, where)
|
|||
#define DUMMYBUFSIZE 256
|
||||
char dummybuf[DUMMYBUFSIZE];
|
||||
off_t len = toskip;
|
||||
if (len > DUMMYBUFSIZE) len = DUMMYBUFSIZE;
|
||||
|
||||
if (len > DUMMYBUFSIZE)
|
||||
len = DUMMYBUFSIZE;
|
||||
if (read(fd, dummybuf, len) != len) {
|
||||
errno = EOFFSET;
|
||||
return ((off_t)-1);
|
||||
return (off_t)-1;
|
||||
}
|
||||
toskip -= len;
|
||||
}
|
||||
|
@ -460,13 +450,14 @@ lseek(fd, offset, where)
|
|||
if (offset != s->stream.total_out)
|
||||
panic("lseek compressed");
|
||||
#endif
|
||||
return (offset);
|
||||
return offset;
|
||||
case SEEK_END:
|
||||
errno = EOFFSET;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ((off_t)-1);
|
||||
return (off_t)-1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dev.c,v 1.7 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: dev.c,v 1.8 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -37,22 +37,21 @@
|
|||
#include "stand.h"
|
||||
|
||||
int
|
||||
nodev()
|
||||
nodev(void)
|
||||
{
|
||||
return (ENXIO);
|
||||
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
void
|
||||
nullsys()
|
||||
nullsys(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
noioctl(f, cmd, data)
|
||||
struct open_file *f;
|
||||
u_long cmd;
|
||||
void *data;
|
||||
noioctl(struct open_file *f, u_long cmd, void *data)
|
||||
{
|
||||
return (EINVAL);
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dev_net.c,v 1.21 2007/10/27 12:19:41 tsutsui Exp $ */
|
||||
/* $NetBSD: dev_net.c,v 1.22 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -78,7 +78,7 @@ extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
|
|||
static int netdev_sock = -1;
|
||||
static int netdev_opens;
|
||||
|
||||
static int net_getparams __P((int sock));
|
||||
static int net_getparams __P((int));
|
||||
|
||||
/*
|
||||
* Called by devopen after it sets f->f_dev to our devsw entry.
|
||||
|
@ -93,7 +93,7 @@ net_open(struct open_file *f, ...)
|
|||
int error = 0;
|
||||
|
||||
va_start(ap, f);
|
||||
devname = va_arg(ap, char*);
|
||||
devname = va_arg(ap, char *);
|
||||
va_end(ap);
|
||||
|
||||
#ifdef NETIF_DEBUG
|
||||
|
@ -108,7 +108,7 @@ net_open(struct open_file *f, ...)
|
|||
netdev_sock = netif_open(devname);
|
||||
if (netdev_sock < 0) {
|
||||
printf("netif_open() failed\n");
|
||||
return (ENXIO);
|
||||
return ENXIO;
|
||||
}
|
||||
#ifdef NETIF_DEBUG
|
||||
if (debug)
|
||||
|
@ -130,7 +130,7 @@ net_open(struct open_file *f, ...)
|
|||
fail:
|
||||
netif_close(netdev_sock);
|
||||
netdev_sock = -1;
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
#ifdef NETIF_DEBUG
|
||||
if (debug)
|
||||
|
@ -140,12 +140,11 @@ net_open(struct open_file *f, ...)
|
|||
}
|
||||
netdev_opens++;
|
||||
f->f_devdata = nfs_root_node;
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
net_close(f)
|
||||
struct open_file *f;
|
||||
net_close(struct open_file *f)
|
||||
{
|
||||
|
||||
#ifdef NETIF_DEBUG
|
||||
|
@ -157,11 +156,11 @@ net_close(f)
|
|||
f->f_devdata = NULL;
|
||||
/* Extra close call? */
|
||||
if (netdev_opens <= 0)
|
||||
return (0);
|
||||
return 0;
|
||||
netdev_opens--;
|
||||
/* Not last close? */
|
||||
if (netdev_opens > 0)
|
||||
return(0);
|
||||
return 0;
|
||||
rootip.s_addr = 0;
|
||||
if (netdev_sock >= 0) {
|
||||
#ifdef NETIF_DEBUG
|
||||
|
@ -171,27 +170,21 @@ net_close(f)
|
|||
netif_close(netdev_sock);
|
||||
netdev_sock = -1;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
net_ioctl(f, cmd, data)
|
||||
struct open_file *f;
|
||||
u_long cmd;
|
||||
void *data;
|
||||
net_ioctl(struct open_file *f, u_long cmd, void *data)
|
||||
{
|
||||
|
||||
return EIO;
|
||||
}
|
||||
|
||||
int
|
||||
net_strategy(devdata, rw, blk, size, buf, rsize)
|
||||
void *devdata;
|
||||
int rw;
|
||||
daddr_t blk;
|
||||
size_t size;
|
||||
void *buf;
|
||||
size_t *rsize;
|
||||
net_strategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
|
||||
size_t *rsize)
|
||||
{
|
||||
|
||||
return EIO;
|
||||
}
|
||||
|
||||
|
@ -212,8 +205,7 @@ int try_bootp;
|
|||
#endif
|
||||
|
||||
static int
|
||||
net_getparams(sock)
|
||||
int sock;
|
||||
net_getparams(int sock)
|
||||
{
|
||||
char buf[MAXHOSTNAMELEN];
|
||||
n_long smask;
|
||||
|
@ -228,7 +220,7 @@ net_getparams(sock)
|
|||
if (try_bootp)
|
||||
bootp(sock);
|
||||
if (myip.s_addr != 0)
|
||||
return (0);
|
||||
return 0;
|
||||
#ifdef NETIF_DEBUG
|
||||
if (debug)
|
||||
printf("BOOTP failed, trying RARP/RPC...\n");
|
||||
|
@ -241,7 +233,7 @@ net_getparams(sock)
|
|||
*/
|
||||
if (rarp_getipaddress(sock)) {
|
||||
printf("RARP failed\n");
|
||||
return (EIO);
|
||||
return EIO;
|
||||
}
|
||||
#ifdef NETIF_DEBUG
|
||||
if (debug)
|
||||
|
@ -251,7 +243,7 @@ net_getparams(sock)
|
|||
/* Get our hostname, server IP address, gateway. */
|
||||
if (bp_whoami(sock)) {
|
||||
printf("bootparam/whoami RPC failed\n");
|
||||
return (EIO);
|
||||
return EIO;
|
||||
}
|
||||
#ifdef NETIF_DEBUG
|
||||
if (debug)
|
||||
|
@ -264,9 +256,9 @@ net_getparams(sock)
|
|||
*/
|
||||
smask = 0;
|
||||
gateip.s_addr = 0;
|
||||
if (bp_getfile(sock, "gateway", &gateip, buf))
|
||||
if (bp_getfile(sock, "gateway", &gateip, buf)) {
|
||||
printf("nfs_open: gateway bootparam missing\n");
|
||||
else {
|
||||
} else {
|
||||
/* Got it! Parse the netmask. */
|
||||
smask = inet_addr(buf);
|
||||
}
|
||||
|
@ -286,7 +278,7 @@ net_getparams(sock)
|
|||
/* Get the root server and pathname. */
|
||||
if (bp_getfile(sock, "root", &rootip, rootpath)) {
|
||||
printf("bootparam/getfile RPC failed\n");
|
||||
return (EIO);
|
||||
return EIO;
|
||||
}
|
||||
|
||||
#ifdef NETIF_DEBUG
|
||||
|
@ -296,5 +288,5 @@ net_getparams(sock)
|
|||
}
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.c,v 1.9 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.10 2007/11/24 13:20:54 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -43,10 +43,9 @@
|
|||
static char nolabel[] = "no disk label";
|
||||
static char corruptedlabel[] = "disk label corrupted";
|
||||
#endif
|
||||
|
||||
char *
|
||||
getdisklabel(buf, lp)
|
||||
const char *buf;
|
||||
struct disklabel *lp;
|
||||
getdisklabel(const char *buf, struct disklabel *lp)
|
||||
{
|
||||
const struct disklabel *dlp, *elp;
|
||||
char *msg = NULL;
|
||||
|
@ -58,9 +57,9 @@ getdisklabel(buf, lp)
|
|||
if (msg == NULL)
|
||||
msg = nolabel;
|
||||
} else if (dlp->d_npartitions > MAXPARTITIONS ||
|
||||
dkcksum(dlp) != 0)
|
||||
dkcksum(dlp) != 0) {
|
||||
msg = corruptedlabel;
|
||||
else {
|
||||
} else {
|
||||
(void)memcpy(lp, dlp, sizeof *lp);
|
||||
msg = NULL;
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dosfs.c,v 1.11 2006/12/02 00:38:22 dogcow Exp $ */
|
||||
/* $NetBSD: dosfs.c,v 1.12 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1998 Robert Nordier
|
||||
|
@ -126,7 +126,7 @@ static const struct direntry dot[2] = {
|
|||
/* Convert cluster number to offset within FAT */
|
||||
#define fatoff(sz, c) ((sz) == 12 ? (c) + ((c) >> 1) : \
|
||||
(sz) == 16 ? (c) << 1 : \
|
||||
(c) << 2)
|
||||
(c) << 2)
|
||||
|
||||
/* Does cluster number reference a valid data cluster? */
|
||||
#define okclus(fs, c) ((c) >= LOCLUS && (c) <= (fs)->xclus)
|
||||
|
@ -134,7 +134,7 @@ static const struct direntry dot[2] = {
|
|||
/* Get start cluster from directory entry */
|
||||
#define stclus(sz, de) ((sz) != 32 ? (u_int)getushort((de)->deStartCluster) : \
|
||||
((u_int)getushort((de)->deHighClust) << 16) | \
|
||||
(u_int)getushort((de)->deStartCluster))
|
||||
(u_int)getushort((de)->deStartCluster))
|
||||
|
||||
static int dosunmount(DOS_FS *);
|
||||
static int parsebs(DOS_FS *, DOS_BS *);
|
||||
|
@ -154,7 +154,7 @@ static int ioget(struct open_file *, u_int, void *, u_int);
|
|||
* Mount DOS filesystem
|
||||
*/
|
||||
static int
|
||||
dos_mount(DOS_FS * fs, struct open_file * fd)
|
||||
dos_mount(DOS_FS *fs, struct open_file *fd)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -162,9 +162,9 @@ dos_mount(DOS_FS * fs, struct open_file * fd)
|
|||
fs->fd = fd;
|
||||
if ((err = !(fs->buf = alloc(SECSIZ)) ? errno : 0) ||
|
||||
(err = ioget(fs->fd, 0, fs->buf, 1)) ||
|
||||
(err = parsebs(fs, (DOS_BS *) fs->buf))) {
|
||||
(err = parsebs(fs, (DOS_BS *)fs->buf))) {
|
||||
(void) dosunmount(fs);
|
||||
return (err);
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -174,14 +174,14 @@ dos_mount(DOS_FS * fs, struct open_file * fd)
|
|||
* Unmount mounted filesystem
|
||||
*/
|
||||
static int
|
||||
dos_unmount(DOS_FS * fs)
|
||||
dos_unmount(DOS_FS *fs)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (fs->links)
|
||||
return (EBUSY);
|
||||
return EBUSY;
|
||||
if ((err = dosunmount(fs)))
|
||||
return (err);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -190,12 +190,12 @@ dos_unmount(DOS_FS * fs)
|
|||
* Common code shared by dos_mount() and dos_unmount()
|
||||
*/
|
||||
static int
|
||||
dosunmount(DOS_FS * fs)
|
||||
dosunmount(DOS_FS *fs)
|
||||
{
|
||||
if (fs->buf)
|
||||
dealloc(fs->buf, SECSIZ);
|
||||
dealloc(fs, sizeof(DOS_FS));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -243,22 +243,22 @@ dosfs_open(const char *path, struct open_file *fd)
|
|||
f->fs = fs;
|
||||
fs->links++;
|
||||
f->de = *de;
|
||||
fd->f_fsdata = (void *) f;
|
||||
fd->f_fsdata = (void *)f;
|
||||
|
||||
out:
|
||||
return (err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read from file
|
||||
*/
|
||||
int
|
||||
dosfs_read(struct open_file * fd, void *vbuf, size_t nbyte, size_t * resid)
|
||||
dosfs_read(struct open_file *fd, void *vbuf, size_t nbyte, size_t *resid)
|
||||
{
|
||||
off_t size;
|
||||
u_int8_t *buf = vbuf;
|
||||
u_int nb, off, clus, c, cnt, n;
|
||||
DOS_FILE *f = (DOS_FILE *) fd->f_fsdata;
|
||||
DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
|
||||
int err = 0;
|
||||
|
||||
nb = (u_int) nbyte;
|
||||
|
@ -276,8 +276,9 @@ dosfs_read(struct open_file * fd, void *vbuf, size_t nbyte, size_t * resid)
|
|||
if (!c) {
|
||||
if ((c = clus))
|
||||
n = bytblk(f->fs, f->offset);
|
||||
} else if (!off)
|
||||
} else if (!off) {
|
||||
n++;
|
||||
}
|
||||
while (n--) {
|
||||
if ((err = fatget(f->fs, &c)))
|
||||
goto out;
|
||||
|
@ -301,7 +302,7 @@ dosfs_read(struct open_file * fd, void *vbuf, size_t nbyte, size_t * resid)
|
|||
out:
|
||||
if (resid)
|
||||
*resid = nbyte - nb + cnt;
|
||||
return (err);
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifndef LIBSA_NO_FS_WRITE
|
||||
|
@ -312,7 +313,7 @@ int
|
|||
dosfs_write(struct open_file *fd, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
|
||||
return (EROFS);
|
||||
return EROFS;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_WRITE */
|
||||
|
||||
|
@ -321,11 +322,11 @@ dosfs_write(struct open_file *fd, void *start, size_t size, size_t *resid)
|
|||
* Reposition within file
|
||||
*/
|
||||
off_t
|
||||
dosfs_seek(struct open_file * fd, off_t offset, int whence)
|
||||
dosfs_seek(struct open_file *fd, off_t offset, int whence)
|
||||
{
|
||||
off_t off;
|
||||
u_int size;
|
||||
DOS_FILE *f = (DOS_FILE *) fd->f_fsdata;
|
||||
DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
|
||||
|
||||
size = getulong(f->de.deFileSize);
|
||||
switch (whence) {
|
||||
|
@ -339,14 +340,14 @@ dosfs_seek(struct open_file * fd, off_t offset, int whence)
|
|||
off = size;
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
off += offset;
|
||||
if (off < 0 || off > size)
|
||||
return (-1);
|
||||
return -1;
|
||||
f->offset = (u_int) off;
|
||||
f->c = 0;
|
||||
return (off);
|
||||
return off;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_SEEK */
|
||||
|
||||
|
@ -355,9 +356,9 @@ dosfs_seek(struct open_file * fd, off_t offset, int whence)
|
|||
* Close open file
|
||||
*/
|
||||
int
|
||||
dosfs_close(struct open_file * fd)
|
||||
dosfs_close(struct open_file *fd)
|
||||
{
|
||||
DOS_FILE *f = (DOS_FILE *) fd->f_fsdata;
|
||||
DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
|
||||
DOS_FS *fs = f->fs;
|
||||
|
||||
f->fs->links--;
|
||||
|
@ -371,9 +372,9 @@ dosfs_close(struct open_file * fd)
|
|||
* Return some stat information on a file.
|
||||
*/
|
||||
int
|
||||
dosfs_stat(struct open_file * fd, struct stat * sb)
|
||||
dosfs_stat(struct open_file *fd, struct stat *sb)
|
||||
{
|
||||
DOS_FILE *f = (DOS_FILE *) fd->f_fsdata;
|
||||
DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
|
||||
|
||||
/* only important stuff */
|
||||
sb->st_mode = (f->de.deAttributes & ATTR_DIRECTORY) ?
|
||||
|
@ -383,14 +384,14 @@ dosfs_stat(struct open_file * fd, struct stat * sb)
|
|||
sb->st_gid = 0;
|
||||
if ((sb->st_size = fsize(f->fs, &f->de)) == -1)
|
||||
return EINVAL;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse DOS boot sector
|
||||
*/
|
||||
static int
|
||||
parsebs(DOS_FS * fs, DOS_BS * bs)
|
||||
parsebs(DOS_FS *fs, DOS_BS *bs)
|
||||
{
|
||||
u_int sc;
|
||||
|
||||
|
@ -440,7 +441,7 @@ parsebs(DOS_FS * fs, DOS_BS * bs)
|
|||
* Return directory entry from path
|
||||
*/
|
||||
static int
|
||||
namede(DOS_FS * fs, const char *path, const struct direntry ** dep)
|
||||
namede(DOS_FS *fs, const char *path, const struct direntry **dep)
|
||||
{
|
||||
char name[256];
|
||||
const struct direntry *de;
|
||||
|
@ -475,7 +476,7 @@ namede(DOS_FS * fs, const char *path, const struct direntry ** dep)
|
|||
* Lookup path segment
|
||||
*/
|
||||
static int
|
||||
lookup(DOS_FS * fs, u_int clus, const char *name, const struct direntry ** dep)
|
||||
lookup(DOS_FS *fs, u_int clus, const char *name, const struct direntry **dep)
|
||||
{
|
||||
static DOS_DIR *dir = NULL;
|
||||
u_char lfn[261];
|
||||
|
@ -493,7 +494,7 @@ lookup(DOS_FS * fs, u_int clus, const char *name, const struct direntry ** dep)
|
|||
if (dir == NULL) {
|
||||
dir = alloc(sizeof(DOS_DIR) * DEPSEC);
|
||||
if (dir == NULL)
|
||||
return (ENOMEM);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (!clus && fs->fatsz == 32)
|
||||
|
@ -544,11 +545,11 @@ lookup(DOS_FS * fs, u_int clus, const char *name, const struct direntry ** dep)
|
|||
x = ((((x & 1) << 7) | (x >> 1)) +
|
||||
dir[ent].de.deName[i]) & 0xff;
|
||||
ok = chk == x &&
|
||||
!strcasecmp(name, (const char *) lfn);
|
||||
!strcasecmp(name, (const char *)lfn);
|
||||
}
|
||||
if (!ok) {
|
||||
cp_sfn(sfn, &dir[ent].de);
|
||||
ok = !strcasecmp(name, (const char *) sfn);
|
||||
ok = !strcasecmp(name, (const char *)sfn);
|
||||
}
|
||||
if (ok) {
|
||||
*dep = &dir[ent].de;
|
||||
|
@ -571,14 +572,14 @@ lookup(DOS_FS * fs, u_int clus, const char *name, const struct direntry ** dep)
|
|||
dealloc(dir, sizeof(DOS_DIR) * DEPSEC);
|
||||
dir = NULL;
|
||||
out2:
|
||||
return (err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy name from extended directory entry
|
||||
*/
|
||||
static void
|
||||
cp_xdnm(u_char * lfn, struct winentry * xde)
|
||||
cp_xdnm(u_char *lfn, struct winentry *xde)
|
||||
{
|
||||
static const struct {
|
||||
u_int off;
|
||||
|
@ -596,7 +597,7 @@ cp_xdnm(u_char * lfn, struct winentry * xde)
|
|||
|
||||
lfn += 13 * ((xde->weCnt & WIN_CNT) - 1);
|
||||
for (n = 0; n < 3; n++)
|
||||
for (p = (u_char *) xde + ix[n].off, x = ix[n].dim; x;
|
||||
for (p = (u_char *)xde + ix[n].off, x = ix[n].dim; x;
|
||||
p += 2, x--) {
|
||||
if ((c = getushort(p)) && (c < 32 || c > 127))
|
||||
c = '?';
|
||||
|
@ -611,7 +612,7 @@ cp_xdnm(u_char * lfn, struct winentry * xde)
|
|||
* Copy short filename
|
||||
*/
|
||||
static void
|
||||
cp_sfn(u_char * sfn, struct direntry * de)
|
||||
cp_sfn(u_char *sfn, struct direntry *de)
|
||||
{
|
||||
u_char *p;
|
||||
int j, i;
|
||||
|
@ -637,7 +638,7 @@ cp_sfn(u_char * sfn, struct direntry * de)
|
|||
* Return size of file in bytes
|
||||
*/
|
||||
static off_t
|
||||
fsize(DOS_FS * fs, struct direntry * de)
|
||||
fsize(DOS_FS *fs, struct direntry *de)
|
||||
{
|
||||
u_long size;
|
||||
u_int c;
|
||||
|
@ -645,9 +646,9 @@ fsize(DOS_FS * fs, struct direntry * de)
|
|||
|
||||
if (!(size = getulong(de->deFileSize)) &&
|
||||
de->deAttributes & ATTR_DIRECTORY) {
|
||||
if (!(c = getushort(de->deStartCluster)))
|
||||
if (!(c = getushort(de->deStartCluster))) {
|
||||
size = fs->dirents * sizeof(struct direntry);
|
||||
else {
|
||||
} else {
|
||||
if ((n = fatcnt(fs, c)) == -1)
|
||||
return n;
|
||||
size = blkbyt(fs, n);
|
||||
|
@ -660,7 +661,7 @@ fsize(DOS_FS * fs, struct direntry * de)
|
|||
* Count number of clusters in chain
|
||||
*/
|
||||
static int
|
||||
fatcnt(DOS_FS * fs, u_int c)
|
||||
fatcnt(DOS_FS *fs, u_int c)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
@ -674,7 +675,7 @@ fatcnt(DOS_FS * fs, u_int c)
|
|||
* Get next cluster in cluster chain
|
||||
*/
|
||||
static int
|
||||
fatget(DOS_FS * fs, u_int * c)
|
||||
fatget(DOS_FS *fs, u_int *c)
|
||||
{
|
||||
u_char buf[4];
|
||||
u_int x;
|
||||
|
@ -702,7 +703,7 @@ fatend(u_int sz, u_int c)
|
|||
* Offset-based I/O primitive
|
||||
*/
|
||||
static int
|
||||
ioread(DOS_FS * fs, u_int offset, void *buf, u_int nbyte)
|
||||
ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte)
|
||||
{
|
||||
char *s;
|
||||
u_int off, n;
|
||||
|
@ -739,7 +740,7 @@ ioread(DOS_FS * fs, u_int offset, void *buf, u_int nbyte)
|
|||
* Buffered sector-based I/O primitive
|
||||
*/
|
||||
static int
|
||||
iobuf(DOS_FS * fs, u_int lsec)
|
||||
iobuf(DOS_FS *fs, u_int lsec)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -755,7 +756,7 @@ iobuf(DOS_FS * fs, u_int lsec)
|
|||
* Sector-based I/O primitive
|
||||
*/
|
||||
static int
|
||||
ioget(struct open_file * fd, u_int lsec, void *buf, u_int nsec)
|
||||
ioget(struct open_file *fd, u_int lsec, void *buf, u_int nsec)
|
||||
{
|
||||
size_t rsize;
|
||||
int err;
|
||||
|
@ -765,5 +766,5 @@ ioget(struct open_file * fd, u_int lsec, void *buf, u_int nsec)
|
|||
#endif
|
||||
err = DEV_STRATEGY(fd->f_dev)(fd->f_devdata, F_READ, lsec,
|
||||
secbyt(nsec), buf, &rsize);
|
||||
return (err);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ether.c,v 1.20 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: ether.c,v 1.21 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -58,12 +58,7 @@
|
|||
|
||||
/* Caller must leave room for ethernet header in front!! */
|
||||
ssize_t
|
||||
sendether(d, pkt, len, dea, etype)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
u_char *dea;
|
||||
int etype;
|
||||
sendether(struct iodesc *d, void *pkt, size_t len, u_char *dea, int etype)
|
||||
{
|
||||
ssize_t n;
|
||||
struct ether_header *eh;
|
||||
|
@ -82,10 +77,10 @@ sendether(d, pkt, len, dea, etype)
|
|||
|
||||
n = netif_put(d, eh, len);
|
||||
if (n == -1 || (size_t)n < sizeof(*eh))
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
n -= sizeof(*eh);
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -94,12 +89,8 @@ sendether(d, pkt, len, dea, etype)
|
|||
* NOTE: Caller must leave room for the Ether header.
|
||||
*/
|
||||
ssize_t
|
||||
readether(d, pkt, len, tleft, etype)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
u_int16_t *etype;
|
||||
readether(struct iodesc *d, void *pkt, size_t len, time_t tleft,
|
||||
u_int16_t *etype)
|
||||
{
|
||||
ssize_t n;
|
||||
struct ether_header *eh;
|
||||
|
@ -114,7 +105,7 @@ readether(d, pkt, len, tleft, etype)
|
|||
|
||||
n = netif_get(d, eh, len, tleft);
|
||||
if (n == -1 || (size_t)n < sizeof(*eh))
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
/* Validate Ethernet address. */
|
||||
if (memcmp(d->myea, eh->ether_dhost, 6) != 0 &&
|
||||
|
@ -124,10 +115,10 @@ readether(d, pkt, len, tleft, etype)
|
|||
printf("readether: not ours (ea=%s)\n",
|
||||
ether_sprintf(eh->ether_dhost));
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
*etype = ntohs(eh->ether_type);
|
||||
|
||||
n -= sizeof(*eh);
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ether_sprintf.c,v 1.5 2006/01/24 17:07:19 christos Exp $ */
|
||||
/* $NetBSD: ether_sprintf.c,v 1.6 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -69,5 +69,5 @@ ether_sprintf(const u_char *ap)
|
|||
*cp++ = ':';
|
||||
}
|
||||
*--cp = 0;
|
||||
return (etherbuf);
|
||||
return etherbuf;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec.c,v 1.24 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: exec.c,v 1.25 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
|
@ -48,10 +48,7 @@
|
|||
#include "stand.h"
|
||||
|
||||
void
|
||||
exec(path, loadaddr, howto)
|
||||
char *path;
|
||||
char *loadaddr;
|
||||
int howto;
|
||||
exec(char *path, char *loadaddr, int howto)
|
||||
{
|
||||
#ifndef INSECURE
|
||||
struct stat sb;
|
||||
|
@ -80,7 +77,7 @@ exec(path, loadaddr, howto)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Text */
|
||||
/* Text */
|
||||
printf("%ld", x.a_text);
|
||||
addr = loadaddr;
|
||||
if (N_GETMAGIC(x) == ZMAGIC) {
|
||||
|
@ -95,18 +92,18 @@ exec(path, loadaddr, howto)
|
|||
while ((long)addr & (N_PAGSIZ(x) - 1))
|
||||
*addr++ = 0;
|
||||
|
||||
/* Data */
|
||||
/* Data */
|
||||
printf("+%ld", x.a_data);
|
||||
if (read(io, addr, x.a_data) != (ssize_t)x.a_data)
|
||||
goto shread;
|
||||
addr += x.a_data;
|
||||
|
||||
/* Bss */
|
||||
/* Bss */
|
||||
printf("+%ld", x.a_bss);
|
||||
for (i = 0; i < (int)x.a_bss; i++)
|
||||
*addr++ = 0;
|
||||
|
||||
/* Symbols */
|
||||
/* Symbols */
|
||||
ssym = addr;
|
||||
bcopy(&x.a_syms, addr, sizeof(x.a_syms));
|
||||
addr += sizeof(x.a_syms);
|
||||
|
@ -126,7 +123,7 @@ exec(path, loadaddr, howto)
|
|||
i -= sizeof(int);
|
||||
addr += sizeof(int);
|
||||
if (read(io, addr, i) != i)
|
||||
goto shread;
|
||||
goto shread;
|
||||
addr += i;
|
||||
}
|
||||
|
||||
|
@ -139,7 +136,7 @@ exec(path, loadaddr, howto)
|
|||
|
||||
#define round_to_size(x) \
|
||||
(((int)(x) + sizeof(int) - 1) & ~(sizeof(int) - 1))
|
||||
esym = (char *)round_to_size(addr - loadaddr);
|
||||
esym = (char *)round_to_size(addr - loadaddr);
|
||||
#undef round_to_size
|
||||
|
||||
/* and note the end address of all this */
|
||||
|
@ -154,9 +151,9 @@ exec(path, loadaddr, howto)
|
|||
*/
|
||||
|
||||
#ifdef EXEC_DEBUG
|
||||
printf("ssym=0x%x esym=0x%x\n", ssym, esym);
|
||||
printf("\n\nReturn to boot...\n");
|
||||
getchar();
|
||||
printf("ssym=0x%x esym=0x%x\n", ssym, esym);
|
||||
printf("\n\nReturn to boot...\n");
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
machdep_start((char *)x.a_entry, howto, loadaddr, ssym, esym);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exit.c,v 1.16 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: exit.c,v 1.17 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -31,9 +31,8 @@
|
|||
#include "stand.h"
|
||||
|
||||
void
|
||||
exit(arg)
|
||||
int arg;
|
||||
exit(int arg)
|
||||
{
|
||||
panic("exit");
|
||||
/*NOTREACHED*/
|
||||
panic("exit");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fstat.c,v 1.5 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: fstat.c,v 1.6 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -34,16 +34,14 @@
|
|||
#include "stand.h"
|
||||
|
||||
int
|
||||
fstat(fd, sb)
|
||||
int fd;
|
||||
struct stat *sb;
|
||||
fstat(int fd, struct stat *sb)
|
||||
{
|
||||
struct open_file *f = &files[fd];
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -51,10 +49,10 @@ fstat(fd, sb)
|
|||
/* operation not defined on raw devices */
|
||||
if (f->f_flags & F_RAW) {
|
||||
errno = EOPNOTSUPP;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
errno = FS_STAT(f->f_ops)(f, sb); /* XXX no point setting errno */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getfile.c,v 1.8 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: getfile.c,v 1.9 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -32,12 +32,10 @@
|
|||
*/
|
||||
#include "stand.h"
|
||||
|
||||
#define CTRL(x) (x&037)
|
||||
#define CTRL(x) ((x) & 037)
|
||||
|
||||
int
|
||||
getfile(prompt, mode)
|
||||
char *prompt;
|
||||
int mode;
|
||||
getfile(char *prompt, int mode)
|
||||
{
|
||||
int fd;
|
||||
char buf[100];
|
||||
|
@ -46,8 +44,8 @@ getfile(prompt, mode)
|
|||
printf("%s: ", prompt);
|
||||
gets(buf);
|
||||
if (buf[0] == CTRL('d') && buf[1] == 0)
|
||||
return (-1);
|
||||
return -1;
|
||||
} while ((fd = open(buf, mode)) < 0);
|
||||
|
||||
return (fd);
|
||||
return fd;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: gets.c,v 1.9 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: gets.c,v 1.10 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -34,13 +34,12 @@
|
|||
#include "stand.h"
|
||||
|
||||
void
|
||||
gets(buf)
|
||||
char *buf;
|
||||
gets(char *buf)
|
||||
{
|
||||
int c;
|
||||
char *lp;
|
||||
|
||||
for (lp = buf;;)
|
||||
for (lp = buf;;) {
|
||||
switch (c = getchar() & 0177) {
|
||||
case '\n':
|
||||
case '\r':
|
||||
|
@ -62,7 +61,7 @@ gets(buf)
|
|||
--lp;
|
||||
break;
|
||||
#endif
|
||||
case 'r'&037: {
|
||||
case 'r' & 037: {
|
||||
char *p;
|
||||
|
||||
putchar('\n');
|
||||
|
@ -73,14 +72,16 @@ gets(buf)
|
|||
#if AT_ERASE
|
||||
case '@':
|
||||
#endif
|
||||
case 'u'&037:
|
||||
case 'w'&037:
|
||||
case 'u' & 037:
|
||||
case 'w' & 037:
|
||||
lp = buf;
|
||||
putchar('\n');
|
||||
break;
|
||||
default:
|
||||
*lp++ = c;
|
||||
putchar(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ioctl.c,v 1.9 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: ioctl.c,v 1.10 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -63,10 +63,7 @@
|
|||
#include "stand.h"
|
||||
|
||||
int
|
||||
ioctl(fd, cmd, arg)
|
||||
int fd;
|
||||
u_long cmd;
|
||||
char *arg;
|
||||
ioctl(int fd, u_long cmd, char *arg)
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING) || !defined(LIBSA_NO_RAW_ACCESS)
|
||||
struct open_file *f = &files[fd];
|
||||
|
@ -75,17 +72,17 @@ ioctl(fd, cmd, arg)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (f->f_flags & F_RAW) {
|
||||
errno = DEV_IOCTL(f->f_dev)(f, cmd, arg);
|
||||
if (errno)
|
||||
return (-1);
|
||||
return (0);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
errno = EIO;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: loadfile.c,v 1.25 2006/12/09 22:11:36 chs Exp $ */
|
||||
/* $NetBSD: loadfile.c,v 1.26 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -105,17 +105,17 @@ loadfile(fname, marks, flags)
|
|||
/* Open the file. */
|
||||
if ((fd = open(fname, 0)) < 0) {
|
||||
WARN(("open %s", fname ? fname : "<default>"));
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load it; save the value of errno across the close() call */
|
||||
if ((error = fdloadfile(fd, marks, flags)) != 0) {
|
||||
(void)close(fd);
|
||||
errno = error;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (fd);
|
||||
return fd;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -195,8 +195,8 @@ fdloadfile(fd, marks, flags)
|
|||
if ((flags & LOAD_ALL) != 0)
|
||||
PROGRESS(("=0x%lx\n",
|
||||
marks[MARK_END] - marks[MARK_START]));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
err:
|
||||
return (errno);
|
||||
return errno;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lseek.c,v 1.9 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: lseek.c,v 1.10 2007/11/24 13:20:55 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -64,20 +64,17 @@
|
|||
|
||||
off_t
|
||||
#ifndef __INTERNAL_LIBSA_CREAD
|
||||
lseek(fd, offset, where)
|
||||
lseek(int fd, off_t offset, int where)
|
||||
#else
|
||||
olseek(fd, offset, where)
|
||||
olseek(int fd, off_t offset, int where)
|
||||
#endif
|
||||
int fd;
|
||||
off_t offset;
|
||||
int where;
|
||||
{
|
||||
struct open_file *f = &files[fd];
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -96,9 +93,9 @@ olseek(fd, offset, where)
|
|||
case SEEK_END:
|
||||
default:
|
||||
errno = EOFFSET;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
return (f->f_offset);
|
||||
return f->f_offset;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memcmp.c,v 1.10 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: memcmp.c,v 1.11 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -54,9 +54,7 @@ __strong_alias(bcmp, memcmp);
|
|||
* Conformant memcmp()
|
||||
*/
|
||||
int
|
||||
memcmp(b1, b2, len)
|
||||
const void *b1, *b2;
|
||||
size_t len;
|
||||
memcmp(const void *b1, const void *b2, size_t len)
|
||||
{
|
||||
const unsigned char *c1 = b1, *c2 = b2;
|
||||
int diff;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memcpy.c,v 1.6 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: memcpy.c,v 1.7 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -38,15 +38,12 @@
|
|||
* This is designed to be small, not fast.
|
||||
*/
|
||||
void *
|
||||
memcpy(s1, s2, n)
|
||||
void *s1;
|
||||
const void *s2;
|
||||
size_t n;
|
||||
memcpy(void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const char *f = s2;
|
||||
char *t = s1;
|
||||
|
||||
while (n-- > 0)
|
||||
*t++ = *f++;
|
||||
return (s1);
|
||||
return s1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memmove.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: memmove.c,v 1.4 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -38,10 +38,7 @@
|
|||
* This is designed to be small, not fast.
|
||||
*/
|
||||
void *
|
||||
memmove(s1, s2, n)
|
||||
void *s1;
|
||||
const void *s2;
|
||||
size_t n;
|
||||
memmove(void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const char *f = s2;
|
||||
char *t = s1;
|
||||
|
@ -51,8 +48,9 @@ memmove(s1, s2, n)
|
|||
t += n;
|
||||
while (n-- > 0)
|
||||
*--t = *--f;
|
||||
} else
|
||||
} else {
|
||||
while (n-- > 0)
|
||||
*t++ = *f++;
|
||||
return (s1);
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memset.c,v 1.3 1999/11/13 21:17:57 thorpej Exp $ */
|
||||
/* $NetBSD: memset.c,v 1.4 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -34,10 +34,7 @@
|
|||
#include <lib/libkern/libkern.h>
|
||||
|
||||
void *
|
||||
memset(dstv, c, length)
|
||||
void *dstv;
|
||||
int c;
|
||||
size_t length;
|
||||
memset(void *dstv, int c, size_t length)
|
||||
{
|
||||
u_char *dst = dstv;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: net.c,v 1.30 2006/01/21 10:06:06 dsl Exp $ */
|
||||
/* $NetBSD: net.c,v 1.31 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -81,14 +81,11 @@
|
|||
* zero errno to indicate it isn't done yet.
|
||||
*/
|
||||
ssize_t
|
||||
sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
|
||||
struct iodesc *d;
|
||||
ssize_t (*sproc)(struct iodesc *, void *, size_t);
|
||||
void *sbuf;
|
||||
size_t ssize;
|
||||
ssize_t (*rproc)(struct iodesc *, void *, size_t, time_t);
|
||||
void *rbuf;
|
||||
size_t rsize;
|
||||
sendrecv(struct iodesc *d,
|
||||
ssize_t (*sproc)(struct iodesc *, void *, size_t),
|
||||
void *sbuf, size_t ssize,
|
||||
ssize_t (*rproc)(struct iodesc *, void *, size_t, time_t),
|
||||
void *rbuf, size_t rsize)
|
||||
{
|
||||
ssize_t cc;
|
||||
time_t t, tmo, tlast;
|
||||
|
@ -133,7 +130,7 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
|
|||
cc = (*rproc)(d, rbuf, rsize, tleft);
|
||||
/* Return on data, EOF or real error. */
|
||||
if (cc != -1 || errno != 0)
|
||||
return (cc);
|
||||
return cc;
|
||||
|
||||
/* Timed out or didn't get the packet we're waiting for */
|
||||
t = getsecs();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: net.h,v 1.19 2006/01/24 17:07:19 christos Exp $ */
|
||||
/* $NetBSD: net.h,v 1.20 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Adam Glass
|
||||
|
@ -92,17 +92,15 @@ void arp_reply __P((struct iodesc *, void *));
|
|||
int rarp_getipaddress __P((int));
|
||||
|
||||
/* Link functions: */
|
||||
ssize_t sendether __P((struct iodesc *d, void *pkt, size_t len,
|
||||
u_char *dea, int etype));
|
||||
ssize_t readether __P((struct iodesc *d, void *pkt, size_t len,
|
||||
time_t tleft, u_int16_t *etype));
|
||||
ssize_t sendether __P((struct iodesc *, void *, size_t, u_char *, int));
|
||||
ssize_t readether __P((struct iodesc *, void *, size_t, time_t, u_int16_t *));
|
||||
|
||||
ssize_t sendudp __P((struct iodesc *, void *, size_t));
|
||||
ssize_t readudp __P((struct iodesc *, void *, size_t, time_t));
|
||||
ssize_t sendrecv __P((struct iodesc *,
|
||||
ssize_t (*)(struct iodesc *, void *, size_t),
|
||||
ssize_t (*)(struct iodesc *, void *, size_t),
|
||||
void *, size_t,
|
||||
ssize_t (*)(struct iodesc *, void *, size_t, time_t),
|
||||
ssize_t (*)(struct iodesc *, void *, size_t, time_t),
|
||||
void *, size_t));
|
||||
|
||||
/* Utilities: */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: netif.c,v 1.20 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: netif.c,v 1.21 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Adam Glass
|
||||
|
@ -58,7 +58,7 @@ int netif_debug = 0;
|
|||
*/
|
||||
|
||||
void
|
||||
netif_init()
|
||||
netif_init(void)
|
||||
{
|
||||
struct netif_driver *drv;
|
||||
int d, i;
|
||||
|
@ -77,9 +77,7 @@ netif_init()
|
|||
int netif_match __P((struct netif *, void *));
|
||||
|
||||
int
|
||||
netif_match(nif, machdep_hint)
|
||||
struct netif *nif;
|
||||
void *machdep_hint;
|
||||
netif_match(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
||||
|
@ -92,8 +90,7 @@ netif_match(nif, machdep_hint)
|
|||
}
|
||||
|
||||
struct netif *
|
||||
netif_select(machdep_hint)
|
||||
void *machdep_hint;
|
||||
netif_select(void *machdep_hint)
|
||||
{
|
||||
int d, u, unit_done, s;
|
||||
struct netif_driver *drv;
|
||||
|
@ -168,9 +165,7 @@ netif_select(machdep_hint)
|
|||
}
|
||||
|
||||
int
|
||||
netif_probe(nif, machdep_hint)
|
||||
struct netif *nif;
|
||||
void *machdep_hint;
|
||||
netif_probe(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
||||
|
@ -182,10 +177,7 @@ netif_probe(nif, machdep_hint)
|
|||
}
|
||||
|
||||
void
|
||||
netif_attach(nif, desc, machdep_hint)
|
||||
struct netif *nif;
|
||||
struct iodesc *desc;
|
||||
void *machdep_hint;
|
||||
netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint)
|
||||
{
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
||||
|
@ -205,8 +197,7 @@ netif_attach(nif, desc, machdep_hint)
|
|||
}
|
||||
|
||||
void
|
||||
netif_detach(nif)
|
||||
struct netif *nif;
|
||||
netif_detach(struct netif *nif)
|
||||
{
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
||||
|
@ -223,11 +214,7 @@ netif_detach(nif)
|
|||
}
|
||||
|
||||
ssize_t
|
||||
netif_get(desc, pkt, len, timo)
|
||||
struct iodesc *desc;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t timo;
|
||||
netif_get(struct iodesc *desc, void *pkt, size_t len, time_t timo)
|
||||
{
|
||||
struct netif *nif = desc->io_netif;
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
@ -252,10 +239,7 @@ netif_get(desc, pkt, len, timo)
|
|||
}
|
||||
|
||||
ssize_t
|
||||
netif_put(desc, pkt, len)
|
||||
struct iodesc *desc;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
netif_put(struct iodesc *desc, void *pkt, size_t len)
|
||||
{
|
||||
struct netif *nif = desc->io_netif;
|
||||
struct netif_driver *drv = nif->nif_driver;
|
||||
|
@ -280,21 +264,19 @@ netif_put(desc, pkt, len)
|
|||
}
|
||||
|
||||
struct iodesc *
|
||||
socktodesc(sock)
|
||||
int sock;
|
||||
socktodesc(int sock)
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if (sock >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return (&sockets[sock]);
|
||||
return &sockets[sock];
|
||||
}
|
||||
|
||||
int
|
||||
netif_open(machdep_hint)
|
||||
void *machdep_hint;
|
||||
netif_open(void *machdep_hint)
|
||||
{
|
||||
int fd;
|
||||
struct iodesc *s;
|
||||
|
@ -305,7 +287,7 @@ netif_open(machdep_hint)
|
|||
if (s->io_netif == (struct netif *)0)
|
||||
goto fnd;
|
||||
errno = EMFILE;
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
fnd:
|
||||
bzero(s, sizeof(*s));
|
||||
|
@ -317,25 +299,24 @@ fnd:
|
|||
printf("netboot: couldn't probe %s%d\n",
|
||||
nif->nif_driver->netif_bname, nif->nif_unit);
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
netif_attach(nif, s, machdep_hint);
|
||||
|
||||
return(fd);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int
|
||||
netif_close(sock)
|
||||
int sock;
|
||||
netif_close(int sock)
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if (sock >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
netif_detach(sockets[sock].io_netif);
|
||||
sockets[sock].io_netif = (struct netif *)0;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfs.c,v 1.41 2007/02/25 04:46:32 uwe Exp $ */
|
||||
/* $NetBSD: nfs.c,v 1.42 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -122,10 +122,7 @@ ssize_t nfs_readdata __P((struct nfs_iodesc *, off_t, void *, size_t));
|
|||
* On error, return non-zero and set errno.
|
||||
*/
|
||||
int
|
||||
nfs_getrootfh(d, path, fhp)
|
||||
struct iodesc *d;
|
||||
char *path;
|
||||
u_char *fhp;
|
||||
nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
|
||||
{
|
||||
int len;
|
||||
struct args {
|
||||
|
@ -166,18 +163,18 @@ nfs_getrootfh(d, path, fhp)
|
|||
args, len, repl, sizeof(*repl));
|
||||
if (cc == -1) {
|
||||
/* errno was set by rpc_call */
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (cc < 4) {
|
||||
errno = EBADRPC;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (repl->errno) {
|
||||
errno = ntohl(repl->errno);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
bcopy(repl->fh, fhp, sizeof(repl->fh));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -185,11 +182,8 @@ nfs_getrootfh(d, path, fhp)
|
|||
* Return zero or error number.
|
||||
*/
|
||||
int
|
||||
nfs_lookupfh(d, name, len, newfd)
|
||||
struct nfs_iodesc *d;
|
||||
const char *name;
|
||||
int len;
|
||||
struct nfs_iodesc *newfd;
|
||||
nfs_lookupfh(struct nfs_iodesc *d, const char *name, int len,
|
||||
struct nfs_iodesc *newfd)
|
||||
{
|
||||
int rlen;
|
||||
struct args {
|
||||
|
@ -234,16 +228,16 @@ nfs_lookupfh(d, name, len, newfd)
|
|||
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP,
|
||||
args, len, repl, rlen);
|
||||
if (cc == -1)
|
||||
return (errno); /* XXX - from rpc_call */
|
||||
return errno; /* XXX - from rpc_call */
|
||||
if (cc < 4)
|
||||
return (EIO);
|
||||
return EIO;
|
||||
if (repl->errno) {
|
||||
/* saerrno.h now matches NFS error numbers. */
|
||||
return (ntohl(repl->errno));
|
||||
return ntohl(repl->errno);
|
||||
}
|
||||
bcopy( repl->fh, &newfd->fh, sizeof(newfd->fh));
|
||||
bcopy(&repl->fa, &newfd->fa, sizeof(newfd->fa));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NFS_NOSYMLINK
|
||||
|
@ -251,9 +245,7 @@ nfs_lookupfh(d, name, len, newfd)
|
|||
* Get the destination of a symbolic link.
|
||||
*/
|
||||
int
|
||||
nfs_readlink(d, buf)
|
||||
struct nfs_iodesc *d;
|
||||
char *buf;
|
||||
nfs_readlink(struct nfs_iodesc *d, char *buf)
|
||||
{
|
||||
struct {
|
||||
n_long h[RPC_HEADER_WORDS];
|
||||
|
@ -272,24 +264,24 @@ nfs_readlink(d, buf)
|
|||
|
||||
bcopy(d->fh, sdata.fh, NFS_FHSIZE);
|
||||
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK,
|
||||
sdata.fh, NFS_FHSIZE,
|
||||
&rdata.d, sizeof(rdata.d));
|
||||
sdata.fh, NFS_FHSIZE,
|
||||
&rdata.d, sizeof(rdata.d));
|
||||
if (cc == -1)
|
||||
return (errno);
|
||||
return errno;
|
||||
|
||||
if (cc < 4)
|
||||
return (EIO);
|
||||
return EIO;
|
||||
|
||||
if (rdata.d.errno)
|
||||
return (ntohl(rdata.d.errno));
|
||||
return ntohl(rdata.d.errno);
|
||||
|
||||
rdata.d.len = ntohl(rdata.d.len);
|
||||
if (rdata.d.len > NFS_MAXPATHLEN)
|
||||
return (ENAMETOOLONG);
|
||||
return ENAMETOOLONG;
|
||||
|
||||
bcopy(rdata.d.path, buf, rdata.d.len);
|
||||
buf[rdata.d.len] = 0;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -298,11 +290,7 @@ nfs_readlink(d, buf)
|
|||
* Return transfer count or -1 (and set errno)
|
||||
*/
|
||||
ssize_t
|
||||
nfs_readdata(d, off, addr, len)
|
||||
struct nfs_iodesc *d;
|
||||
off_t off;
|
||||
void *addr;
|
||||
size_t len;
|
||||
nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
|
||||
{
|
||||
struct nfs_read_args *args;
|
||||
struct nfs_read_repl *repl;
|
||||
|
@ -334,25 +322,25 @@ nfs_readdata(d, off, addr, len)
|
|||
repl, sizeof(*repl));
|
||||
if (cc == -1) {
|
||||
/* errno was already set by rpc_call */
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (cc < (ssize_t)hlen) {
|
||||
errno = EBADRPC;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (repl->errno) {
|
||||
errno = ntohl(repl->errno);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
rlen = cc - hlen;
|
||||
x = ntohl(repl->count);
|
||||
if (rlen < (size_t)x) {
|
||||
printf("nfsread: short packet, %lu < %ld\n", (u_long) rlen, x);
|
||||
errno = EBADRPC;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
bcopy(repl->data, addr, x);
|
||||
return (x);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -360,24 +348,21 @@ nfs_readdata(d, off, addr, len)
|
|||
* On error, return non-zero and set errno.
|
||||
*/
|
||||
int
|
||||
nfs_mount(sock, ip, path)
|
||||
int sock;
|
||||
struct in_addr ip;
|
||||
char *path;
|
||||
nfs_mount(int sock, struct in_addr ip, char *path)
|
||||
{
|
||||
struct iodesc *desc;
|
||||
struct nfsv2_fattrs *fa;
|
||||
|
||||
if (!(desc = socktodesc(sock))) {
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Bind to a reserved port. */
|
||||
desc->myport = htons(--rpc_port);
|
||||
desc->destip = ip;
|
||||
if (nfs_getrootfh(desc, path, nfs_root_node.fh))
|
||||
return (-1);
|
||||
return -1;
|
||||
nfs_root_node.iodesc = desc;
|
||||
/* Fake up attributes for the root dir. */
|
||||
fa = &nfs_root_node.fa;
|
||||
|
@ -390,7 +375,7 @@ nfs_mount(sock, ip, path)
|
|||
printf("nfs_mount: got fh for %s\n", path);
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -398,9 +383,7 @@ nfs_mount(sock, ip, path)
|
|||
* return zero or error number
|
||||
*/
|
||||
int
|
||||
nfs_open(path, f)
|
||||
const char *path;
|
||||
struct open_file *f;
|
||||
nfs_open(const char *path, struct open_file *f)
|
||||
{
|
||||
struct nfs_iodesc *newfd, *currfd;
|
||||
const char *cp;
|
||||
|
@ -415,11 +398,11 @@ nfs_open(path, f)
|
|||
|
||||
#ifdef NFS_DEBUG
|
||||
if (debug)
|
||||
printf("nfs_open: %s\n", path);
|
||||
printf("nfs_open: %s\n", path);
|
||||
#endif
|
||||
if (nfs_root_node.iodesc == NULL) {
|
||||
printf("nfs_open: must mount first.\n");
|
||||
return (ENXIO);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
currfd = &nfs_root_node;
|
||||
|
@ -537,7 +520,7 @@ out:
|
|||
#endif
|
||||
if (!error) {
|
||||
f->f_fsdata = (void *)currfd;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NFS_DEBUG
|
||||
|
@ -550,12 +533,11 @@ out:
|
|||
if (newfd)
|
||||
dealloc(newfd, sizeof(*newfd));
|
||||
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
nfs_close(f)
|
||||
struct open_file *f;
|
||||
nfs_close(struct open_file *f)
|
||||
{
|
||||
struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
|
||||
|
||||
|
@ -568,18 +550,14 @@ nfs_close(f)
|
|||
dealloc(fp, sizeof(struct nfs_iodesc));
|
||||
f->f_fsdata = (void *)0;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* read a portion of a file
|
||||
*/
|
||||
int
|
||||
nfs_read(f, buf, size, resid)
|
||||
struct open_file *f;
|
||||
void *buf;
|
||||
size_t size;
|
||||
size_t *resid; /* out */
|
||||
nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
|
||||
{
|
||||
struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
|
||||
ssize_t cc;
|
||||
|
@ -602,7 +580,7 @@ nfs_read(f, buf, size, resid)
|
|||
printf("nfs_read: read: %s\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
return (errno); /* XXX - from nfs_readdata */
|
||||
return errno; /* XXX - from nfs_readdata */
|
||||
}
|
||||
if (cc == 0) {
|
||||
#ifdef NFS_DEBUG
|
||||
|
@ -619,27 +597,20 @@ ret:
|
|||
if (resid)
|
||||
*resid = size;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not implemented.
|
||||
*/
|
||||
int
|
||||
nfs_write(f, buf, size, resid)
|
||||
struct open_file *f;
|
||||
void *buf;
|
||||
size_t size;
|
||||
size_t *resid; /* out */
|
||||
nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid)
|
||||
{
|
||||
return (EROFS);
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
off_t
|
||||
nfs_seek(f, offset, where)
|
||||
struct open_file *f;
|
||||
off_t offset;
|
||||
int where;
|
||||
nfs_seek(struct open_file *f, off_t offset, int where)
|
||||
{
|
||||
struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata;
|
||||
n_long size = ntohl(d->fa.fa_size);
|
||||
|
@ -655,10 +626,10 @@ nfs_seek(f, offset, where)
|
|||
d->off = size - offset;
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (d->off);
|
||||
return d->off;
|
||||
}
|
||||
|
||||
/* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */
|
||||
|
@ -666,9 +637,7 @@ const int nfs_stat_types[8] = {
|
|||
0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 };
|
||||
|
||||
int
|
||||
nfs_stat(f, sb)
|
||||
struct open_file *f;
|
||||
struct stat *sb;
|
||||
nfs_stat(struct open_file *f, struct stat *sb)
|
||||
{
|
||||
struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
|
||||
n_long ftype, mode;
|
||||
|
@ -683,5 +652,5 @@ nfs_stat(f, sb)
|
|||
sb->st_gid = ntohl(fp->fa.fa_gid);
|
||||
sb->st_size = ntohl(fp->fa.fa_size);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: open.c,v 1.25 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: open.c,v 1.26 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -72,12 +72,10 @@ oopen(){}
|
|||
|
||||
int
|
||||
#ifndef __INTERNAL_LIBSA_CREAD
|
||||
open(fname, mode)
|
||||
open(const char *fname, int mode)
|
||||
#else
|
||||
oopen(fname, mode)
|
||||
oopen(const char *fname, int mode)
|
||||
#endif
|
||||
const char *fname;
|
||||
int mode;
|
||||
{
|
||||
struct open_file *f;
|
||||
int fd, error;
|
||||
|
@ -91,7 +89,7 @@ oopen(fname, mode)
|
|||
if (f->f_flags == 0)
|
||||
goto fnd;
|
||||
errno = EMFILE;
|
||||
return (-1);
|
||||
return -1;
|
||||
fnd:
|
||||
/*
|
||||
* Try to open the device.
|
||||
|
@ -121,7 +119,7 @@ fnd:
|
|||
/* see if we opened a raw device; otherwise, 'file' is the file name. */
|
||||
if (file == (char *)0 || *file == '\0') {
|
||||
f->f_flags |= F_RAW;
|
||||
return (fd);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -132,7 +130,7 @@ fnd:
|
|||
error = FS_OPEN(&file_system[i])(file, f);
|
||||
if (error == 0) {
|
||||
f->f_ops = &file_system[i];
|
||||
return (fd);
|
||||
return fd;
|
||||
}
|
||||
if (error != EINVAL)
|
||||
besterror = error;
|
||||
|
@ -141,7 +139,7 @@ fnd:
|
|||
#else
|
||||
error = FS_OPEN(&file_system[i])(file, f);
|
||||
if (error == 0)
|
||||
return (fd);
|
||||
return fd;
|
||||
if (error == EINVAL)
|
||||
error = ENOENT;
|
||||
#endif
|
||||
|
@ -155,5 +153,5 @@ fnd:
|
|||
err:
|
||||
f->f_flags = 0;
|
||||
errno = error;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: panic.c,v 1.5 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: panic.c,v 1.6 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -43,24 +43,24 @@ panic(fmt /*, va_alist */)
|
|||
char *fmt;
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
#ifndef LIBSA_NO_FS_CLOSE
|
||||
static int paniced;
|
||||
static int paniced;
|
||||
|
||||
if (!paniced) {
|
||||
paniced = 1;
|
||||
closeall();
|
||||
}
|
||||
if (!paniced) {
|
||||
paniced = 1;
|
||||
closeall();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
va_start(ap, fmt);
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
va_start(ap);
|
||||
#endif
|
||||
vprintf(fmt, ap);
|
||||
printf("\n");
|
||||
va_end(ap);
|
||||
_rtt();
|
||||
/*NOTREACHED*/
|
||||
vprintf(fmt, ap);
|
||||
printf("\n");
|
||||
va_end(ap);
|
||||
_rtt();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/sys/libkern/qsort.c,v 1.12 2002/11/09 12:55:06 alfred Exp $
|
||||
* $NetBSD: qsort.c,v 1.3 2005/12/24 20:45:09 perry Exp $
|
||||
* $NetBSD: qsort.c,v 1.4 2007/11/24 13:20:56 isaki Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -50,22 +50,20 @@ void qsort(void *a, size_t n, size_t es, cmp_t *cmp);
|
|||
*/
|
||||
#define swapcode(TYPE, parmi, parmj, n) { \
|
||||
long i = (n) / sizeof (TYPE); \
|
||||
register TYPE *pi = (TYPE *) (parmi); \
|
||||
register TYPE *pj = (TYPE *) (parmj); \
|
||||
register TYPE *pi = (TYPE *)(parmi); \
|
||||
register TYPE *pj = (TYPE *)(parmj); \
|
||||
do { \
|
||||
register TYPE t = *pi; \
|
||||
*pi++ = *pj; \
|
||||
*pj++ = t; \
|
||||
} while (--i > 0); \
|
||||
} while (--i > 0); \
|
||||
}
|
||||
|
||||
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
||||
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
||||
|
||||
static inline void
|
||||
swapfunc(a, b, n, swaptype)
|
||||
char *a, *b;
|
||||
int n, swaptype;
|
||||
swapfunc(char *a, char *b, int n, int swaptype)
|
||||
{
|
||||
if(swaptype <= 1)
|
||||
swapcode(long, a, b, n)
|
||||
|
@ -84,13 +82,11 @@ swapfunc(a, b, n, swaptype)
|
|||
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
|
||||
|
||||
static inline char *
|
||||
med3(a, b, c, cmp)
|
||||
char *a, *b, *c;
|
||||
cmp_t *cmp;
|
||||
med3(char *a, char *b, char *c, cmp_t *cmp)
|
||||
{
|
||||
return cmp(a, b) < 0 ?
|
||||
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
|
||||
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
|
||||
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -99,7 +95,8 @@ qsort(void *a, size_t n, size_t es, cmp_t *cmp)
|
|||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
int d, r, swaptype, swap_cnt;
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
loop:
|
||||
SWAPINIT(a, es);
|
||||
swap_cnt = 0;
|
||||
if (n < 7) {
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rarp.c,v 1.25 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: rarp.c,v 1.26 2007/11/24 13:20:56 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -63,7 +63,7 @@
|
|||
* to resolving internet addresses. Field names used correspond to
|
||||
* RFC 826.
|
||||
*/
|
||||
struct ether_arp {
|
||||
struct ether_arp {
|
||||
struct arphdr ea_hdr; /* fixed-size header */
|
||||
u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
|
||||
u_int8_t arp_spa[4]; /* sender protocol address */
|
||||
|
@ -83,8 +83,7 @@ static ssize_t rarprecv __P((struct iodesc *, void *, size_t, time_t));
|
|||
* Ethernet (Reverse) Address Resolution Protocol (see RFC 903, and 826).
|
||||
*/
|
||||
int
|
||||
rarp_getipaddress(sock)
|
||||
int sock;
|
||||
rarp_getipaddress(int sock)
|
||||
{
|
||||
struct iodesc *d;
|
||||
struct ether_arp *ap;
|
||||
|
@ -109,14 +108,14 @@ rarp_getipaddress(sock)
|
|||
#endif
|
||||
if (!(d = socktodesc(sock))) {
|
||||
printf("rarp: bad socket. %d\n", sock);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#ifdef RARP_DEBUG
|
||||
if (debug)
|
||||
printf("rarp: d=%lx\n", (u_long)d);
|
||||
#endif
|
||||
|
||||
bzero((char*)&wbuf.data, sizeof(wbuf.data));
|
||||
bzero((char *)&wbuf.data, sizeof(wbuf.data));
|
||||
ap = &wbuf.data.arp;
|
||||
ap->arp_hrd = htons(ARPHRD_ETHER);
|
||||
ap->arp_pro = htons(ETHERTYPE_IP);
|
||||
|
@ -131,7 +130,7 @@ rarp_getipaddress(sock)
|
|||
rarprecv, &rbuf.data, sizeof(rbuf.data)) < 0)
|
||||
{
|
||||
printf("No response for RARP request\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ap = &rbuf.data.arp;
|
||||
|
@ -150,17 +149,14 @@ rarp_getipaddress(sock)
|
|||
netmask = IN_CLASSC_NET;
|
||||
|
||||
d->myip = myip;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Broadcast a RARP request (i.e. who knows who I am)
|
||||
*/
|
||||
static ssize_t
|
||||
rarpsend(d, pkt, len)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
rarpsend(struct iodesc *d, void *pkt, size_t len)
|
||||
{
|
||||
|
||||
#ifdef RARP_DEBUG
|
||||
|
@ -168,7 +164,7 @@ rarpsend(d, pkt, len)
|
|||
printf("rarpsend: called\n");
|
||||
#endif
|
||||
|
||||
return (sendether(d, pkt, len, bcea, ETHERTYPE_REVARP));
|
||||
return sendether(d, pkt, len, bcea, ETHERTYPE_REVARP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -176,11 +172,7 @@ rarpsend(d, pkt, len)
|
|||
* else -1 (and errno == 0)
|
||||
*/
|
||||
static ssize_t
|
||||
rarprecv(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
rarprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
ssize_t n;
|
||||
struct ether_arp *ap;
|
||||
|
@ -198,7 +190,7 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad len=%d\n", n);
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (etype != ETHERTYPE_REVARP) {
|
||||
|
@ -206,7 +198,7 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad type=0x%x\n", etype);
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ap = (struct ether_arp *)pkt;
|
||||
|
@ -219,7 +211,7 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad hrd/pro/hln/pln\n");
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ap->arp_op != htons(ARPOP_REVREPLY)) {
|
||||
|
@ -227,7 +219,7 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("bad op=0x%x\n", ntohs(ap->arp_op));
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Is the reply for our Ethernet address? */
|
||||
|
@ -236,7 +228,7 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("unwanted address\n");
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We have our answer. */
|
||||
|
@ -244,5 +236,5 @@ rarprecv(d, pkt, len, tleft)
|
|||
if (debug)
|
||||
printf("got it\n");
|
||||
#endif
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: read.c,v 1.13 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: read.c,v 1.14 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -65,13 +65,10 @@
|
|||
|
||||
ssize_t
|
||||
#ifndef __INTERNAL_LIBSA_CREAD
|
||||
read(fd, dest, bcount)
|
||||
read(int fd, void *dest, size_t bcount)
|
||||
#else
|
||||
oread(fd, dest, bcount)
|
||||
oread(int fd, void *dest, size_t bcount)
|
||||
#endif
|
||||
int fd;
|
||||
void *dest;
|
||||
size_t bcount;
|
||||
{
|
||||
struct open_file *f = &files[fd];
|
||||
size_t resid;
|
||||
|
@ -79,7 +76,7 @@ oread(fd, dest, bcount)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
|
@ -90,13 +87,13 @@ oread(fd, dest, bcount)
|
|||
errno = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
btodb(f->f_offset), bcount, dest, &resid);
|
||||
if (errno)
|
||||
return (-1);
|
||||
return -1;
|
||||
f->f_offset += resid;
|
||||
return (resid);
|
||||
return resid;
|
||||
}
|
||||
#endif
|
||||
resid = bcount;
|
||||
if ((errno = FS_READ(f->f_ops)(f, dest, bcount, &resid)))
|
||||
return (-1);
|
||||
return -1;
|
||||
return (ssize_t)(bcount - resid);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc.c,v 1.25 2006/01/21 10:06:06 dsl Exp $ */
|
||||
/* $NetBSD: rpc.c,v 1.26 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -113,13 +113,8 @@ int rpc_port = 0x400; /* predecrement */
|
|||
* Note: Caller must leave room for headers.
|
||||
*/
|
||||
ssize_t
|
||||
rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
|
||||
struct iodesc *d;
|
||||
n_long prog, vers, proc;
|
||||
void *sdata;
|
||||
size_t slen;
|
||||
void *rdata;
|
||||
size_t rlen;
|
||||
rpc_call(struct iodesc *d, n_long prog, n_long vers, n_long proc,
|
||||
void *sdata, size_t slen, void *rdata, size_t rlen)
|
||||
{
|
||||
ssize_t cc;
|
||||
struct auth_info *auth;
|
||||
|
@ -138,7 +133,7 @@ rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
|
|||
|
||||
port = rpc_getport(d, prog, vers);
|
||||
if (port == -1)
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
d->destport = htons(port);
|
||||
|
||||
|
@ -196,11 +191,11 @@ rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
|
|||
printf("callrpc: cc=%ld rlen=%lu\n", (long)cc, (u_long)rlen);
|
||||
#endif
|
||||
if (cc == -1)
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
if ((size_t)cc <= sizeof(*reply)) {
|
||||
errno = EBADRPC;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
recv_tail = recv_head + cc;
|
||||
|
@ -218,13 +213,13 @@ rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
|
|||
printf("callrpc: reply auth != NULL\n");
|
||||
#endif
|
||||
errno = EBADRPC;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
x = ntohl(reply->rp_u.rpu_rok.rok_status);
|
||||
if (x != 0) {
|
||||
printf("callrpc: error = %d\n", x);
|
||||
errno = EBADRPC;
|
||||
return(-1);
|
||||
return -1;
|
||||
}
|
||||
recv_head += sizeof(*reply);
|
||||
|
||||
|
@ -237,11 +232,7 @@ rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
|
|||
* Remaining checks are done by callrpc
|
||||
*/
|
||||
static ssize_t
|
||||
recvrpc(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
recvrpc(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
struct rpc_reply *reply;
|
||||
ssize_t n;
|
||||
|
@ -285,7 +276,7 @@ recvrpc(d, pkt, len, tleft)
|
|||
}
|
||||
|
||||
/* Return data count (thus indicating success) */
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -293,10 +284,7 @@ recvrpc(d, pkt, len, tleft)
|
|||
* dig out the IP address/port from the headers.
|
||||
*/
|
||||
void
|
||||
rpc_fromaddr(pkt, addr, port)
|
||||
void *pkt;
|
||||
struct in_addr *addr;
|
||||
u_short *port;
|
||||
rpc_fromaddr(void *pkt, struct in_addr *addr, u_short *port)
|
||||
{
|
||||
struct hackhdr {
|
||||
/* Tail of IP header: just IP addresses */
|
||||
|
@ -334,12 +322,15 @@ struct pmap_list {
|
|||
int port; /* host order */
|
||||
} rpc_pmap_list[PMAP_NUM];
|
||||
|
||||
/* return port number in host order, or -1 */
|
||||
/*
|
||||
* return port number in host order, or -1.
|
||||
* arguments are:
|
||||
* addr .. server, net order.
|
||||
* prog .. host order.
|
||||
* vers .. host order.
|
||||
*/
|
||||
int
|
||||
rpc_pmap_getcache(addr, prog, vers)
|
||||
struct in_addr addr; /* server, net order */
|
||||
u_int prog; /* host order */
|
||||
u_int vers; /* host order */
|
||||
rpc_pmap_getcache(struct in_addr addr, u_int prog, u_int vers)
|
||||
{
|
||||
struct pmap_list *pl;
|
||||
|
||||
|
@ -347,18 +338,21 @@ rpc_pmap_getcache(addr, prog, vers)
|
|||
if (pl->addr.s_addr == addr.s_addr &&
|
||||
pl->prog == prog && pl->vers == vers )
|
||||
{
|
||||
return (pl->port);
|
||||
return pl->port;
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* arguments are:
|
||||
* addr .. server, net order.
|
||||
* prog .. host order.
|
||||
* vers .. host order.
|
||||
* port .. host order.
|
||||
*/
|
||||
void
|
||||
rpc_pmap_putcache(addr, prog, vers, port)
|
||||
struct in_addr addr; /* server, net order */
|
||||
u_int prog; /* host order */
|
||||
u_int vers; /* host order */
|
||||
int port; /* host order */
|
||||
rpc_pmap_putcache(struct in_addr addr, u_int prog, u_int vers, int port)
|
||||
{
|
||||
struct pmap_list *pl;
|
||||
|
||||
|
@ -385,12 +379,10 @@ rpc_pmap_putcache(addr, prog, vers, port)
|
|||
/*
|
||||
* Request a port number from the port mapper.
|
||||
* Returns the port in host order.
|
||||
* prog and vers are host order.
|
||||
*/
|
||||
int
|
||||
rpc_getport(d, prog, vers)
|
||||
struct iodesc *d;
|
||||
n_long prog; /* host order */
|
||||
n_long vers; /* host order */
|
||||
rpc_getport(struct iodesc *d, n_long prog, n_long vers)
|
||||
{
|
||||
struct args {
|
||||
n_long prog; /* call program */
|
||||
|
@ -420,12 +412,12 @@ rpc_getport(d, prog, vers)
|
|||
|
||||
/* This one is fixed forever. */
|
||||
if (prog == PMAPPROG)
|
||||
return (PMAPPORT);
|
||||
return PMAPPORT;
|
||||
|
||||
/* Try for cached answer first */
|
||||
port = rpc_pmap_getcache(d->destip, prog, vers);
|
||||
if (port != -1)
|
||||
return (port);
|
||||
return port;
|
||||
|
||||
args = &sdata.d;
|
||||
args->prog = htonl(prog);
|
||||
|
@ -439,11 +431,11 @@ rpc_getport(d, prog, vers)
|
|||
if ((size_t)cc < sizeof(*res)) {
|
||||
printf("getport: %s", strerror(errno));
|
||||
errno = EBADRPC;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
port = (int)ntohl(res->port);
|
||||
|
||||
rpc_pmap_putcache(d->destip, prog, vers, port);
|
||||
|
||||
return (port);
|
||||
return port;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc.h,v 1.9 2006/01/21 10:06:06 dsl Exp $ */
|
||||
/* $NetBSD: rpc.h,v 1.10 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -50,7 +50,7 @@
|
|||
|
||||
/* RPC functions: */
|
||||
ssize_t rpc_call __P((struct iodesc *, n_long, n_long, n_long,
|
||||
void *, size_t, void *, size_t));
|
||||
void *, size_t, void *, size_t));
|
||||
void rpc_fromaddr __P((void *, struct in_addr *, u_short *));
|
||||
int rpc_pmap_getcache __P((struct in_addr, u_int, u_int));
|
||||
void rpc_pmap_putcache __P((struct in_addr, u_int, u_int, int));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: snprintf.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: snprintf.c,v 1.4 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -60,5 +60,5 @@ snprintf(buf, size, fmt, va_alist)
|
|||
#endif
|
||||
len = vsnprintf(buf, size, fmt, ap);
|
||||
va_end(ap);
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sprintf.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: sprintf.c,v 1.4 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -59,5 +59,5 @@ sprintf(buf, fmt, va_alist)
|
|||
#endif
|
||||
len = vsnprintf(buf, -(size_t)buf, fmt, ap);
|
||||
va_end(ap);
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: stand.h,v 1.61 2006/01/25 22:44:37 uwe Exp $ */
|
||||
/* $NetBSD: stand.h,v 1.62 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -261,7 +261,7 @@ int stat(const char *, struct stat *);
|
|||
int fstat(int, struct stat *);
|
||||
|
||||
typedef int cmp_t __P((const void *, const void *));
|
||||
void qsort(void *, size_t, size_t, cmp_t * cmp);
|
||||
void qsort(void *, size_t, size_t, cmp_t *);
|
||||
|
||||
extern int opterr, optind, optopt, optreset;
|
||||
extern char *optarg;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: stat.c,v 1.6 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: stat.c,v 1.7 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -34,16 +34,14 @@
|
|||
#include "stand.h"
|
||||
|
||||
int
|
||||
stat(str, sb)
|
||||
const char *str;
|
||||
struct stat *sb;
|
||||
stat(const char *str, struct stat *sb)
|
||||
{
|
||||
int fd, rv;
|
||||
|
||||
fd = open(str, 0);
|
||||
if (fd < 0)
|
||||
return (-1);
|
||||
return -1;
|
||||
rv = fstat(fd, sb);
|
||||
(void)close(fd);
|
||||
return (rv);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: strerror.c,v 1.19 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: strerror.c,v 1.20 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -54,7 +54,8 @@ static const struct mi {
|
|||
{ ENOTDIR, "Not a directory" },
|
||||
{ EOFFSET, "invalid file offset" },
|
||||
{ EACCES, "Permission denied" },
|
||||
{ 0, 0 } };
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
char *
|
||||
strerror(int err)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_prf.c,v 1.15 2006/01/27 02:28:36 uwe Exp $ */
|
||||
/* $NetBSD: subr_prf.c,v 1.16 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -74,7 +74,7 @@ vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
|
|||
ebuf = buf + size - 1;
|
||||
kdoprnt(sputchar, fmt, ap);
|
||||
*sbuf = '\0';
|
||||
return (sbuf - buf);
|
||||
return sbuf - buf;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -92,7 +92,8 @@ kdoprnt(void (*put)(int), const char *fmt, va_list ap)
|
|||
put(ch);
|
||||
}
|
||||
lflag = 0;
|
||||
reswitch: switch (ch = *fmt++) {
|
||||
reswitch:
|
||||
switch (ch = *fmt++) {
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
goto reswitch;
|
||||
|
@ -151,6 +152,7 @@ reswitch: switch (ch = *fmt++) {
|
|||
if (ch == '\0')
|
||||
return;
|
||||
put(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tftp.c,v 1.22 2007/03/05 14:49:04 he Exp $ */
|
||||
/* $NetBSD: tftp.c,v 1.23 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -87,7 +87,7 @@ static const int tftperrors[8] = {
|
|||
EINVAL, /* ??? */
|
||||
EINVAL, /* ??? */
|
||||
EEXIST,
|
||||
EINVAL /* ??? */
|
||||
EINVAL, /* ??? */
|
||||
};
|
||||
|
||||
static ssize_t recvtftp __P((struct iodesc *, void *, size_t, time_t));
|
||||
|
@ -98,11 +98,7 @@ static void tftp_terminate __P((struct tftp_handle *));
|
|||
#endif
|
||||
|
||||
static ssize_t
|
||||
recvtftp(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
recvtftp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
ssize_t n;
|
||||
struct tftphdr *t;
|
||||
|
@ -112,23 +108,23 @@ recvtftp(d, pkt, len, tleft)
|
|||
n = readudp(d, pkt, len, tleft);
|
||||
|
||||
if (n < 4)
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
t = (struct tftphdr *) pkt;
|
||||
t = (struct tftphdr *)pkt;
|
||||
switch (ntohs(t->th_opcode)) {
|
||||
case DATA:
|
||||
if (htons(t->th_block) != d->xid) {
|
||||
/*
|
||||
* Expected block?
|
||||
*/
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
if (d->xid == 1) {
|
||||
/*
|
||||
* First data packet from new port.
|
||||
*/
|
||||
struct udphdr *uh;
|
||||
uh = (struct udphdr *) pkt - 1;
|
||||
uh = (struct udphdr *)pkt - 1;
|
||||
d->destport = uh->uh_sport;
|
||||
} /* else check uh_sport has not changed??? */
|
||||
return (n - (t->th_data - (char *)t));
|
||||
|
@ -142,23 +138,22 @@ recvtftp(d, pkt, len, tleft)
|
|||
#endif
|
||||
errno = tftperrors[ntohs(t->th_code)];
|
||||
}
|
||||
return (-1);
|
||||
return -1;
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
printf("tftp type %d not handled\n", ntohs(t->th_opcode));
|
||||
#endif
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* send request, expect first block (or error) */
|
||||
static int
|
||||
tftp_makereq(h)
|
||||
struct tftp_handle *h;
|
||||
tftp_makereq(struct tftp_handle *h)
|
||||
{
|
||||
struct {
|
||||
u_char header[HEADER_SIZE];
|
||||
struct tftphdr t;
|
||||
struct tftphdr t;
|
||||
u_char space[FNAME_SIZE + 6];
|
||||
} wbuf;
|
||||
char *wtail;
|
||||
|
@ -166,7 +161,7 @@ tftp_makereq(h)
|
|||
ssize_t res;
|
||||
struct tftphdr *t;
|
||||
|
||||
wbuf.t.th_opcode = htons((u_short) RRQ);
|
||||
wbuf.t.th_opcode = htons((u_short)RRQ);
|
||||
wtail = wbuf.t.th_stuff;
|
||||
l = strlen(h->path);
|
||||
bcopy(h->path, wtail, l + 1);
|
||||
|
@ -181,24 +176,23 @@ tftp_makereq(h)
|
|||
h->iodesc->destport = htons(IPPORT_TFTP);
|
||||
h->iodesc->xid = 1; /* expected block */
|
||||
|
||||
res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
|
||||
res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *)&wbuf.t,
|
||||
recvtftp, t, sizeof(*t) + RSPACE);
|
||||
|
||||
if (res == -1)
|
||||
return (errno);
|
||||
return errno;
|
||||
|
||||
h->currblock = 1;
|
||||
h->validsize = res;
|
||||
h->islastblock = 0;
|
||||
if (res < SEGSIZE)
|
||||
h->islastblock = 1; /* very short file */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ack block, expect next */
|
||||
static int
|
||||
tftp_getnextblock(h)
|
||||
struct tftp_handle *h;
|
||||
tftp_getnextblock(struct tftp_handle *h)
|
||||
{
|
||||
struct {
|
||||
u_char header[HEADER_SIZE];
|
||||
|
@ -208,31 +202,30 @@ tftp_getnextblock(h)
|
|||
int res;
|
||||
struct tftphdr *t;
|
||||
|
||||
wbuf.t.th_opcode = htons((u_short) ACK);
|
||||
wbuf.t.th_block = htons((u_short) h->currblock);
|
||||
wtail = (char *) &wbuf.t.th_data;
|
||||
wbuf.t.th_opcode = htons((u_short)ACK);
|
||||
wbuf.t.th_block = htons((u_short)h->currblock);
|
||||
wtail = (char *)&wbuf.t.th_data;
|
||||
|
||||
t = &h->lastdata.t;
|
||||
|
||||
h->iodesc->xid = h->currblock + 1; /* expected block */
|
||||
|
||||
res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *) &wbuf.t,
|
||||
res = sendrecv(h->iodesc, sendudp, &wbuf.t, wtail - (char *)&wbuf.t,
|
||||
recvtftp, t, sizeof(*t) + RSPACE);
|
||||
|
||||
if (res == -1) /* 0 is OK! */
|
||||
return (errno);
|
||||
return errno;
|
||||
|
||||
h->currblock++;
|
||||
h->validsize = res;
|
||||
if (res < SEGSIZE)
|
||||
h->islastblock = 1; /* EOF */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TFTP_NOTERMINATE
|
||||
static void
|
||||
tftp_terminate(h)
|
||||
struct tftp_handle *h;
|
||||
tftp_terminate(struct tftp_handle *h)
|
||||
{
|
||||
struct {
|
||||
u_char header[HEADER_SIZE];
|
||||
|
@ -241,32 +234,30 @@ tftp_terminate(h)
|
|||
char *wtail;
|
||||
|
||||
if (h->islastblock) {
|
||||
wbuf.t.th_opcode = htons((u_short) ACK);
|
||||
wbuf.t.th_block = htons((u_short) h->currblock);
|
||||
wbuf.t.th_opcode = htons((u_short)ACK);
|
||||
wbuf.t.th_block = htons((u_short)h->currblock);
|
||||
} else {
|
||||
wbuf.t.th_opcode = htons((u_short) ERROR);
|
||||
wbuf.t.th_code = htons((u_short) ENOSPACE); /* ??? */
|
||||
wbuf.t.th_opcode = htons((u_short)ERROR);
|
||||
wbuf.t.th_code = htons((u_short)ENOSPACE); /* ??? */
|
||||
}
|
||||
wtail = (char *) &wbuf.t.th_data;
|
||||
wtail = (char *)&wbuf.t.th_data;
|
||||
|
||||
(void) sendudp(h->iodesc, &wbuf.t, wtail - (char *) &wbuf.t);
|
||||
(void)sendudp(h->iodesc, &wbuf.t, wtail - (char *)&wbuf.t);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
tftp_open(path, f)
|
||||
const char *path;
|
||||
struct open_file *f;
|
||||
tftp_open(const char *path, struct open_file *f)
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
struct iodesc *io;
|
||||
int res;
|
||||
|
||||
tftpfile = (struct tftp_handle *) alloc(sizeof(*tftpfile));
|
||||
tftpfile = (struct tftp_handle *)alloc(sizeof(*tftpfile));
|
||||
if (!tftpfile)
|
||||
return (ENOMEM);
|
||||
return ENOMEM;
|
||||
|
||||
tftpfile->iodesc = io = socktodesc(*(int *) (f->f_devdata));
|
||||
tftpfile->iodesc = io = socktodesc(*(int *)(f->f_devdata));
|
||||
io->destip = servip;
|
||||
tftpfile->off = 0;
|
||||
tftpfile->path = path; /* XXXXXXX we hope it's static */
|
||||
|
@ -275,24 +266,20 @@ tftp_open(path, f)
|
|||
|
||||
if (res) {
|
||||
dealloc(tftpfile, sizeof(*tftpfile));
|
||||
return (res);
|
||||
return res;
|
||||
}
|
||||
f->f_fsdata = (void *) tftpfile;
|
||||
return (0);
|
||||
f->f_fsdata = (void *)tftpfile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
tftp_read(f, addr, size, resid)
|
||||
struct open_file *f;
|
||||
void *addr;
|
||||
size_t size;
|
||||
size_t *resid; /* out */
|
||||
tftp_read(struct open_file *f, void *addr, size_t size, size_t *resid)
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
static int tc = 0;
|
||||
#endif
|
||||
tftpfile = (struct tftp_handle *) f->f_fsdata;
|
||||
tftpfile = (struct tftp_handle *)f->f_fsdata;
|
||||
|
||||
while (size > 0) {
|
||||
int needblock;
|
||||
|
@ -310,7 +297,7 @@ tftp_read(f, addr, size, resid)
|
|||
tftp_terminate(tftpfile);
|
||||
#endif
|
||||
tftp_makereq(tftpfile); /* no error check, it worked
|
||||
* for open */
|
||||
* for open */
|
||||
}
|
||||
|
||||
while (tftpfile->currblock < needblock) {
|
||||
|
@ -322,7 +309,7 @@ tftp_read(f, addr, size, resid)
|
|||
printf("tftp: read error (block %d->%d)\n",
|
||||
tftpfile->currblock, needblock);
|
||||
#endif
|
||||
return (res);
|
||||
return res;
|
||||
}
|
||||
if (tftpfile->islastblock)
|
||||
break;
|
||||
|
@ -339,7 +326,7 @@ tftp_read(f, addr, size, resid)
|
|||
printf("tftp: invalid offset %d\n",
|
||||
tftpfile->off);
|
||||
#endif
|
||||
return (EINVAL);
|
||||
return EINVAL;
|
||||
}
|
||||
count = (size < inbuffer ? size : inbuffer);
|
||||
bcopy(tftpfile->lastdata.t.th_data + offinblock,
|
||||
|
@ -355,22 +342,21 @@ tftp_read(f, addr, size, resid)
|
|||
#ifdef DEBUG
|
||||
printf("tftp: block %d not found\n", needblock);
|
||||
#endif
|
||||
return (EINVAL);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (resid)
|
||||
*resid = size;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
tftp_close(f)
|
||||
struct open_file *f;
|
||||
tftp_close(struct open_file *f)
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
tftpfile = (struct tftp_handle *) f->f_fsdata;
|
||||
tftpfile = (struct tftp_handle *)f->f_fsdata;
|
||||
|
||||
#ifdef TFTP_NOTERMINATE
|
||||
/* let it time out ... */
|
||||
|
@ -379,43 +365,35 @@ tftp_close(f)
|
|||
#endif
|
||||
|
||||
dealloc(tftpfile, sizeof(*tftpfile));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
tftp_write(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
void *start;
|
||||
size_t size;
|
||||
size_t *resid; /* out */
|
||||
tftp_write(struct open_file *f, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
return (EROFS);
|
||||
|
||||
return EROFS;
|
||||
}
|
||||
|
||||
int
|
||||
tftp_stat(f, sb)
|
||||
struct open_file *f;
|
||||
struct stat *sb;
|
||||
tftp_stat(struct open_file *f, struct stat *sb)
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
tftpfile = (struct tftp_handle *) f->f_fsdata;
|
||||
tftpfile = (struct tftp_handle *)f->f_fsdata;
|
||||
|
||||
sb->st_mode = 0444;
|
||||
sb->st_nlink = 1;
|
||||
sb->st_uid = 0;
|
||||
sb->st_gid = 0;
|
||||
sb->st_size = -1;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_t
|
||||
tftp_seek(f, offset, where)
|
||||
struct open_file *f;
|
||||
off_t offset;
|
||||
int where;
|
||||
tftp_seek(struct open_file *f, off_t offset, int where)
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
tftpfile = (struct tftp_handle *) f->f_fsdata;
|
||||
tftpfile = (struct tftp_handle *)f->f_fsdata;
|
||||
|
||||
switch (where) {
|
||||
case SEEK_SET:
|
||||
|
@ -426,7 +404,7 @@ tftp_seek(f, offset, where)
|
|||
break;
|
||||
default:
|
||||
errno = EOFFSET;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
return (tftpfile->off);
|
||||
return tftpfile->off;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: twiddle.c,v 1.6 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: twiddle.c,v 1.7 2007/11/24 13:20:57 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -39,7 +39,7 @@
|
|||
#define TWIDDLE_CHARS "|/-\\"
|
||||
|
||||
void
|
||||
twiddle()
|
||||
twiddle(void)
|
||||
{
|
||||
static int pos;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: udp.c,v 1.5 2006/01/24 17:07:19 christos Exp $ */
|
||||
/* $NetBSD: udp.c,v 1.6 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Regents of the University of California.
|
||||
|
@ -64,10 +64,7 @@
|
|||
|
||||
/* Caller must leave room for ethernet, ip and udp headers in front!! */
|
||||
ssize_t
|
||||
sendudp(d, pkt, len)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
sendudp(struct iodesc *d, void *pkt, size_t len)
|
||||
{
|
||||
ssize_t cc;
|
||||
struct ip *ip;
|
||||
|
@ -128,7 +125,7 @@ sendudp(d, pkt, len)
|
|||
|
||||
cc = sendether(d, ip, len, ea, ETHERTYPE_IP);
|
||||
if (cc == -1)
|
||||
return (-1);
|
||||
return -1;
|
||||
if ((size_t)cc != len)
|
||||
panic("sendudp: bad write (%d != %d)", cc, len);
|
||||
return (cc - (sizeof(*ip) + sizeof(*uh)));
|
||||
|
@ -139,11 +136,7 @@ sendudp(d, pkt, len)
|
|||
* Caller leaves room for the headers (Ether, IP, UDP)
|
||||
*/
|
||||
ssize_t
|
||||
readudp(d, pkt, len, tleft)
|
||||
struct iodesc *d;
|
||||
void *pkt;
|
||||
size_t len;
|
||||
time_t tleft;
|
||||
readudp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
|
||||
{
|
||||
ssize_t n;
|
||||
size_t hlen;
|
||||
|
@ -187,15 +180,16 @@ readudp(d, pkt, len, tleft)
|
|||
if (ip->ip_v != IPVERSION ||
|
||||
ip->ip_p != IPPROTO_UDP) { /* half char */
|
||||
#ifdef NET_DEBUG
|
||||
if (debug)
|
||||
printf("readudp: IP version or not UDP. ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p);
|
||||
if (debug) {
|
||||
printf("readudp: IP version or not UDP. "
|
||||
"ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p);
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
hlen = ip->ip_hl << 2;
|
||||
if (hlen < sizeof(*ip) ||
|
||||
ip_cksum(ip, hlen) != 0) {
|
||||
if (hlen < sizeof(*ip) || ip_cksum(ip, hlen) != 0) {
|
||||
#ifdef NET_DEBUG
|
||||
if (debug)
|
||||
printf("readudp: short hdr or bad cksum.\n");
|
||||
|
@ -272,5 +266,5 @@ readudp(d, pkt, len, tleft)
|
|||
}
|
||||
|
||||
n -= sizeof(*ip) + sizeof(*uh);
|
||||
return (n);
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs.c,v 1.50 2007/09/29 21:36:56 martin Exp $ */
|
||||
/* $NetBSD: ufs.c,v 1.51 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -194,7 +194,7 @@ find_inode_sector(ino32_t inumber, struct open_file *f, daddr_t *isp)
|
|||
|
||||
rc = read_inode(fs->lfs_ifile, f);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
|
||||
ifileent_blkno =
|
||||
(inumber / fs->lfs_ifpb) + fs->lfs_cleansz + fs->lfs_segtabsz;
|
||||
|
@ -202,15 +202,15 @@ find_inode_sector(ino32_t inumber, struct open_file *f, daddr_t *isp)
|
|||
(inumber % fs->lfs_ifpb) * sizeof (IFILE_Vx);
|
||||
rc = buf_read_file(f, &ent_in_buf, &buf_after_ent);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
/* make sure something's not badly wrong, but don't panic. */
|
||||
if (buf_after_ent < sizeof (IFILE_Vx))
|
||||
return (EINVAL);
|
||||
return EINVAL;
|
||||
|
||||
*isp = FSBTODB(fs, ((IFILE_Vx *)ent_in_buf)->if_daddr);
|
||||
if (*isp == LFS_UNUSED_DADDR) /* again, something badly wrong */
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
return EINVAL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -235,7 +235,7 @@ read_inode(ino32_t inumber, struct open_file *f)
|
|||
if (inumber == fs->lfs_ifile)
|
||||
inode_sector = FSBTODB(fs, fs->lfs_idaddr);
|
||||
else if ((rc = find_inode_sector(inumber, f, &inode_sector)) != 0)
|
||||
return (rc);
|
||||
return rc;
|
||||
#else
|
||||
inode_sector = FSBTODB(fs, ino_to_fsba(fs, inumber));
|
||||
#endif
|
||||
|
@ -270,7 +270,7 @@ read_inode(ino32_t inumber, struct open_file *f)
|
|||
*/
|
||||
fp->f_ind_cache_block = ~0;
|
||||
fp->f_buf_blkno = -1;
|
||||
return (rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -315,7 +315,7 @@ block_map(struct open_file *f, indp_t file_block, indp_t *disk_block_p)
|
|||
if (file_block < NDADDR) {
|
||||
/* Direct block. */
|
||||
*disk_block_p = fp->f_di.di_db[file_block];
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
file_block -= NDADDR;
|
||||
|
@ -332,7 +332,7 @@ block_map(struct open_file *f, indp_t file_block, indp_t *disk_block_p)
|
|||
break;
|
||||
if (level > NIADDR * fp->f_nishift)
|
||||
/* Block number too high */
|
||||
return (EFBIG);
|
||||
return EFBIG;
|
||||
file_block -= (indp_t)1 << level;
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ block_map(struct open_file *f, indp_t file_block, indp_t *disk_block_p)
|
|||
level -= fp->f_nishift;
|
||||
if (ind_block_num == 0) {
|
||||
*disk_block_p = 0; /* missing */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
twiddle();
|
||||
|
@ -356,7 +356,7 @@ block_map(struct open_file *f, indp_t file_block, indp_t *disk_block_p)
|
|||
FSBTODB(fp->f_fs, ind_block_num), fs->fs_bsize,
|
||||
buf, &rsize);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
if (rsize != fs->fs_bsize)
|
||||
return EIO;
|
||||
ind_block_num = buf[file_block >> level];
|
||||
|
@ -372,7 +372,7 @@ block_map(struct open_file *f, indp_t file_block, indp_t *disk_block_p)
|
|||
|
||||
*disk_block_p = ind_block_num;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -401,7 +401,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
|
|||
if (file_block != fp->f_buf_blkno) {
|
||||
rc = block_map(f, file_block, &disk_block);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
|
||||
if (disk_block == 0) {
|
||||
memset(fp->f_buf, 0, block_size);
|
||||
|
@ -412,7 +412,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
|
|||
FSBTODB(fs, disk_block),
|
||||
block_size, fp->f_buf, &fp->f_buf_size);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fp->f_buf_blkno = file_block;
|
||||
|
@ -432,7 +432,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
|
|||
if (*size_p > fp->f_di.di_size - fp->f_seekp)
|
||||
*size_p = fp->f_di.di_size - fp->f_seekp;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -441,7 +441,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
|
|||
*/
|
||||
static int
|
||||
search_directory(const char *name, int length, struct open_file *f,
|
||||
ino32_t *inumber_p)
|
||||
ino32_t *inumber_p)
|
||||
{
|
||||
struct file *fp = (struct file *)f->f_fsdata;
|
||||
struct direct *dp;
|
||||
|
@ -455,7 +455,7 @@ search_directory(const char *name, int length, struct open_file *f,
|
|||
while (fp->f_seekp < (off_t)fp->f_di.di_size) {
|
||||
rc = buf_read_file(f, &buf, &buf_size);
|
||||
if (rc)
|
||||
return (rc);
|
||||
return rc;
|
||||
|
||||
dp = (struct direct *)buf;
|
||||
edp = (struct direct *)(buf + buf_size);
|
||||
|
@ -474,12 +474,12 @@ search_directory(const char *name, int length, struct open_file *f,
|
|||
!memcmp(name, dp->d_name, length)) {
|
||||
/* found entry */
|
||||
*inumber_p = dp->d_ino;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
fp->f_seekp += buf_size;
|
||||
}
|
||||
return (ENOENT);
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
#ifdef LIBSA_FFSv2
|
||||
|
@ -733,12 +733,12 @@ ufs_open(const char *path, struct open_file *f)
|
|||
|
||||
#endif /* !LIBSA_FS_SINGLECOMPONENT */
|
||||
|
||||
fp->f_seekp = 0; /* reset seek pointer */
|
||||
fp->f_seekp = 0; /* reset seek pointer */
|
||||
|
||||
out:
|
||||
if (rc)
|
||||
ufs_close(f);
|
||||
return (rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -748,13 +748,13 @@ ufs_close(struct open_file *f)
|
|||
|
||||
f->f_fsdata = NULL;
|
||||
if (fp == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
if (fp->f_buf)
|
||||
dealloc(fp->f_buf, fp->f_fs->fs_bsize);
|
||||
dealloc(fp->f_fs, SBLOCKSIZE);
|
||||
dealloc(fp, sizeof(struct file));
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -791,7 +791,7 @@ ufs_read(struct open_file *f, void *start, size_t size, size_t *resid)
|
|||
}
|
||||
if (resid)
|
||||
*resid = size;
|
||||
return (rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -802,7 +802,7 @@ int
|
|||
ufs_write(struct open_file *f, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
|
||||
return (EROFS);
|
||||
return EROFS;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_WRITE */
|
||||
|
||||
|
@ -823,9 +823,9 @@ ufs_seek(struct open_file *f, off_t offset, int where)
|
|||
fp->f_seekp = fp->f_di.di_size - offset;
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
return (fp->f_seekp);
|
||||
return fp->f_seekp;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_SEEK */
|
||||
|
||||
|
@ -840,7 +840,7 @@ ufs_stat(struct open_file *f, struct stat *sb)
|
|||
sb->st_uid = fp->f_di.di_uid;
|
||||
sb->st_gid = fp->f_di.di_gid;
|
||||
sb->st_size = fp->f_di.di_size;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef LIBSA_FFSv1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs_ls.c,v 1.13 2006/01/25 18:27:23 christos Exp $ */
|
||||
/* $NetBSD: ufs_ls.c,v 1.14 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993
|
||||
|
@ -172,8 +172,8 @@ ufs_ls(const char *path)
|
|||
while ((size = read(fd, dirbuf, DIRBLKSIZ)) == DIRBLKSIZ) {
|
||||
struct direct *dp, *edp;
|
||||
|
||||
dp = (struct direct *) dirbuf;
|
||||
edp = (struct direct *) (dirbuf + size);
|
||||
dp = (struct direct *)dirbuf;
|
||||
edp = (struct direct *)(dirbuf + size);
|
||||
|
||||
for (; dp < edp; dp = (void *)((char *)dp + dp->d_reclen)) {
|
||||
const char *t;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ustarfs.c,v 1.30 2007/11/11 13:23:07 isaki Exp $ */
|
||||
/* $NetBSD: ustarfs.c,v 1.31 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/* [Notice revision 2.2]
|
||||
* Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
|
||||
|
@ -136,7 +136,7 @@ typedef struct ust_active_struct {
|
|||
} ust_active_t;
|
||||
|
||||
static const char formatid[] = "USTARFS",
|
||||
metaname[] = "USTAR.volsize.";
|
||||
metaname[] = "USTAR.volsize.";
|
||||
|
||||
static const int ustarfs_mode_offset = BBSIZE;
|
||||
|
||||
|
@ -160,9 +160,7 @@ void changedisk_hook __P((struct open_file *));
|
|||
#endif
|
||||
|
||||
static int
|
||||
convert(f, base, fw)
|
||||
const char *f;
|
||||
int base, fw;
|
||||
convert(const char *f, int base, int fw)
|
||||
{
|
||||
int i, c, result = 0;
|
||||
|
||||
|
@ -181,18 +179,14 @@ convert(f, base, fw)
|
|||
}
|
||||
|
||||
static void
|
||||
ustarfs_sscanf(s,f,xi)
|
||||
const char *s,*f;
|
||||
int *xi;
|
||||
ustarfs_sscanf(const char *s, const char *f, int *xi)
|
||||
{
|
||||
|
||||
*xi = convert(s, 8, convert(f + 1, 10, 99));
|
||||
}
|
||||
|
||||
static int
|
||||
ustarfs_cylinder_read(f, seek2, forcelabel)
|
||||
struct open_file *f;
|
||||
ustoffs seek2;
|
||||
int forcelabel;
|
||||
ustarfs_cylinder_read(struct open_file *f, ustoffs seek2, int forcelabel)
|
||||
{
|
||||
int i, e;
|
||||
|
||||
|
@ -205,17 +199,14 @@ ustarfs_cylinder_read(f, seek2, forcelabel)
|
|||
}
|
||||
|
||||
static int
|
||||
real_fs_cylinder_read(f, seek2, forcelabel)
|
||||
struct open_file *f;
|
||||
ustoffs seek2;
|
||||
int forcelabel;
|
||||
real_fs_cylinder_read(struct open_file *f, ustoffs seek2, int forcelabel)
|
||||
{
|
||||
int i;
|
||||
int e = 0; /* XXX work around gcc warning */
|
||||
ustoffs lda;
|
||||
char *xferbase;
|
||||
ust_active_t *ustf;
|
||||
size_t xferrqst, xfercount;
|
||||
size_t xferrqst, xfercount;
|
||||
|
||||
ustf = f->f_fsdata;
|
||||
xferrqst = sizeof ustf->uas_1cyl;
|
||||
|
@ -234,8 +225,9 @@ real_fs_cylinder_read(f, seek2, forcelabel)
|
|||
xferbase += lda;
|
||||
seek2 += lda;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
ustf->uas_offset = 0;
|
||||
}
|
||||
while(xferrqst > 0) {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
|
@ -260,8 +252,7 @@ real_fs_cylinder_read(f, seek2, forcelabel)
|
|||
}
|
||||
|
||||
static int
|
||||
checksig(ustf)
|
||||
ust_active_t *ustf;
|
||||
checksig(ust_active_t *ustf)
|
||||
{
|
||||
int i, rcs;
|
||||
|
||||
|
@ -271,9 +262,7 @@ checksig(ustf)
|
|||
}
|
||||
|
||||
static int
|
||||
get_volume(f, vn)
|
||||
struct open_file *f;
|
||||
int vn;
|
||||
get_volume(struct open_file *f, int vn)
|
||||
{
|
||||
int e, needvolume, havevolume;
|
||||
ust_active_t *ustf;
|
||||
|
@ -321,16 +310,13 @@ static void
|
|||
setwindow(ust_active_t *ustf, ustoffs pda, ustoffs vda)
|
||||
{
|
||||
ustf->uas_windowbase = lda2vda(pda2lda(pda), ustf->uas_volsize,
|
||||
vda2vn(vda, ustf->uas_volsize))
|
||||
+ ustf->uas_offset;
|
||||
vda2vn(vda, ustf->uas_volsize))
|
||||
+ ustf->uas_offset;
|
||||
ustf->uas_init_window = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
read512block(f, vda, block)
|
||||
struct open_file *f;
|
||||
ustoffs vda;
|
||||
char block[512];
|
||||
read512block(struct open_file *f, ustoffs vda, char block[512])
|
||||
{
|
||||
ustoffs pda;
|
||||
ssize_t e;
|
||||
|
@ -379,8 +365,7 @@ tryagain:
|
|||
}
|
||||
|
||||
static int
|
||||
init_volzero_sig(f)
|
||||
struct open_file *f;
|
||||
init_volzero_sig(struct open_file *f)
|
||||
{
|
||||
int e;
|
||||
ust_active_t *ustf;
|
||||
|
@ -397,10 +382,7 @@ init_volzero_sig(f)
|
|||
}
|
||||
|
||||
int
|
||||
ustarfs_open(path, f)
|
||||
const char *path;
|
||||
struct open_file *f;
|
||||
|
||||
ustarfs_open(const char *path, struct open_file *f)
|
||||
{
|
||||
ust_active_t *ustf;
|
||||
ustoffs offset;
|
||||
|
@ -461,37 +443,31 @@ ustarfs_open(path, f)
|
|||
|
||||
#ifndef LIBSA_NO_FS_WRITE
|
||||
int
|
||||
ustarfs_write(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
void *start;
|
||||
size_t size;
|
||||
size_t *resid;
|
||||
ustarfs_write(struct open_file *f, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
return (EROFS);
|
||||
|
||||
return EROFS;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_WRITE */
|
||||
|
||||
#ifndef LIBSA_NO_FS_SEEK
|
||||
off_t
|
||||
ustarfs_seek(f, offs, whence)
|
||||
struct open_file *f;
|
||||
off_t offs;
|
||||
int whence;
|
||||
ustarfs_seek(struct open_file *f, off_t offs, int whence)
|
||||
{
|
||||
ust_active_t *ustf;
|
||||
|
||||
ustf = f->f_fsdata;
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
case SEEK_SET:
|
||||
ustf->uas_fseek = offs;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
case SEEK_CUR:
|
||||
ustf->uas_fseek += offs;
|
||||
break;
|
||||
case SEEK_END:
|
||||
case SEEK_END:
|
||||
ustf->uas_fseek = ustf->uas_filesize - offs;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return ustf->uas_fseek;
|
||||
|
@ -499,21 +475,17 @@ ustarfs_seek(f, offs, whence)
|
|||
#endif /* !LIBSA_NO_FS_SEEK */
|
||||
|
||||
int
|
||||
ustarfs_read(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
void *start;
|
||||
size_t size;
|
||||
size_t *resid;
|
||||
ustarfs_read(struct open_file *f, void *start, size_t size, size_t *resid)
|
||||
{
|
||||
ust_active_t *ustf;
|
||||
int e;
|
||||
char *space512;
|
||||
int blkoffs,
|
||||
readoffs,
|
||||
bufferoffset;
|
||||
int blkoffs;
|
||||
int readoffs;
|
||||
int bufferoffset;
|
||||
size_t seg;
|
||||
size_t infile,
|
||||
inbuffer;
|
||||
size_t infile;
|
||||
size_t inbuffer;
|
||||
|
||||
e = 0;
|
||||
space512 = alloc(512);
|
||||
|
@ -537,7 +509,7 @@ ustarfs_read(f, start, size, resid)
|
|||
memcpy(start, space512 + bufferoffset, seg);
|
||||
ustf->uas_fseek += seg;
|
||||
start = (char *)start + seg;
|
||||
size -= seg;
|
||||
size -= seg;
|
||||
}
|
||||
if (resid)
|
||||
*resid = size;
|
||||
|
@ -546,9 +518,7 @@ ustarfs_read(f, start, size, resid)
|
|||
}
|
||||
|
||||
int
|
||||
ustarfs_stat(f, sb)
|
||||
struct open_file *f;
|
||||
struct stat *sb;
|
||||
ustarfs_stat(struct open_file *f, struct stat *sb)
|
||||
{
|
||||
int mode, uid, gid;
|
||||
ust_active_t *ustf;
|
||||
|
@ -569,8 +539,7 @@ ustarfs_stat(f, sb)
|
|||
|
||||
#ifndef LIBSA_NO_FS_CLOSE
|
||||
int
|
||||
ustarfs_close(f)
|
||||
struct open_file *f;
|
||||
ustarfs_close(struct open_file *f)
|
||||
{
|
||||
if (f == NULL || f->f_fsdata == NULL)
|
||||
return EINVAL;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vsprintf.c,v 1.3 2005/12/11 12:24:46 christos Exp $ */
|
||||
/* $NetBSD: vsprintf.c,v 1.4 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -45,5 +45,5 @@ int
|
|||
vsprintf(char *buf, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
return (vsnprintf(buf, -(size_t)buf, fmt, ap));
|
||||
return vsnprintf(buf, -(size_t)buf, fmt, ap);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: write.c,v 1.13 2006/01/13 22:32:10 christos Exp $ */
|
||||
/* $NetBSD: write.c,v 1.14 2007/11/24 13:20:58 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -64,10 +64,7 @@
|
|||
#include "stand.h"
|
||||
|
||||
ssize_t
|
||||
write(fd, destp, bcount)
|
||||
int fd;
|
||||
const void *destp;
|
||||
size_t bcount;
|
||||
write(int fd, const void *destp, size_t bcount)
|
||||
{
|
||||
struct open_file *f = &files[fd];
|
||||
size_t resid;
|
||||
|
@ -76,7 +73,7 @@ write(fd, destp, bcount)
|
|||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
|
@ -87,13 +84,13 @@ write(fd, destp, bcount)
|
|||
errno = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_WRITE,
|
||||
btodb(f->f_offset), bcount, dest, &resid);
|
||||
if (errno)
|
||||
return (-1);
|
||||
return -1;
|
||||
f->f_offset += resid;
|
||||
return (resid);
|
||||
return resid;
|
||||
}
|
||||
#endif
|
||||
resid = bcount;
|
||||
if ((errno = FS_WRITE(f->f_ops)(f, dest, bcount, &resid)))
|
||||
return (-1);
|
||||
return (0);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue