From 51fec467c4b771db8ffc6a10a07dbf781a905482 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann <marcus@gnu.org> Date: Tue, 30 Jan 2001 00:38:45 +0000 Subject: 2000-12-26 Neal H Walfield <neal@cs.uml.edu> * cache.c: Change cache/hash table size to 509, a prime. Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and check the result of rpc transaction _and_ do not act if failed. * main.c: Correct the wording of the help messages. Do not bother initializing global variable to 0. Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and check the result of rpc transaction _and_ do not act if failed. * mount.c: Check return values of initialize_rpc. Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and strdup. Correct comments. (mount_root): Check result of connect. Handle errors consistently. Reverse loops that are if (! c) {} else when appropriate. * mount.h: Protect header with #ifdef. * name-cache.c: Correct dangerous NPARTIALS macro. Use memcpy/memcmp not bcopy/bcmp. (find_cache): Use PARTIAL_THRESH, not the constant. * nfs-spec.h: Protect header with #ifdef. * nfs.c: Use memcpy/memcmp not bcopy/bcmp. * nfs.h: Likewise. * ops.c (netfs_attempt_mkdir): Check return values of initialize_rpc. Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and check the result of rpc transaction _and_ do not act if failed. (netfs_attempt_link): Unlock the directory before the rpc transaction. Check the result of rpc transaction _and_ do not act if failed. * pager.c: Remove, we do not use it. * rpc.c: Use memcpy/memcmp not bcopy/bcmp. Verify return value from malloc and check the result of rpc transaction _and_ do not act if failed. (initialize_rpc): Use AUTH_NONE, not the depreciated AUTH_NULL. Return sane values on failure. (generate_xid): Make inline. (link_rpc): New function. Complements unlink_rpc. (conduct_rpc): Use link_rpc. (rpc_receive_thread): Reroll to a single loop. --- nfs/name-cache.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'nfs/name-cache.c') diff --git a/nfs/name-cache.c b/nfs/name-cache.c index bc5babe6..845cda30 100644 --- a/nfs/name-cache.c +++ b/nfs/name-cache.c @@ -24,7 +24,7 @@ #include <cacheq.h> -/* Maximum number of names to cache at once */ +/* Maximum number of names to cache at any given time */ #define MAXCACHE 200 /* Maximum length of file name we bother caching */ @@ -73,7 +73,7 @@ static struct stats } statistics; #define PARTIAL_THRESH 100 -#define NPARTIALS MAXCACHE / PARTIAL_THRESH +#define NPARTIALS (MAXCACHE / PARTIAL_THRESH) struct stats partial_stats [NPARTIALS]; @@ -93,19 +93,19 @@ find_cache (char *dir, size_t len, const char *name, size_t name_len) if (c->name_len == name_len && c->dir_cache_len == len && c->name[0] == name[0] - && bcmp (c->dir_cache_fh, dir, len) == 0 + && memcmp (c->dir_cache_fh, dir, len) == 0 && strcmp (c->name, name) == 0) { - c->stati = i / 100; + c->stati = i / PARTIAL_THRESH; return c; } return 0; } -/* Node NP has just been found in DIR with NAME. If NP is null, that - means that this name has been confirmed as absent in the directory. - DIR is the fhandle of the directory; its length is LEN. */ +/* Node NP has just been found in DIR with NAME. If NP is null, this + name has been confirmed as absent in the directory. DIR is the + fhandle of the directory and LEN is its length. */ void enter_lookup_cache (char *dir, size_t len, struct node *np, char *name) { @@ -127,7 +127,7 @@ enter_lookup_cache (char *dir, size_t len, struct node *np, char *name) c = find_cache (dir, len, name, name_len) ?: lookup_cache.lru; /* Fill C with the new entry. */ - bcopy (dir, c->dir_cache_fh, len); + memcpy (c->dir_cache_fh, dir, len); c->dir_cache_len = len; if (c->np) netfs_nrele (c->np); @@ -158,7 +158,8 @@ purge_lookup_cache (struct node *dp, char *name, size_t namelen) if (c->name_len == namelen && c->dir_cache_len == dp->nn->handle.size - && bcmp (c->dir_cache_fh, dp->nn->handle.data, c->dir_cache_len) == 0 + && memcmp (c->dir_cache_fh, dp->nn->handle.data, + c->dir_cache_len) == 0 && strcmp (c->name, name) == 0) { if (c->np) @@ -237,11 +238,12 @@ register_miss () -/* Scan the cache looking for NAME inside DIR. If we don't know - anything entry at all, then return 0. If the entry is confirmed to - not exist, then return -1. Otherwise, return NP for the entry, with - a newly allocated reference. For any return value but 0, unlock - DP before returning. */ +/* Scan the cache looking for NAME inside DIR. If we know nothing + about the entry, then return 0. If the entry is confirmed to not + exist, then return -1. Otherwise, return NP for the entry, with + a newly allocated reference. For all return values other than 0, + unlock DIR->LOCK before returning. For positive hits, lock the + returned node. */ struct node * check_lookup_cache (struct node *dir, char *name) { -- cgit v1.2.3