home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / n / tcpip / netkit-a.06 / netkit-a / NetKit-A-0.06 / nfs-server-2.0 / fh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-14  |  3.0 KB  |  104 lines

  1. /*
  2.  * fh.h        This module handles the file-handle cache.
  3.  *
  4.  * Authors:    Mark A. Shand, May 1988
  5.  *        Don Becker, <becker@super.org>
  6.  *        Rick Sladkey, <jrs@world.std.com>
  7.  *        Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  8.  *
  9.  *        Copyright 1988 Mark A. Shand
  10.  *        This software maybe be used for any purpose provided
  11.  *        the above copyright notice is retained.  It is supplied
  12.  *        as is, with no warranty expressed or implied.
  13.  */
  14.  
  15. /* Compatibility between mount and nfs_prot. */
  16. #ifndef NFS_FHSIZE
  17. #   define NFS_FHSIZE        FHSIZE
  18. #endif
  19.  
  20. #define    HP_LEN            (NFS_FHSIZE - sizeof(u_long))
  21.  
  22. #define    FHC_XONLY_PATH        01
  23. #define    FHC_BUSY        02    /* NOT USED */
  24. #define FHC_NFSMOUNTED        04
  25.  
  26. #define    CACHE_SIZE_LIMIT    500
  27. #define    LOWAT_CACHE_SIZE    3*CACHE_SIZE_LIMIT
  28. #define    HIWAT_CACHE_SIZE    4*CACHE_SIZE_LIMIT
  29. #define HASH_TAB_SIZE        (5*CACHE_SIZE_LIMIT | 03)
  30.  
  31. #define FD_CACHE_LIMIT        8
  32.  
  33. /* The following affect execute-only directories. */
  34. #define FLUSH_INTERVAL        (60*60*12)        /* Twice a day    */
  35. #define BUSY_RETRY_INTERVAL    (60*10)            /* Ten minutes    */
  36. #define DISCARD_INTERVAL    (FLUSH_INTERVAL*2)    /* Two days    */
  37.  
  38.  
  39. /*
  40.  * Hashed search path to this file.
  41.  * path is: hash_path[1] ... hash_path[hash_path[0]]
  42.  *
  43.  * hash_path[hash_path[0]+1] ... hash_path[HP_LEN-1] == 0
  44.  */
  45. typedef struct {
  46.   u_long    psi;
  47.   u_char    hash_path[HP_LEN];
  48. } svc_fh;
  49.  
  50. typedef enum { inactive, active } mutex;
  51.  
  52. /*
  53.  * Paths constructed in this system always consist of real directories
  54.  * (excepting the last element) i.e. they do not contain symbolic links.
  55.  * This is guaranteed by the way NFS constructs the paths.
  56.  * As a consequence we may assume that
  57.  *    /x/y/z/.. == /x/y
  58.  * and    /x/y/z/. == /x/y/z
  59.  * provided that z != . && z != ..
  60.  * These relations are exploited in fh_compose.
  61.  *
  62.  * Further assumptions:
  63.  *    All cached pathnames consist of a leading /
  64.  *    followed by zero or more / separated names
  65.  *    s.t.
  66.  *        name != .
  67.  *        name != ..
  68.  *        index(name, '/') == 0
  69.  */
  70. typedef struct fhcache {
  71.   struct fhcache    *next;
  72.   struct fhcache    *prev;
  73.   struct fhcache    *hash_next;
  74.   svc_fh        h;
  75.   int            fd;
  76.   int            omode;
  77.   char            *path;
  78.   time_t        last_used;
  79.   int            flags;
  80. } fhcache;
  81.  
  82. /* Global FH variables. */
  83. extern int _rpcpmstart;
  84. extern int fh_initialized;
  85.  
  86. /* Global function prototypes. */
  87. extern _PRO( enum nfsstat nfs_errno, (void)                );
  88. extern _PRO( int pseudo_inode, (u_long inode, u_short dev)        );
  89. extern _PRO( void fh_init, (void)                    );
  90. extern _PRO( char *fh_pr, (nfs_fh *fh)                    );
  91. extern _PRO( int fh_create, (nfs_fh *fh, char *path)            );
  92. extern _PRO( fhcache *fh_find, (svc_fh *h, int create)            );
  93. extern _PRO( char *fh_path, (nfs_fh *fh, nfsstat *status)        );
  94. extern _PRO( int path_open, (char *path, int omode, int perm)        );
  95. extern _PRO( int fh_fd, (nfs_fh *fh, nfsstat *status, int omode)    );
  96. extern _PRO( void fd_inactive, (int fd)                    );
  97. extern _PRO( nfsstat fh_compose, (diropargs *dopa, nfs_fh *new_fh,    \
  98.                   struct stat **sbpp, int fd, int omode));
  99. extern _PRO( int fh_psi, (nfs_fh *fh)                    );
  100. extern _PRO( void fh_remove, (char *path)                );
  101. extern _PRO( int nfsmounted, (const char *path, struct stat *sbp)    );
  102.  
  103. /* End of fh.h. */
  104.