diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-09-29 15:12:48 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-09-29 15:12:48 +0000 |
commit | a3f98f6fc2b76b39272250be3badabcf65fc23f1 (patch) | |
tree | c1a26b500de77c7be0872f92fd3aaedc6c01160d /nfsd/loop.c | |
parent | 5942bd6f73499f198b23975b8d7b8df1383934d8 (diff) |
2002-09-29 Marcus Brinkmann <marcus@gnu.org>
* loop.c (server_loop): Use memset instead bzero.
(server_loop): Add parenthesis for post-decrement (even
though it is only used as an lvalue here). Increment P after
using it in the macro, not within.
* ops.c (complete_setattr): Likewise.
(op_setattr, op_read, op_write, op_create, op_symlink, op_mkdir,
op_readdir, op_getport): Likewise.
* xdr.c (encode_fattr): Likewise.
(encode_data): Likewise. Also use memcpy instead bcopy.
(encode_statfs): Likewise.
(decode_name): Likewise. Also use memcpy instead bcopy.
(encode_fhandle): Use memcpy instead bcopy.
* cache.c (process_cred): Add parenthesis for post-decrement (even
though it is only used as an lvalue here). Increment P after
using it in the macro, not within.
(idspec_lookup): Use memcpy, not bcopy.
(lookup_cache_handle): Likewise.
(create_cached_handle): Likewise.
(check_cached_replies): Likewise.
Diffstat (limited to 'nfsd/loop.c')
-rw-r--r-- | nfsd/loop.c | 119 |
1 files changed, 62 insertions, 57 deletions
diff --git a/nfsd/loop.c b/nfsd/loop.c index 8f21b105..246e0ba8 100644 --- a/nfsd/loop.c +++ b/nfsd/loop.c @@ -1,4 +1,4 @@ -/* Main server loop for nfs server. +/* loop.c - Main server loop for nfs server. Copyright (C) 1996,98,2002 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. @@ -55,7 +55,7 @@ server_loop (int fd) socklen_t addrlen; int cc; - bzero (&fakec, sizeof (struct cache_handle)); + memset (&fakec, 0, sizeof (struct cache_handle)); for (;;) { @@ -64,33 +64,36 @@ server_loop (int fd) addrlen = sizeof (struct sockaddr_in); cc = recvfrom (fd, buf, MAXIOSIZE, 0, &sender, &addrlen); if (cc == -1) - continue; /* ignore errors */ - xid = *p++; + continue; /* Ignore errors. */ + xid = *(p++); - /* Ignore things that aren't proper RPCs. */ - if (ntohl (*p++) != CALL) + /* Ignore things that aren't proper RPCs. */ + if (ntohl (*p) != CALL) continue; + p++; cr = check_cached_replies (xid, &sender); if (cr->data) - /* This transacation has already completed */ + /* This transacation has already completed. */ goto repost_reply; r = (int *) rbuf = malloc (MAXIOSIZE); - if (ntohl (*p++) != RPC_MSG_VERSION) + if (ntohl (*p) != RPC_MSG_VERSION) { - /* Reject RPC */ - *r++ = xid; - *r++ = htonl (REPLY); - *r++ = htonl (MSG_DENIED); - *r++ = htonl (RPC_MISMATCH); - *r++ = htonl (RPC_MSG_VERSION); - *r++ = htonl (RPC_MSG_VERSION); + /* Reject RPC. */ + *(r++) = xid; + *(r++) = htonl (REPLY); + *(r++) = htonl (MSG_DENIED); + *(r++) = htonl (RPC_MISMATCH); + *(r++) = htonl (RPC_MSG_VERSION); + *(r++) = htonl (RPC_MSG_VERSION); goto send_reply; } + p++; - program = ntohl (*p++); + program = ntohl (*p); + p++; switch (program) { case MOUNTPROG: @@ -109,44 +112,46 @@ server_loop (int fd) break; default: - /* Program unavailable */ - *r++ = xid; - *r++ = htonl (REPLY); - *r++ = htonl (MSG_ACCEPTED); - *r++ = htonl (AUTH_NULL); - *r++ = htonl (0); - *r++ = htonl (PROG_UNAVAIL); + /* Program unavailable. */ + *(r++) = xid; + *(r++) = htonl (REPLY); + *(r++) = htonl (MSG_ACCEPTED); + *(r++) = htonl (AUTH_NULL); + *(r++) = htonl (0); + *(r++) = htonl (PROG_UNAVAIL); goto send_reply; } - if (ntohl (*p++) != version) + if (ntohl (*p) != version) { - /* Program mismatch */ - *r++ = xid; - *r++ = htonl (REPLY); - *r++ = htonl (MSG_ACCEPTED); - *r++ = htonl (AUTH_NULL); - *r++ = htonl (0); - *r++ = htonl (PROG_MISMATCH); - *r++ = htonl (version); - *r++ = htonl (version); + /* Program mismatch. */ + *(r++) = xid; + *(r++) = htonl (REPLY); + *(r++) = htonl (MSG_ACCEPTED); + *(r++) = htonl (AUTH_NULL); + *(r++) = htonl (0); + *(r++) = htonl (PROG_MISMATCH); + *(r++) = htonl (version); + *(r++) = htonl (version); goto send_reply; } + p++; - procedure = htonl (*p++); + procedure = htonl (*p); + p++; if (procedure < table->min || procedure > table->max || table->procs[procedure - table->min].func == 0) { - /* Procedure unavailable */ - *r++ = xid; - *r++ = htonl (REPLY); - *r++ = htonl (MSG_ACCEPTED); - *r++ = htonl (AUTH_NULL); - *r++ = htonl (0); - *r++ = htonl (PROC_UNAVAIL); - *r++ = htonl (table->min); - *r++ = htonl (table->max); + /* Procedure unavailable. */ + *(r++) = xid; + *(r++) = htonl (REPLY); + *(r++) = htonl (MSG_ACCEPTED); + *(r++) = htonl (AUTH_NULL); + *(r++) = htonl (0); + *(r++) = htonl (PROC_UNAVAIL); + *(r++) = htonl (table->min); + *(r++) = htonl (table->max); goto send_reply; } proc = &table->procs[procedure - table->min]; @@ -172,34 +177,34 @@ server_loop (int fd) } } - /* Fill in beginning of reply */ - *r++ = xid; - *r++ = htonl (REPLY); - *r++ = htonl (MSG_ACCEPTED); - *r++ = htonl (AUTH_NULL); - *r++ = htonl (0); - *r++ = htonl (SUCCESS); + /* Fill in beginning of reply. */ + *(r++) = xid; + *(r++) = htonl (REPLY); + *(r++) = htonl (MSG_ACCEPTED); + *(r++) = htonl (AUTH_NULL); + *(r++) = htonl (0); + *(r++) = htonl (SUCCESS); if (!proc->process_error) - /* The function does its own error processing, - and we ignore its return value. */ + /* The function does its own error processing, and we ignore + its return value. */ (void) (*proc->func) (c, p, &r, version); else { if (c) { - /* Assume success for now and patch it later if necessary */ + /* Assume success for now and patch it later if necessary. */ int *errloc = r; - *r++ = htonl (0); + *(r++) = htonl (0); /* Call processing function, its output after error code. */ err = (*proc->func) (c, p, &r, version); if (err) { r = errloc; /* Back up, patch error code, discard rest. */ - *r++ = htonl (nfs_error_trans (err, version)); + *(r++) = htonl (nfs_error_trans (err, version)); } } else - *r++ = htonl (nfs_error_trans (ESTALE, version)); + *(r++) = htonl (nfs_error_trans (ESTALE, version)); } cred_rele (cred); @@ -212,7 +217,7 @@ server_loop (int fd) repost_reply: sendto (fd, cr->data, cr->len, 0, - (struct sockaddr *)&sender, addrlen); + (struct sockaddr *) &sender, addrlen); release_cached_reply (cr); } } |