summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2009-09-13 21:51:01 +0000
committeremaste <emaste@FreeBSD.org>2009-09-13 21:51:01 +0000
commit52033fa3cffa5bc28a7ddd5e50b30a5e5d1d18f8 (patch)
treeb46329b15326e015b14f2abd97a57ee0af87b11e
parent56f8b9c6d49014776c9d2568fcd367e405c6fafc (diff)
downloadFreeBSD-src-52033fa3cffa5bc28a7ddd5e50b30a5e5d1d18f8.zip
FreeBSD-src-52033fa3cffa5bc28a7ddd5e50b30a5e5d1d18f8.tar.gz
ANSIfy, whitespace and comment adjustments, to simplify comparing these
files with NetBSD / OpenBSD versions.
-rw-r--r--lib/libstand/net.c35
-rw-r--r--lib/libstand/nfs.c86
-rw-r--r--lib/libstand/rpc.c52
3 files changed, 65 insertions, 108 deletions
diff --git a/lib/libstand/net.c b/lib/libstand/net.c
index bfa690b..d417bfb 100644
--- a/lib/libstand/net.c
+++ b/lib/libstand/net.c
@@ -68,14 +68,11 @@ __FBSDID("$FreeBSD$");
* 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;
@@ -87,7 +84,8 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
#endif
tmo = MINTMO;
- tlast = tleft = 0;
+ tlast = 0;
+ tleft = 0;
t = getsecs();
for (;;) {
if (tleft <= 0) {
@@ -107,7 +105,8 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
if (cc == -1) {
/* Error on transmit; wait before retrying */
- while ((getsecs() - t) < tmo);
+ while ((getsecs() - t) < tmo)
+ ;
tleft = 0;
continue;
}
@@ -133,8 +132,7 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
* Return values are in network order.
*/
n_long
-inet_addr(cp)
- char *cp;
+inet_addr(char *cp)
{
u_long val;
int n;
@@ -211,16 +209,14 @@ inet_addr(cp)
}
char *
-inet_ntoa(ia)
- struct in_addr ia;
+inet_ntoa(struct in_addr ia)
{
return (intoa(ia.s_addr));
}
/* Similar to inet_ntoa() */
char *
-intoa(addr)
- n_long addr;
+intoa(n_long addr)
{
char *cp;
u_int byte;
@@ -250,9 +246,7 @@ intoa(addr)
}
static char *
-number(s, n)
- char *s;
- int *n;
+number(char *s, int *n)
{
for (*n = 0; isdigit(*s); s++)
*n = (*n * 10) + *s - '0';
@@ -260,8 +254,7 @@ number(s, n)
}
n_long
-ip_convertaddr(p)
- char *p;
+ip_convertaddr(char *p)
{
#define IP_ANYADDR 0
n_long addr = 0, n;
diff --git a/lib/libstand/nfs.c b/lib/libstand/nfs.c
index a2d19c5..4859449 100644
--- a/lib/libstand/nfs.c
+++ b/lib/libstand/nfs.c
@@ -3,7 +3,7 @@
/*-
* Copyright (c) 1993 John Brezak
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,7 +14,7 @@
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -147,10 +147,7 @@ struct fs_ops nfs_fsops = {
* Return zero or error number.
*/
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 {
@@ -170,7 +167,7 @@ nfs_getrootfh(d, path, fhp)
struct repl d;
} rdata;
size_t cc;
-
+
#ifdef NFS_DEBUG
if (debug)
printf("nfs_getrootfh: %s\n", path);
@@ -206,10 +203,7 @@ nfs_getrootfh(d, path, fhp)
* Return zero or error number.
*/
int
-nfs_lookupfh(d, name, newfd)
- struct nfs_iodesc *d;
- const char *name;
- struct nfs_iodesc *newfd;
+nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
{
int len, rlen;
struct args {
@@ -231,7 +225,7 @@ nfs_lookupfh(d, name, newfd)
struct repl d;
} rdata;
ssize_t cc;
-
+
#ifdef NFS_DEBUG
if (debug)
printf("lookupfh: called\n");
@@ -272,9 +266,7 @@ nfs_lookupfh(d, name, 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];
@@ -300,7 +292,7 @@ nfs_readlink(d, buf)
if (cc < 4)
return (EIO);
-
+
if (rdata.d.errno)
return (ntohl(rdata.d.errno));
@@ -319,11 +311,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;
@@ -381,9 +369,7 @@ nfs_readdata(d, off, addr, len)
* return zero or error number
*/
int
-nfs_open(upath, f)
- const char *upath;
- struct open_file *f;
+nfs_open(const char *upath, struct open_file *f)
{
struct iodesc *desc;
struct nfs_iodesc *currfd;
@@ -475,18 +461,18 @@ nfs_open(upath, f)
error = ENOTDIR;
goto out;
}
-
+
/* allocate file system specific data structure */
newfd = malloc(sizeof(*newfd));
newfd->iodesc = currfd->iodesc;
newfd->off = 0;
-
+
/*
* Get next component of path name.
*/
{
int len = 0;
-
+
ncp = cp;
while ((c = *cp) != '\0' && c != '/') {
if (++len > NFS_MAXNAMLEN) {
@@ -497,19 +483,19 @@ nfs_open(upath, f)
}
*cp = '\0';
}
-
+
/* lookup a file handle */
error = nfs_lookupfh(currfd, ncp, newfd);
*cp = c;
if (error)
goto out;
-
+
/*
* Check for symbolic link
*/
if (newfd->fa.fa_type == htonl(NFLNK)) {
int link_len, len;
-
+
error = nfs_readlink(newfd, linkbuf);
if (error)
goto out;
@@ -525,7 +511,7 @@ nfs_open(upath, f)
bcopy(cp, &namebuf[link_len], len + 1);
bcopy(linkbuf, namebuf, link_len);
-
+
/*
* If absolute pathname, restart at root.
* If relative pathname, restart at parent directory.
@@ -539,10 +525,10 @@ nfs_open(upath, f)
free(newfd);
newfd = 0;
-
+
continue;
}
-
+
if (currfd != &nfs_root_node)
free(currfd);
currfd = newfd;
@@ -568,7 +554,7 @@ out:
f->f_fsdata = (void *)currfd;
return (0);
}
-
+
#ifdef NFS_DEBUG
if (debug)
printf("nfs_open: %s lookupfh failed: %s\n",
@@ -583,8 +569,7 @@ out:
}
int
-nfs_close(f)
- struct open_file *f;
+nfs_close(struct open_file *f)
{
struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
@@ -596,7 +581,7 @@ nfs_close(f)
if (fp != &nfs_root_node && fp)
free(fp);
f->f_fsdata = (void *)0;
-
+
return (0);
}
@@ -604,16 +589,12 @@ nfs_close(f)
* 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;
char *addr = buf;
-
+
#ifdef NFS_DEBUG
if (debug)
printf("nfs_read: size=%lu off=%d\n", (u_long)size,
@@ -652,20 +633,13 @@ ret:
* 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);
}
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);
@@ -693,9 +667,7 @@ 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;
@@ -724,7 +696,7 @@ nfs_readdir(struct open_file *f, struct dirent *d)
static n_long cookie = 0;
size_t cc;
n_long eof;
-
+
struct {
n_long h[RPC_HEADER_WORDS];
struct nfs_readdir_args d;
@@ -742,7 +714,7 @@ nfs_readdir(struct open_file *f, struct dirent *d)
bcopy(fp->fh, args->fh, NFS_FHSIZE);
args->cookie = htonl(cookie);
args->count = htonl(NFS_READDIRSIZE);
-
+
cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READDIR,
args, sizeof(*args),
rdata.d, sizeof(rdata.d));
diff --git a/lib/libstand/rpc.c b/lib/libstand/rpc.c
index 49ddb9d..ee155f6 100644
--- a/lib/libstand/rpc.c
+++ b/lib/libstand/rpc.c
@@ -108,13 +108,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;
@@ -232,11 +227,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;
@@ -288,10 +279,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 */
@@ -324,12 +312,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;
@@ -343,12 +334,15 @@ rpc_pmap_getcache(addr, prog, vers)
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;
@@ -375,12 +369,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 */
OpenPOWER on IntegriCloud