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 | |
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')
-rw-r--r-- | nfsd/ChangeLog | 22 | ||||
-rw-r--r-- | nfsd/cache.c | 92 | ||||
-rw-r--r-- | nfsd/loop.c | 119 | ||||
-rw-r--r-- | nfsd/ops.c | 115 | ||||
-rw-r--r-- | nfsd/xdr.c | 80 |
5 files changed, 241 insertions, 187 deletions
diff --git a/nfsd/ChangeLog b/nfsd/ChangeLog index 1a78f994..7d89361b 100644 --- a/nfsd/ChangeLog +++ b/nfsd/ChangeLog @@ -1,3 +1,25 @@ +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. + 2002-05-29 Roland McGrath <roland@frob.com> * nfsd.h (struct proctable): [0] -> [], for newfangled GCC. diff --git a/nfsd/cache.c b/nfsd/cache.c index d4988b53..7b96dbc2 100644 --- a/nfsd/cache.c +++ b/nfsd/cache.c @@ -1,4 +1,4 @@ -/* +/* cache.c - Cache operations for the nfs daemon. Copyright (C) 1996,98,99,2000,02 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. @@ -46,9 +46,9 @@ spin_lock_t idhashlock = SPIN_LOCK_INITIALIZER; static int nfreeids; static int leastidlastuse; -/* Compare I against the specified set of users/groups. */ +/* Compare I against the specified set of users/groups. */ /* Use of int in decl of UIDS and GIDS is correct here; that's - the NFS type because they come in in known 32 bit slots. */ + the NFS type because they come in in known 32 bit slots. */ static int idspec_compare (struct idspec *i, int nuids, int ngids, int *uids, int *gids) @@ -66,7 +66,7 @@ idspec_compare (struct idspec *i, int nuids, int ngids, return 1; } -/* Compute a hash value for a given user spec */ +/* Compute a hash value for a given user spec. */ static int idspec_hash (int nuids, int ngids, int *uids, int *gids) { @@ -81,7 +81,7 @@ idspec_hash (int nuids, int ngids, int *uids, int *gids) return hash; } -/* Lookup a user spec in the hash table and allocate a reference */ +/* Lookup a user spec in the hash table and allocate a reference. */ static struct idspec * idspec_lookup (int nuids, int ngids, int *uids, int *gids) { @@ -107,8 +107,8 @@ idspec_lookup (int nuids, int ngids, int *uids, int *gids) i->ngids = ngids; i->uids = malloc (nuids * sizeof (uid_t)); i->gids = malloc (ngids * sizeof (gid_t)); - bcopy (uids, i->uids, nuids * sizeof (uid_t)); - bcopy (gids, i->gids, ngids * sizeof (gid_t)); + memcpy (i->uids, uids, nuids * sizeof (uid_t)); + memcpy (i->gids, gids, ngids * sizeof (gid_t)); i->references = 1; i->next = idhashtable[hash]; @@ -132,33 +132,38 @@ process_cred (int *p, struct idspec **credp) int firstgid; int i; - type = ntohl (*p++); + type = ntohl (*p); + p++; if (type != AUTH_UNIX) { - int size = ntohl (*p++); + int size = ntohl (*p); + p++; *credp = idspec_lookup (0, 0, 0, 0); p += INTSIZE (size); } else { - p++; /* skip size */ - p++; /* skip seconds */ - len = ntohl (*p++); - p += INTSIZE (len); /* skip hostname */ + p++; /* Skip size. */ + p++; /* Skip seconds. */ + len = ntohl (*p); + p++; + p += INTSIZE (len); /* Skip hostname. */ - uid = p++; /* remember loc of uid */ + uid = p++; /* Remember location of uid. */ *uid = ntohl (*uid); - firstgid = *p++; /* remember first gid */ - gids = p; /* here's where the array will start */ - ngids = ntohl (*p++); + firstgid = *(p++); /* Remember first gid. */ + gids = p; /* Here is where the array will start. */ + ngids = ntohl (*p); + p++; - /* Now swap the first gid to be the first element of the array */ + /* Now swap the first gid to be the first element of the + array. */ *gids = firstgid; - ngids++; /* and count it */ + ngids++; /* And count it. */ - /* And byteswap the gids */ + /* And byteswap the gids. */ for (i = 0; i < ngids; i++) gids[i] = ntohl (gids[i]); @@ -167,9 +172,10 @@ process_cred (int *p, struct idspec **credp) *credp = idspec_lookup (1, ngids, uid, gids); } - /* Next is the verf field; skip it entirely */ - p++; /* skip id */ - len = htonl (*p++); + /* Next is the verf field; skip it entirely. */ + p++; /* Skip ID. */ + len = htonl (*p); + p++; p += INTSIZE (len); return p; @@ -235,7 +241,7 @@ scan_creds () } } - /* If we didn't bail early, then this is valid */ + /* If we didn't bail early, then this is valid. */ if (nfreeids) leastidlastuse = newleast; } @@ -281,9 +287,9 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i) return p + NFS2_FHSIZE / sizeof (int); } - /* Not found */ + /* Not found. */ - /* First four bytes are our internal table of filesystems */ + /* First four bytes are our internal table of filesystems. */ fsys = lookup_filesystem (*p); if (fsys == MACH_PORT_NULL || fsys_getfile (fsys, i->uids, i->nuids, i->gids, i->ngids, @@ -295,7 +301,7 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i) } c = malloc (sizeof (struct cache_handle)); - bcopy (p, c->handle, NFS2_FHSIZE); + memcpy (c->handle, p, NFS2_FHSIZE); cred_ref (i); c->ids = i; c->port = port; @@ -363,7 +369,7 @@ scan_fhs () } } - /* If we didn't bail early, then this is valid. */ + /* If we didn't bail early, then this is valid. */ if (nfreefh) leastfhlastuse = newleast; } @@ -381,22 +387,22 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport) size_t handlelen = NFS2_FHSIZE - sizeof (int); mach_port_t newport, ref; - /* Authenticate USERPORT so that we can call file_getfh on it. */ + /* Authenticate USERPORT so that we can call file_getfh on it. */ ref = mach_reply_port (); - /* MAKE_SEND is safe becaue we destroy REF ourselves. */ + /* MAKE_SEND is safe becaue we destroy REF ourselves. */ if (io_reauthenticate (userport, ref, MACH_MSG_TYPE_MAKE_SEND) || auth_user_authenticate (authserver, ref, MACH_MSG_TYPE_MAKE_SEND, &newport)) { /* Reauthentication has failed, but maybe the filesystem will let - us call file_getfh anyway. */ + us call file_getfh anyway. */ newport = userport; } else mach_port_deallocate (mach_task_self (), userport); mach_port_destroy (mach_task_self (), ref); - /* Fetch the file handle */ + /* Fetch the file handle. */ *(int *)fhandle = fs; err = file_getfh (newport, &bp, &handlelen); mach_port_deallocate (mach_task_self (), newport); @@ -404,17 +410,17 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport) return 0; if (bp != fhandle + sizeof (int)) { - bcopy (bp, fhandle + sizeof (int), NFS2_FHSIZE - sizeof (int)); + memcpy (fhandle + sizeof (int), bp, NFS2_FHSIZE - sizeof (int)); munmap (bp, handlelen); } - /* Cache it */ + /* Cache it. */ hash = fh_hash (fhandle, credc->ids); mutex_lock (&fhhashlock); for (c = fhhashtable[hash]; c; c = c->next) if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS2_FHSIZE)) { - /* Return this one */ + /* Return this one. */ if (c->references == 0) nfreefh--; c->references++; @@ -423,7 +429,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport) } /* Always call fsys_getfile so that we don't depend on the - particular open modes of the port passed in. */ + particular open modes of the port passed in. */ err = fsys_getfile (lookup_filesystem (fs), credc->ids->uids, credc->ids->nuids, @@ -436,15 +442,15 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport) return 0; } - /* Create it anew */ + /* Create it anew. */ c = malloc (sizeof (struct cache_handle)); - bcopy (fhandle, c->handle, NFS2_FHSIZE); + memcpy (c->handle, fhandle, NFS2_FHSIZE); cred_ref (credc->ids); c->ids = credc->ids; c->port = newport; c->references = 1; - /* And add it to the hash table */ + /* And add it to the hash table. */ c->next = fhhashtable[hash]; if (c->next) c->next->prevp = &c->next; @@ -464,7 +470,7 @@ static int leastreplylastuse; /* Check the list of cached replies to see if this is a replay of a previous transaction; if so, return the cache record. Otherwise, - create a new cache record. */ + create a new cache record. */ struct cached_reply * check_cached_replies (int xid, struct sockaddr_in *sender) @@ -490,7 +496,7 @@ check_cached_replies (int xid, cr = malloc (sizeof (struct cached_reply)); mutex_init (&cr->lock); mutex_lock (&cr->lock); - bcopy (sender, &cr->source, sizeof (struct sockaddr_in)); + memcpy (&cr->source, sender, sizeof (struct sockaddr_in)); cr->xid = xid; cr->data = 0; cr->references = 1; @@ -506,7 +512,7 @@ check_cached_replies (int xid, } /* A cached reply returned by check_cached_replies is now no longer - needed by its caller. */ + needed by its caller. */ void release_cached_reply (struct cached_reply *cr) { @@ -559,7 +565,7 @@ scan_replies () } } - /* If we didn't bail early, then this is valid */ + /* If we didn't bail early, then this is valid. */ if (nfreereplies) leastreplylastuse = newleast; } 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); } } @@ -1,5 +1,5 @@ -/* NFS daemon protocol operations - Copyright (C) 1996, 2001 Free Software Foundation, Inc. +/* ops.c NFS daemon protocol operations. + Copyright (C) 1996, 2001, 2002 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -69,8 +69,10 @@ complete_setattr (mach_port_t port, if (err) return err; - uid = ntohl (*p++); - gid = ntohl (*p++); + uid = ntohl (*p); + p++; + gid = ntohl (*p); + p++; if (uid == -1) uid = st.st_uid; if (gid == -1) @@ -80,16 +82,21 @@ complete_setattr (mach_port_t port, if (err) return err; - size = ntohl (*p++); + size = ntohl (*p); + p++; if (size != -1 && size != st.st_size) err = file_set_size (port, size); if (err) return err; - atime.seconds = ntohl (*p++); - atime.microseconds = ntohl (*p++); - mtime.seconds = ntohl (*p++); - mtime.microseconds = ntohl (*p++); + atime.seconds = ntohl (*p); + p++; + atime.microseconds = ntohl (*p); + p++; + mtime.seconds = ntohl (*p); + p++; + mtime.microseconds = ntohl (*p); + p++; if (atime.seconds != -1 && atime.microseconds == -1) atime.microseconds = 0; @@ -124,7 +131,8 @@ op_setattr (struct cache_handle *c, mode_t mode; struct stat st; - mode = ntohl (*p++); + mode = ntohl (*p); + p++; if (mode != -1) err = file_chmod (c->port, mode); @@ -159,7 +167,7 @@ op_lookup (struct cache_handle *c, &newport); free (name); - /* Block attempts to bounce out of this filesystem by any technique */ + /* Block attempts to bounce out of this filesystem by any technique. */ if (!err && (do_retry != FS_RETRY_NORMAL || retry_name[0] != '\0')) @@ -189,7 +197,7 @@ op_readlink (struct cache_handle *c, mach_msg_type_number_t len = sizeof (buf); error_t err; - /* Shamelessly copied from the libc readlink */ + /* Shamelessly copied from the libc readlink. */ err = file_get_translator (c->port, &transp, &len); if (err) { @@ -215,7 +223,8 @@ op_readlink (struct cache_handle *c, static size_t count_read_buffersize (int *p, int version) { - return ntohl (*++p); /* skip OFFSET, return COUNT */ + p++; /* Skip OFFSET. */ + return ntohl (*p); /* Return COUNT. */ } static error_t @@ -231,8 +240,10 @@ op_read (struct cache_handle *c, struct stat st; error_t err; - offset = ntohl (*p++); - count = ntohl (*p++); + offset = ntohl (*p); + p++; + count = ntohl (*p); + p++; err = io_read (c->port, &bp, &buflen, offset, count); if (err) @@ -269,9 +280,11 @@ op_write (struct cache_handle *c, struct stat st; p++; - offset = ntohl (*p++); + offset = ntohl (*p); + p++; + p++; + count = ntohl (*p); p++; - count = ntohl (*p++); bp = (char *) *reply; while (count) @@ -313,7 +326,8 @@ op_create (struct cache_handle *c, off_t size; p = decode_name (p, &name); - mode = ntohl (*p++); + mode = ntohl (*p); + p++; err = dir_lookup (c->port, name, O_NOTRANS | O_CREAT | O_TRUNC, mode, &do_retry, retry_name, &newport); @@ -331,11 +345,12 @@ op_create (struct cache_handle *c, goto errout; /* NetBSD ignores most of the setattr fields given; that's good enough - for me too. */ + for me too. */ - p++, p++; /* skip uid and gid */ + p++, p++; /* Skip uid and gid. */ - size = ntohl (*p++); + size = ntohl (*p); + p++; if (size != -1 && size != st.st_size) { err = file_set_size (newport, size); @@ -344,7 +359,7 @@ op_create (struct cache_handle *c, if (err) goto errout; - /* ignore times */ + /* Ignore times. */ if (statchanged) err = io_stat (newport, &st); @@ -444,7 +459,8 @@ op_symlink (struct cache_handle *c, p = decode_name (p, &name); p = decode_name (p, &target); - mode = ntohl (*p++); + mode = ntohl (*p); + p++; if (mode == -1) mode = 0777; @@ -487,7 +503,8 @@ op_mkdir (struct cache_handle *c, error_t err; p = decode_name (p, &name); - mode = ntohl (*p++); + mode = ntohl (*p); + p++; err = dir_mkdir (c->port, name, mode); @@ -507,7 +524,7 @@ op_mkdir (struct cache_handle *c, if (err) return err; - /* Ignore the rest of the sattr structure */ + /* Ignore the rest of the sattr structure. */ if (!err) err = io_stat (newport, &st); @@ -555,8 +572,10 @@ op_readdir (struct cache_handle *c, int *replystart; int *r; - cookie = ntohl (*p++); - count = ntohl (*p++); + cookie = ntohl (*p); + p++; + count = ntohl (*p); + p++; buf = (char *) 0; bufsize = 0; @@ -572,8 +591,8 @@ op_readdir (struct cache_handle *c, if (nentries == 0) { - *r++ = htonl (0); /* no entry */ - *r++ = htonl (1); /* EOF */ + *(r++) = htonl (0); /* No entry. */ + *(r++) = htonl (1); /* EOF. */ } else { @@ -583,13 +602,13 @@ op_readdir (struct cache_handle *c, && (char *)reply < (char *)replystart + count); i++, dp = (struct dirent *) ((char *)dp + dp->d_reclen)) { - *r++ = htonl (1); /* entry present */ - *r++ = htonl (dp->d_ino); + *(r++) = htonl (1); /* Entry present. */ + *(r++) = htonl (dp->d_ino); r = encode_string (r, dp->d_name); - *r++ = htonl (i + cookie + 1); /* next entry */ + *(r++) = htonl (i + cookie + 1); /* Next entry. */ } - *r++ = htonl (0); /* no more entries */ - *r++ = htonl (0); /* not EOF */ + *(r++) = htonl (0); /* No more entries. */ + *(r++) = htonl (0); /* Not EOF. */ } *reply = r; @@ -603,7 +622,8 @@ op_readdir (struct cache_handle *c, static size_t count_readdir_buffersize (int *p, int version) { - return ntohl (*++p); /* skip COOKIE; return COUNT */ + p++; /* Skip COOKIE. */ + return ntohl (*p); /* Return COUNT. */ } static error_t @@ -656,9 +676,12 @@ op_getport (struct cache_handle *c, { int prog, vers, prot; - prog = ntohl (*p++); - vers = ntohl (*p++); - prot = ntohl (*p++); + prog = ntohl (*p); + p++; + vers = ntohl (*p); + p++; + prot = ntohl (*p); + p++; if (prot != IPPROTO_UDP) *(*reply)++ = htonl (0); @@ -676,17 +699,17 @@ op_getport (struct cache_handle *c, struct proctable nfs2table = { - NFS2PROC_NULL, /* first proc */ - NFS2PROC_STATFS, /* last proc */ + NFS2PROC_NULL, /* First proc. */ + NFS2PROC_STATFS, /* Last proc. */ { { op_null, 0, 0, 0}, { op_getattr, 0, 1, 1}, { op_setattr, 0, 1, 1}, - { 0, 0, 0, 0 }, /* deprecated NFSPROC_ROOT */ + { 0, 0, 0, 0 }, /* Deprecated NFSPROC_ROOT. */ { op_lookup, 0, 1, 1}, { op_readlink, 0, 1, 1}, { op_read, count_read_buffersize, 1, 1}, - { 0, 0, 0, 0 }, /* nonexistent NFSPROC_WRITECACHE */ + { 0, 0, 0, 0 }, /* Nonexistent NFSPROC_WRITECACHE. */ { op_write, 0, 1, 1}, { op_create, 0, 1, 1}, { op_remove, 0, 1, 1}, @@ -703,8 +726,8 @@ struct proctable nfs2table = struct proctable mounttable = { - MOUNTPROC_NULL, /* first proc */ - MOUNTPROC_EXPORT, /* last proc */ + MOUNTPROC_NULL, /* First proc. */ + MOUNTPROC_EXPORT, /* Last proc. */ { { op_null, 0, 0, 0}, { op_mnt, 0, 0, 1}, @@ -717,8 +740,8 @@ struct proctable mounttable = struct proctable pmaptable = { - PMAPPROC_NULL, /* first proc */ - PMAPPROC_CALLIT, /* last proc */ + PMAPPROC_NULL, /* First proc. */ + PMAPPROC_CALLIT, /* Last proc. */ { { op_null, 0, 0, 0}, { 0, 0, 0, 0}, /* PMAPPROC_SET */ @@ -1,5 +1,5 @@ -/* XDR packing and unpacking in nfsd - Copyright (C) 1996 Free Software Foundation, Inc. +/* xdr.c - XDR packing and unpacking in nfsd. + Copyright (C) 1996, 2002 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -23,7 +23,7 @@ #include <string.h> #include "nfsd.h" -/* Any better ideas? */ +/* Any better ideas? */ static int hurd_mode_to_nfs_mode (mode_t m) { @@ -61,83 +61,84 @@ hurd_mode_to_nfs_type (mode_t m, int version) } } -/* Encode ST into P and return the next thing to come after it. */ +/* Encode ST into P and return the next thing to come after it. */ int * encode_fattr (int *p, struct stat *st, int version) { - *p++ = htonl (hurd_mode_to_nfs_type (st->st_mode, version)); - *p++ = htonl (hurd_mode_to_nfs_mode (st->st_mode)); - *p++ = htonl (st->st_nlink); - *p++ = htonl (st->st_uid); - *p++ = htonl (st->st_gid); - *p++ = htonl (st->st_size); - *p++ = htonl (st->st_blksize); - *p++ = htonl (st->st_rdev); - *p++ = htonl (st->st_blocks); - *p++ = htonl (st->st_fsid); - *p++ = htonl (st->st_ino); - *p++ = htonl (st->st_atime); - *p++ = htonl (st->st_atime_usec); - *p++ = htonl (st->st_mtime); - *p++ = htonl (st->st_mtime_usec); - *p++ = htonl (st->st_ctime); - *p++ = htonl (st->st_ctime_usec); + *(p++) = htonl (hurd_mode_to_nfs_type (st->st_mode, version)); + *(p++) = htonl (hurd_mode_to_nfs_mode (st->st_mode)); + *(p++) = htonl (st->st_nlink); + *(p++) = htonl (st->st_uid); + *(p++) = htonl (st->st_gid); + *(p++) = htonl (st->st_size); + *(p++) = htonl (st->st_blksize); + *(p++) = htonl (st->st_rdev); + *(p++) = htonl (st->st_blocks); + *(p++) = htonl (st->st_fsid); + *(p++) = htonl (st->st_ino); + *(p++) = htonl (st->st_atime); + *(p++) = htonl (st->st_atime_usec); + *(p++) = htonl (st->st_mtime); + *(p++) = htonl (st->st_mtime_usec); + *(p++) = htonl (st->st_ctime); + *(p++) = htonl (st->st_ctime_usec); return p; } -/* Decode P into NAME and return the next thing to come after it. */ +/* Decode P into NAME and return the next thing to come after it. */ int * decode_name (int *p, char **name) { int len; - len = ntohl (*p++); + len = ntohl (*p); + p++; *name = malloc (len + 1); - bcopy (p, *name, len); + memcpy (*name, p, len); (*name)[len] = '\0'; return p + INTSIZE (len); } -/* Encode HANDLE into P and return the next thing to come after it. */ +/* Encode HANDLE into P and return the next thing to come after it. */ int * encode_fhandle (int *p, char *handle) { - bcopy (handle, p, NFS2_FHSIZE); + memcpy (p, handle, NFS2_FHSIZE); return p + INTSIZE (NFS2_FHSIZE); } -/* Encode STRING into P and return the next thing to come after it. */ +/* Encode STRING into P and return the next thing to come after it. */ int * encode_string (int *p, char *string) { return encode_data (p, string, strlen (string)); } -/* Encode DATA into P and return the next thing to come after it. */ +/* Encode DATA into P and return the next thing to come after it. */ int * encode_data (int *p, char *data, size_t len) { int nints = INTSIZE (len); p[nints] = 0; - *p++ = htonl (len); - bcopy (data, p, len); + *(p++) = htonl (len); + memcpy (p, data, len); return p + nints; } -/* Encode ST into P and return the next thing to come after it. */ +/* Encode ST into P and return the next thing to come after it. */ int * encode_statfs (int *p, struct statfs *st) { - *p++ = st->f_bsize; - *p++ = st->f_bsize; - *p++ = st->f_blocks; - *p++ = st->f_bfree; - *p++ = st->f_bavail; + *(p++) = st->f_bsize; + *(p++) = st->f_bsize; + *(p++) = st->f_blocks; + *(p++) = st->f_bfree; + *(p++) = st->f_bavail; return p; } -/* Return an NFS error corresponding to Hurd error ERR. */ +/* Return an NFS error corresponding to Hurd error ERR. */ int nfs_error_trans (error_t err, int version) { @@ -206,13 +207,10 @@ nfs_error_trans (error_t err, int version) return NFSERR_INVAL; case EOPNOTSUPP: - return NFSERR_NOTSUPP; /* are we sure here? */ + return NFSERR_NOTSUPP; /* Are we sure here? */ default: return NFSERR_IO; } } } - - - |