summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_default.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-12-15 03:09:59 +0000
committerwollman <wollman@FreeBSD.org>1997-12-15 03:09:59 +0000
commit1a06d8809828f2017adc8b31c76d4f07c3a92169 (patch)
treede4e7dc4bf84fe154d0df8264982bcf11791b066 /sys/kern/vfs_default.c
parentb7cdca40ba7917454003700ecf7d97d1c402ac47 (diff)
downloadFreeBSD-src-1a06d8809828f2017adc8b31c76d4f07c3a92169.zip
FreeBSD-src-1a06d8809828f2017adc8b31c76d4f07c3a92169.tar.gz
Add support for poll(2) on files. vop_nopoll() now returns POLLNVAL
if one of the new poll types is requested; hopefully this will not break any existing code. (This is done so that programs have a dependable way of determining whether a filesystem supports the extended poll types or not.) The new poll types added are: POLLWRITE - file contents may have been modified POLLNLINK - file was linked, unlinked, or renamed POLLATTRIB - file's attributes may have been changed POLLEXTEND - file was extended Note that the internal operation of poll() means that it is impossible for two processes to reliably poll for the same event (this could be fixed but may not be worth it), so it is not possible to rewrite `tail -f' to use poll at this time.
Diffstat (limited to 'sys/kern/vfs_default.c')
-rw-r--r--sys/kern/vfs_default.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index adebcc7..59f6af4 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -231,13 +231,34 @@ vop_nopoll(ap)
struct proc *a_p;
} */ *ap;
{
-
/*
- * Just return what we were asked for.
+ * 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 (ap->a_events & ~POLLSTANDARD)
+ return (POLLNVAL);
+
return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
}
+/*
+ * Implement poll for local filesystems that support it.
+ */
+int
+vop_stdpoll(ap)
+ struct vop_poll_args /* {
+ struct vnode *a_vp;
+ int a_events;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events));
+}
+
int
vop_stdbwrite(ap)
struct vop_bwrite_args *ap;
OpenPOWER on IntegriCloud