-#define f_flag f_fglob->fg_flag
-#define f_type f_fglob->fg_type
-#define f_msgcount f_fglob->fg_msgcount
-#define f_cred f_fglob->fg_cred
-#define f_ops f_fglob->fg_ops
-#define f_offset f_fglob->fg_offset
-#define f_data f_fglob->fg_data
-#define PSHMNAMLEN 31 /* maximum name segment length we bother with */
-
-struct pshmobj {
- void * pshmo_memobject;
- memory_object_size_t pshmo_size;
- struct pshmobj * pshmo_next;
-};
-
-struct pshminfo {
- unsigned int pshm_flags;
- unsigned int pshm_usecount;
- off_t pshm_length;
- mode_t pshm_mode;
- uid_t pshm_uid;
- gid_t pshm_gid;
- char pshm_name[PSHMNAMLEN + 1]; /* segment name */
- struct pshmobj *pshm_memobjects;
-#if DIAGNOSTIC
- unsigned int pshm_readcount;
- unsigned int pshm_writecount;
- proc_t pshm_proc;
-#endif /* DIAGNOSTIC */
- struct label* pshm_label;
-};
-#define PSHMINFO_NULL (struct pshminfo *)0
-
-#define PSHM_NONE 0x001
-#define PSHM_DEFINED 0x002
-#define PSHM_ALLOCATED 0x004
-#define PSHM_MAPPED 0x008
-#define PSHM_INUSE 0x010
-#define PSHM_REMOVED 0x020
-#define PSHM_INCREATE 0x040
-#define PSHM_INDELETE 0x080
-#define PSHM_ALLOCATING 0x100
-
-struct pshmcache {
- LIST_ENTRY(pshmcache) pshm_hash; /* hash chain */
- struct pshminfo *pshminfo; /* vnode the name refers to */
- int pshm_nlen; /* length of name */
- char pshm_name[PSHMNAMLEN + 1]; /* segment name */
-};
-#define PSHMCACHE_NULL (struct pshmcache *)0
-
-struct pshmstats {
- long goodhits; /* hits that we can really use */
- long neghits; /* negative hits that we can use */
- long badhits; /* hits we must drop */
- long falsehits; /* hits with id mismatch */
- long miss; /* misses */
- long longnames; /* long names that ignore cache */
-};
-
-struct pshmname {
- char *pshm_nameptr; /* pointer to looked up name */
- long pshm_namelen; /* length of looked up component */
- u_long pshm_hash; /* hash value of looked up name */
-};
-
-struct pshmnode {
- off_t mapp_addr;
- user_size_t map_size; /* XXX unused ? */
- struct pshminfo *pinfo;
- unsigned int pshm_usecount;
-#if DIAGNOSTIC
- unsigned int readcnt;
- unsigned int writecnt;
-#endif
-};
-#define PSHMNODE_NULL (struct pshmnode *)0
-
-
-#define PSHMHASH(pnp) \
- (&pshmhashtbl[(pnp)->pshm_hash & pshmhash])
-
-LIST_HEAD(pshmhashhead, pshmcache) *pshmhashtbl; /* Hash Table */
-u_long pshmhash; /* size of hash table - 1 */
-long pshmnument; /* number of cache entries allocated */
-struct pshmstats pshmstats; /* cache effectiveness statistics */
-
-static int pshm_read (struct fileproc *fp, struct uio *uio,
- int flags, vfs_context_t ctx);
-static int pshm_write (struct fileproc *fp, struct uio *uio,
- int flags, vfs_context_t ctx);
-static int pshm_ioctl (struct fileproc *fp, u_long com,
- caddr_t data, vfs_context_t ctx);
-static int pshm_select (struct fileproc *fp, int which, void *wql, vfs_context_t ctx);
-static int pshm_close(struct pshmnode *pnode);
-static int pshm_closefile (struct fileglob *fg, vfs_context_t ctx);
-
-static int pshm_kqfilter(struct fileproc *fp, struct knote *kn, vfs_context_t ctx);
-
-int pshm_access(struct pshminfo *pinfo, int mode, kauth_cred_t cred, proc_t p);
-static int pshm_cache_add(struct pshminfo *pshmp, struct pshmname *pnp, struct pshmcache *pcp);
-static void pshm_cache_delete(struct pshmcache *pcp);
-#if NOT_USED
-static void pshm_cache_purge(void);
-#endif /* NOT_USED */
-static int pshm_cache_search(struct pshminfo **pshmp, struct pshmname *pnp,
- struct pshmcache **pcache);
-
-struct fileops pshmops =
- { pshm_read, pshm_write, pshm_ioctl, pshm_select, pshm_closefile, pshm_kqfilter, 0 };
-
-static lck_grp_t *psx_shm_subsys_lck_grp;
-static lck_grp_attr_t *psx_shm_subsys_lck_grp_attr;
-static lck_attr_t *psx_shm_subsys_lck_attr;
-static lck_mtx_t psx_shm_subsys_mutex;
-
-#define PSHM_SUBSYS_LOCK() lck_mtx_lock(& psx_shm_subsys_mutex)
-#define PSHM_SUBSYS_UNLOCK() lck_mtx_unlock(& psx_shm_subsys_mutex)