X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fuse%2Fdircache.c;h=8cff0d39207da724d5258467f0803684e70b876b;hb=79f5720d2ccab820c90b7516f3fbf5e3dcbe9c8f;hp=545b9f3854ec7d2d00e3ec8d9630c0711185f524;hpb=429de2254176e470035eef05e0f3e9910d46863c;p=libguestfs.git diff --git a/fuse/dircache.c b/fuse/dircache.c index 545b9f3..8cff0d3 100644 --- a/fuse/dircache.c +++ b/fuse/dircache.c @@ -37,17 +37,9 @@ #include "hash.h" #include "hash-pjw.h" +#include "guestmount.h" #include "dircache.h" -extern int verbose; -extern int dir_cache_timeout; - -static inline char * -bad_cast (char const *s) -{ - return (char *) s; -} - /* Note on attribute caching: FUSE can cache filesystem attributes for * short periods of time (configurable via -o attr_timeout). It * doesn't cache xattrs, and in any case FUSE caching doesn't solve @@ -100,7 +92,7 @@ gen_compare (void const *x, void const *y) { struct lsc_entry const *a = x; struct lsc_entry const *b = y; - return strcmp (a->pathname, b->pathname) == 0; + return STREQ (a->pathname, b->pathname); } static void @@ -146,7 +138,7 @@ init_dir_caches (void) rlc_ht = hash_initialize (1024, NULL, gen_hash, gen_compare, rlc_free); if (!lsc_ht || !xac_ht || !rlc_ht) { fprintf (stderr, "guestmount: could not initialize dir cache hashtables\n"); - exit (1); + exit (EXIT_FAILURE); } } @@ -250,7 +242,7 @@ lsc_insert (const char *path, const char *name, time_t now, free (entry); return -1; } - if (strcmp (path, "/") == 0) + if (STREQ (path, "/")) snprintf (entry->pathname, len, "/%s", name); else snprintf (entry->pathname, len, "%s/%s", path, name); @@ -285,7 +277,7 @@ xac_insert (const char *path, const char *name, time_t now, free (entry); return -1; } - if (strcmp (path, "/") == 0) + if (STREQ (path, "/")) snprintf (entry->pathname, len, "/%s", name); else snprintf (entry->pathname, len, "%s/%s", path, name); @@ -320,7 +312,7 @@ rlc_insert (const char *path, const char *name, time_t now, free (entry); return -1; } - if (strcmp (path, "/") == 0) + if (STREQ (path, "/")) snprintf (entry->pathname, len, "/%s", name); else snprintf (entry->pathname, len, "%s/%s", path, name); @@ -392,7 +384,7 @@ lsc_remove (Hash_table *ht, const char *pathname, Hash_data_freer freer) entry = hash_delete (ht, &key); - if (verbose) + if (verbose && entry) fprintf (stderr, "dir cache: invalidating entry %p (%s)\n", entry, entry->pathname);