home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / sys / dnlc.h < prev    next >
Text File  |  1993-10-19  |  3KB  |  113 lines

  1. /* @(#)dnlc.h    1.1 87/08/26 3.2/4.3NFSSRC */
  2. /*    @(#)dnlc.h 1.1 86/09/25 SMI    */
  3.  
  4. /*
  5.  * Copyright (c) 1984 Sun Microsystems Inc.
  6.  */
  7. #import <sys/pathname.h>
  8.  
  9. /*
  10.  * This structure describes the elements in the cache of recent
  11.  * names looked up.
  12.  */
  13.  
  14. #if NeXT
  15. #define    NC_NAMLEN    32    /* maximum name segment length we bother with*/
  16. #else
  17. #define    NC_NAMLEN    15    /* maximum name segment length we bother with*/
  18. #endif
  19.  
  20. struct    ncache {
  21.     struct    ncache    *hash_next, *hash_prev;    /* hash chain, MUST BE FIRST */
  22.     struct     ncache    *lru_next, *lru_prev;    /* LRU chain */
  23.     struct    vnode    *vp;            /* vnode the name refers to */
  24.     struct    vnode    *dp;            /* vno of parent of name */
  25.     char        namlen;            /* length of name */
  26.     char        name[NC_NAMLEN];    /* segment name */
  27.     struct    ucred    *cred;            /* credentials */
  28. #if    NeXT
  29.     char        *symLink;        /* contents if a symbolic link */
  30.     char        symLinkValid;        /* TRUE if symLinkValue is valid */
  31.     short        symLinkLength;        /* length (excluding null) */
  32. #endif    NeXT
  33. };
  34.  
  35. #define    ANYCRED    ((struct ucred *) -1)
  36. #define    NOCRED    ((struct ucred *) 0)
  37.  
  38. #define    NC_HASH_SIZE        64    /* size of hash table */
  39.  
  40. #define    NC_HASH(namep, namlen, vp)    \
  41.     ((namep[0] + namep[namlen-1] + namlen + (int) vp) & (NC_HASH_SIZE-1))
  42.  
  43. /*
  44.  * Macros to insert, remove cache entries from hash, LRU lists.
  45.  */
  46. #define    INS_HASH(ncp,nch)    insque(ncp, nch)
  47. #define    RM_HASH(ncp)        remque(ncp)
  48.  
  49. #define    INS_LRU(ncp1,ncp2)    insque2((struct ncache *) ncp1, (struct ncache *) ncp2)
  50. #define    RM_LRU(ncp)        remque2((struct ncache *) ncp)
  51.  
  52. #define    NULL_HASH(ncp)        (ncp)->hash_next = (ncp)->hash_prev = (ncp)
  53.  
  54. /*
  55.  * Stats on usefulness of name cache.
  56.  */
  57. struct    ncstats {
  58.     int    hits;        /* hits that we can really use */
  59.     int    misses;        /* cache misses */
  60.     int    enters;        /* number of enters done */
  61.     int    dbl_enters;    /* number of enters tried when already cached */
  62.     int    long_enter;    /* long names tried to enter */
  63.     int    long_look;    /* long names tried to look up */
  64.     int    lru_empty;    /* LRU list empty */
  65.     int    purges;        /* number of purges of cache */
  66. #if    NeXT
  67.     int    valid_entries;    /* current number of valid entries */
  68. #endif    NeXT
  69. };
  70.  
  71. /*
  72.  * Hash list of name cache entries for fast lookup.
  73.  */
  74. struct    nc_hash    {
  75.     struct    ncache    *hash_next, *hash_prev;
  76. };
  77.  
  78. /*
  79.  * LRU list of cache entries for aging.
  80.  */
  81. struct    nc_lru    {
  82.     struct    ncache    *hash_next, *hash_prev;    /* hash chain, unused */
  83.     struct     ncache    *lru_next, *lru_prev;    /* LRU chain */
  84. };
  85.  
  86.  
  87. /*
  88.  *  Globals
  89.  *
  90.  *  ncsize is configuration dependent, and is set in conf/param.c
  91.  *  ncstats is used in ufs_inode.c to determine when to steal inodes from the cache
  92.  */
  93. extern int    ncsize;            /* static size of the cache */
  94. extern struct    ncache *ncache;        /* storage for all the cache entries */
  95. extern struct    ncstats ncstats;    /* cache effectiveness statistics */
  96. extern struct    nc_hash nc_hash[NC_HASH_SIZE];    /* headers for hash chains */
  97. extern struct    nc_lru nc_lru;            /* header for lru chain */
  98.  
  99. /*
  100.  *  Functions
  101.  */
  102. struct ncache *dnlc_search();
  103. int dnlc_rm(), insque2(), remque2();
  104. #if    NeXT
  105. struct ncache *dnlc_lookupSymLink(char *linkName, struct vnode *dvp);
  106. void dnlc_enterSymLink(char *linkName, struct vnode *dvp, struct pathname *pnp);
  107. #endif    NeXT
  108.  
  109.  
  110.  
  111.  
  112.  
  113.