X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..b226f5e54a60dc81db17b1260381d7dbfea3cdf1:/bsd/sys/filedesc.h diff --git a/bsd/sys/filedesc.h b/bsd/sys/filedesc.h index b5b80a6bc..16e33533a 100644 --- a/bsd/sys/filedesc.h +++ b/bsd/sys/filedesc.h @@ -85,10 +85,17 @@ #ifdef BSD_KERNEL_PRIVATE +#include + struct klist; +struct kqlist; struct filedesc { struct fileproc **fd_ofiles; /* file structures for open files */ + lck_mtx_t fd_kqhashlock; /* lock for dynamic kqueue hash */ + u_long fd_kqhashmask; /* size of dynamic kqueue hash */ + struct kqlist *fd_kqhash; /* hash table for dynamic kqueues */ + struct kqueue *fd_wqkqueue; /* the workq kqueue */ char *fd_ofileflags; /* per-process open file flags */ struct vnode *fd_cdir; /* current directory */ struct vnode *fd_rdir; /* root directory */ @@ -96,11 +103,12 @@ struct filedesc { int fd_lastfile; /* high-water mark of fd_ofiles */ int fd_freefile; /* approx. next free file */ u_short fd_cmask; /* mask for file creation */ + int fd_flags; int fd_knlistsize; /* size of knlist */ struct klist *fd_knlist; /* list of attached knotes */ u_long fd_knhashmask; /* size of knhash */ struct klist *fd_knhash; /* hash table for attached knotes */ - int fd_flags; + lck_mtx_t fd_knhashlock; /* lock for hash table for attached knotes */ }; /* @@ -110,6 +118,9 @@ struct filedesc { /* if we're force unmounted and unable to */ /* take a vnode_ref on fd_rdir during a fork */ +#define FD_WORKLOOP 0x02 /* process has created a kqworkloop that */ + /* requires manual cleanup on exit */ + /* * Per-process open flags. */ @@ -145,6 +156,16 @@ extern int fdavail(proc_t p, int n); (&(p)->p_fd->fd_ofiles[(fd)]) #define fdflags(p, fd) \ (&(p)->p_fd->fd_ofileflags[(fd)]) + +/* + * Accesor macros for fd flags + */ +#define FDFLAGS_GET(p, fd) (*fdflags(p, fd) & (UF_EXCLOSE|UF_FORKCLOSE)) +#define FDFLAGS_SET(p, fd, bits) \ + (*fdflags(p, fd) |= ((bits) & (UF_EXCLOSE|UF_FORKCLOSE))) +#define FDFLAGS_CLR(p, fd, bits) \ + (*fdflags(p, fd) &= ~((bits) & (UF_EXCLOSE|UF_FORKCLOSE))) + extern int falloc(proc_t p, struct fileproc **resultfp, int *resultfd, vfs_context_t ctx); #ifdef __APPLE_API_PRIVATE @@ -155,7 +176,7 @@ extern int falloc_withalloc(proc_t p, struct fileproc **resultfp, extern struct filedesc *fdcopy(proc_t p, struct vnode *uth_cdir); extern void fdfree(proc_t p); -extern void fdexec(proc_t p, short flags); +extern void fdexec(proc_t p, short flags, int self_exec); #endif /* __APPLE_API_PRIVATE */ #endif /* KERNEL */