Fix the "passability" test in fdcopy().

Rather than checking to see if a descriptor is a kqueue, check to see if
its fileops flags include DFLAG_PASSABLE.

At the moment, these two tests are equivalent, but this will change with
the addition of capabilities that wrap kqueues but are themselves of type
DTYPE_CAPABILITY. We already have the DFLAG_PASSABLE abstraction, so let's
use it.

This change has been tested with [the newly improved] tools/regression/kqueue.

Approved by: mentor (rwatson), re (Capsicum blanket)
Sponsored by: Google Inc
This commit is contained in:
Jonathan Anderson 2011-07-08 12:19:25 +00:00
parent 345f2b96e2
commit 5604e481b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223866

View File

@ -1780,11 +1780,11 @@ fdcopy(struct filedesc *fdp)
FILEDESC_XUNLOCK(newfdp);
FILEDESC_SLOCK(fdp);
}
/* copy everything except kqueue descriptors */
/* copy all passable descriptors (i.e. not kqueue) */
newfdp->fd_freefile = -1;
for (i = 0; i <= fdp->fd_lastfile; ++i) {
if (fdisused(fdp, i) &&
fdp->fd_ofiles[i]->f_type != DTYPE_KQUEUE &&
(fdp->fd_ofiles[i]->f_ops->fo_flags & DFLAG_PASSABLE) &&
fdp->fd_ofiles[i]->f_ops != &badfileops) {
newfdp->fd_ofiles[i] = fdp->fd_ofiles[i];
newfdp->fd_ofileflags[i] = fdp->fd_ofileflags[i];