svn commit: r189450 - in head/sys: fs/devfs kern sys

Konstantin Belousov kib at FreeBSD.org
Fri Mar 6 07:35:38 PST 2009


Author: kib
Date: Fri Mar  6 15:35:37 2009
New Revision: 189450
URL: http://svn.freebsd.org/changeset/base/189450

Log:
  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

Modified:
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/kern/kern_conf.c
  head/sys/kern/sys_generic.c
  head/sys/kern/vfs_default.c
  head/sys/sys/systm.h

Modified: head/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- head/sys/fs/devfs/devfs_vnops.c	Fri Mar  6 14:53:51 2009	(r189449)
+++ head/sys/fs/devfs/devfs_vnops.c	Fri Mar  6 15:35:37 2009	(r189450)
@@ -1014,7 +1014,7 @@ devfs_poll_f(struct file *fp, int events
 	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);

Modified: head/sys/kern/kern_conf.c
==============================================================================
--- head/sys/kern/kern_conf.c	Fri Mar  6 14:53:51 2009	(r189449)
+++ head/sys/kern/kern_conf.c	Fri Mar  6 15:35:37 2009	(r189450)
@@ -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

Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c	Fri Mar  6 14:53:51 2009	(r189449)
+++ head/sys/kern/sys_generic.c	Fri Mar  6 15:35:37 2009	(r189450)
@@ -731,6 +731,22 @@ out:
 	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;

Modified: head/sys/kern/vfs_default.c
==============================================================================
--- head/sys/kern/vfs_default.c	Fri Mar  6 14:53:51 2009	(r189449)
+++ head/sys/kern/vfs_default.c	Fri Mar  6 15:35:37 2009	(r189450)
@@ -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));
 }
 
 /*

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri Mar  6 14:53:51 2009	(r189449)
+++ head/sys/sys/systm.h	Fri Mar  6 15:35:37 2009	(r189450)
@@ -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);
 


More information about the svn-src-head mailing list