#ifdef BSD_KERNEL_PRIVATE
+#include <kern/locks.h>
+
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 */
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 */
};
/*
/* 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.
*/
(&(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
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 */