-extern int dupfdopen(struct filedesc *fdp,
- int indx, int dfd, int mode, int error);
-extern int fdalloc(struct proc *p, int want, int *result);
-extern void fdrelse(struct proc *p, int fd);
-extern int fdavail(struct proc *p, int n);
-#define fdfile(p, fd) \
- (&(p)->p_fd->fd_ofiles[(fd)])
-#define fdflags(p, fd) \
- (&(p)->p_fd->fd_ofileflags[(fd)])
-extern int falloc(struct proc *p,
- struct fileproc **resultfp, int *resultfd);
-extern void ffree(struct file *fp);
+extern int dupfdopen(struct filedesc *fdp,
+ int indx, int dfd, int mode, int error);
+extern int fdalloc(proc_t p, int want, int *result);
+extern void fdrelse(proc_t p, int fd);
+extern int fdavail(proc_t p, int n);
+#define fdfile(p, fd) \
+ (&(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);