Extract the no_poll() and vop_nopoll() code into the common routine

poll_no_poll().
Return a poll_no_poll() result from devfs_poll_f() when
filedescriptor does not reference the live cdev, instead of ENXIO.

Noted and tested by:	hps
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2009-03-06 15:35:37 +00:00
parent bbb39ba587
commit 125dcf8c7d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189450
5 changed files with 21 additions and 23 deletions

View File

@ -1014,7 +1014,7 @@ devfs_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td)
fpop = td->td_fpop;
error = devfs_fp_check(fp, &dev, &dsw);
if (error)
return (error);
return (poll_no_poll(events));
error = dsw->d_poll(dev, events, td);
td->td_fpop = fpop;
dev_relthread(dev);

View File

@ -312,18 +312,8 @@ no_strategy(struct bio *bp)
static int
no_poll(struct cdev *dev __unused, int events, struct thread *td __unused)
{
/*
* Return true for read/write. If the user asked for something
* special, return POLLNVAL, so that clients have a way of
* determining reliably whether or not the extended
* functionality is present without hard-coding knowledge
* of specific filesystem implementations.
* Stay in sync with vop_nopoll().
*/
if (events & ~POLLSTANDARD)
return (POLLNVAL);
return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
return (poll_no_poll(events));
}
#define no_dump (dumper_t *)enodev

View File

@ -731,6 +731,22 @@ kern_ioctl(struct thread *td, int fd, u_long com, caddr_t data)
return (error);
}
int
poll_no_poll(int events)
{
/*
* Return true for read/write. If the user asked for something
* special, return POLLNVAL, so that clients have a way of
* determining reliably whether or not the extended
* functionality is present without hard-coding knowledge
* of specific filesystem implementations.
*/
if (events & ~POLLSTANDARD)
return (POLLNVAL);
return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
}
#ifndef _SYS_SYSPROTO_H_
struct select_args {
int nd;

View File

@ -354,18 +354,8 @@ vop_nopoll(ap)
struct thread *a_td;
} */ *ap;
{
/*
* Return true for read/write. If the user asked for something
* special, return POLLNVAL, so that clients have a way of
* determining reliably whether or not the extended
* functionality is present without hard-coding knowledge
* of specific filesystem implementations.
* Stay in sync with kern_conf.c::no_poll().
*/
if (ap->a_events & ~POLLSTANDARD)
return (POLLNVAL);
return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
return (poll_no_poll(ap->a_events));
}
/*

View File

@ -317,6 +317,8 @@ struct cdev;
dev_t dev2udev(struct cdev *x);
const char *devtoname(struct cdev *cdev);
int poll_no_poll(int events);
/* XXX: Should be void nanodelay(u_int nsec); */
void DELAY(int usec);