Print this page
8634 epoll fails to wake on certain edge-triggered conditions
8635 epoll should not emit POLLNVAL
8636 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  22 /*        All Rights Reserved   */
  23 
  24 
  25 /*
  26  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  27  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  28  * Copyright 2015 Joyent, Inc.
  29  */
  30 
  31 /*
  32  * Generic vnode operations.
  33  */
  34 #include <sys/types.h>
  35 #include <sys/param.h>
  36 #include <sys/systm.h>
  37 #include <sys/errno.h>
  38 #include <sys/fcntl.h>
  39 #include <sys/flock.h>
  40 #include <sys/statvfs.h>
  41 #include <sys/vfs.h>
  42 #include <sys/vnode.h>
  43 #include <sys/proc.h>
  44 #include <sys/user.h>
  45 #include <sys/unistd.h>
  46 #include <sys/cred.h>
  47 #include <sys/poll.h>
  48 #include <sys/debug.h>


 399  * Allow any flags.
 400  */
 401 /* ARGSUSED */
 402 int
 403 fs_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr, caller_context_t *ct)
 404 {
 405         return (0);
 406 }
 407 
 408 /*
 409  * Return the answer requested to poll() for non-device files.
 410  * Only POLLIN, POLLRDNORM, and POLLOUT are recognized.
 411  */
 412 struct pollhead fs_pollhd;
 413 
 414 /* ARGSUSED */
 415 int
 416 fs_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
 417     struct pollhead **phpp, caller_context_t *ct)
 418 {











 419         *reventsp = 0;
 420         if (events & POLLIN)
 421                 *reventsp |= POLLIN;
 422         if (events & POLLRDNORM)
 423                 *reventsp |= POLLRDNORM;
 424         if (events & POLLRDBAND)
 425                 *reventsp |= POLLRDBAND;
 426         if (events & POLLOUT)
 427                 *reventsp |= POLLOUT;
 428         if (events & POLLWRBAND)
 429                 *reventsp |= POLLWRBAND;
 430         *phpp = !anyyet && !*reventsp ? &fs_pollhd : (struct pollhead *)NULL;








 431         return (0);
 432 }
 433 
 434 /*
 435  * POSIX pathconf() support.
 436  */
 437 /* ARGSUSED */
 438 int
 439 fs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
 440     caller_context_t *ct)
 441 {
 442         ulong_t val;
 443         int error = 0;
 444         struct statvfs64 vfsbuf;
 445 
 446         switch (cmd) {
 447 
 448         case _PC_LINK_MAX:
 449                 val = MAXLINK;
 450                 break;




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  22 /*        All Rights Reserved   */
  23 
  24 
  25 /*
  26  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  27  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  28  * Copyright 2017 Joyent, Inc.
  29  */
  30 
  31 /*
  32  * Generic vnode operations.
  33  */
  34 #include <sys/types.h>
  35 #include <sys/param.h>
  36 #include <sys/systm.h>
  37 #include <sys/errno.h>
  38 #include <sys/fcntl.h>
  39 #include <sys/flock.h>
  40 #include <sys/statvfs.h>
  41 #include <sys/vfs.h>
  42 #include <sys/vnode.h>
  43 #include <sys/proc.h>
  44 #include <sys/user.h>
  45 #include <sys/unistd.h>
  46 #include <sys/cred.h>
  47 #include <sys/poll.h>
  48 #include <sys/debug.h>


 399  * Allow any flags.
 400  */
 401 /* ARGSUSED */
 402 int
 403 fs_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr, caller_context_t *ct)
 404 {
 405         return (0);
 406 }
 407 
 408 /*
 409  * Return the answer requested to poll() for non-device files.
 410  * Only POLLIN, POLLRDNORM, and POLLOUT are recognized.
 411  */
 412 struct pollhead fs_pollhd;
 413 
 414 /* ARGSUSED */
 415 int
 416 fs_poll(vnode_t *vp, short events, int anyyet, short *reventsp,
 417     struct pollhead **phpp, caller_context_t *ct)
 418 {
 419         /*
 420          * Reject all attempts for edge-triggered polling.  These should only
 421          * occur when regular files are added to a /dev/poll handle which is in
 422          * epoll mode.  The Linux epoll does not allow epoll-ing on regular
 423          * files at all, so rejecting EPOLLET requests is congruent with those
 424          * expectations.
 425          */
 426         if (events & POLLET) {
 427                 return (EPERM);
 428         }
 429 
 430         *reventsp = 0;
 431         if (events & POLLIN)
 432                 *reventsp |= POLLIN;
 433         if (events & POLLRDNORM)
 434                 *reventsp |= POLLRDNORM;
 435         if (events & POLLRDBAND)
 436                 *reventsp |= POLLRDBAND;
 437         if (events & POLLOUT)
 438                 *reventsp |= POLLOUT;
 439         if (events & POLLWRBAND)
 440                 *reventsp |= POLLWRBAND;
 441         /*
 442          * Emitting a pollhead without the intention of issuing pollwakeup()
 443          * calls against it is a recipe for trouble.  It's only acceptable in
 444          * this case since the above logic matches practically all useful
 445          * events.
 446          */
 447         if (*reventsp == 0 && !anyyet) {
 448                 *phpp = &fs_pollhd;
 449         }
 450         return (0);
 451 }
 452 
 453 /*
 454  * POSIX pathconf() support.
 455  */
 456 /* ARGSUSED */
 457 int
 458 fs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
 459     caller_context_t *ct)
 460 {
 461         ulong_t val;
 462         int error = 0;
 463         struct statvfs64 vfsbuf;
 464 
 465         switch (cmd) {
 466 
 467         case _PC_LINK_MAX:
 468                 val = MAXLINK;
 469                 break;