1 /* namei.h 6.9 85/03/07 */ 2 3 #ifndef _NAMEI_ 4 #define _NAMEI_ 5 6 #ifdef KERNEL 7 #include "uio.h" 8 #else 9 #include <sys/uio.h> 10 #endif 11 12 /* 13 * Encapsulation of namei parameters. 14 * One of these is located in the u. area to 15 * minimize space allocated on the kernel stack. 16 */ 17 struct nameidata { 18 caddr_t ni_dirp; /* pathname pointer */ 19 short ni_nameiop; /* see below */ 20 short ni_error; /* error return if any */ 21 off_t ni_endoff; /* end of useful stuff in directory */ 22 struct inode *ni_pdir; /* inode of parent directory of dirp */ 23 struct iovec ni_iovec; /* MUST be pointed to by ni_iov */ 24 struct uio ni_uio; /* directory I/O parameters */ 25 struct direct ni_dent; /* current directory entry */ 26 }; 27 28 #define ni_base ni_iovec.iov_base 29 #define ni_count ni_iovec.iov_len 30 #define ni_iov ni_uio.uio_iov 31 #define ni_iovcnt ni_uio.uio_iovcnt 32 #define ni_offset ni_uio.uio_offset 33 #define ni_segflg ni_uio.uio_segflg 34 #define ni_resid ni_uio.uio_resid 35 36 /* 37 * namei opertions 38 */ 39 #define LOOKUP 0 /* perform name lookup only */ 40 #define CREATE 1 /* setup for file creation */ 41 #define DELETE 2 /* setup for file deletion */ 42 #define LOCKPARENT 0x10 /* see the top of namei */ 43 #define NOCACHE 0x20 /* name must not be left in cache */ 44 #define FOLLOW 0x40 /* follow symbolic links */ 45 #define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */ 46 47 /* 48 * This structure describes the elements in the cache of recent 49 * names looked up by namei. 50 */ 51 struct nch { 52 struct nch *nc_forw, *nc_back; /* hash chain, MUST BE FIRST */ 53 struct nch *nc_nxt, **nc_prev; /* LRU chain */ 54 struct inode *nc_ip; /* inode the name refers to */ 55 ino_t nc_ino; /* ino of parent of name */ 56 dev_t nc_dev; /* dev of parent of name */ 57 dev_t nc_idev; /* dev of the name ref'd */ 58 long nc_id; /* referenced inode's id */ 59 char nc_nlen; /* length of name */ 60 #define NCHNAMLEN 15 /* maximum name segment length we bother with */ 61 char nc_name[NCHNAMLEN]; /* segment name */ 62 }; 63 struct nch *nch; 64 int nchsize; 65 66 /* 67 * Stats on usefulness of namei caches. 68 */ 69 struct nchstats { 70 long ncs_goodhits; /* hits that we can reall use */ 71 long ncs_badhits; /* hits we must drop */ 72 long ncs_falsehits; /* hits with id mismatch */ 73 long ncs_miss; /* misses */ 74 long ncs_long; /* long names that ignore cache */ 75 long ncs_pass2; /* names found with passes == 2 */ 76 long ncs_2passes; /* number of times we attempt it */ 77 }; 78 #endif 79