diff options
author | Garrett Wollman <wollman@FreeBSD.org> | 1997-12-15 03:09:59 +0000 |
---|---|---|
committer | Garrett Wollman <wollman@FreeBSD.org> | 1997-12-15 03:09:59 +0000 |
commit | 1cbbd625cc5162746c6c80c5f02489b093cc34c3 (patch) | |
tree | 264f136a24cfcc6bf9d9aa785e049969ee00fb74 /sys/sys/vnode.h | |
parent | 5d6618fa17a15ce19436c6f13364ad1984fc84fe (diff) | |
download | src-1cbbd625cc5162746c6c80c5f02489b093cc34c3.tar.gz src-1cbbd625cc5162746c6c80c5f02489b093cc34c3.zip |
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.
Notes
Notes:
svn path=/head/; revision=31727
Diffstat (limited to 'sys/sys/vnode.h')
-rw-r--r-- | sys/sys/vnode.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 08be46669723..fec331aec28a 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -31,13 +31,14 @@ * SUCH DAMAGE. * * @(#)vnode.h 8.7 (Berkeley) 2/4/94 - * $Id: vnode.h,v 1.57 1997/11/22 08:35:43 bde Exp $ + * $Id: vnode.h,v 1.58 1997/12/05 19:55:49 bde Exp $ */ #ifndef _SYS_VNODE_H_ #define _SYS_VNODE_H_ #include <sys/queue.h> +#include <sys/select.h> /* needed for struct selinfo in vnodes */ #include <machine/lock.h> @@ -78,6 +79,7 @@ struct namecache; * v_mntvnodes is locked by the global mntvnodes simple lock. * v_flag, v_usecount, v_holdcount and v_writecount are * locked by the v_interlock simple lock. + * v_pollinfo is locked by the lock contained inside it. */ struct vnode { u_long v_flag; /* vnode flags (see below) */ @@ -114,12 +116,24 @@ struct vnode { TAILQ_HEAD(, namecache) v_cache_dst; /* Cache entries to us */ struct vnode *v_dd; /* .. vnode */ u_long v_ddid; /* .. capability identifier */ + struct { + struct simplelock vpi_lock; /* lock to protect below */ + struct selinfo vpi_selinfo; /* identity of poller(s) */ + short vpi_events; /* what they are looking for */ + short vpi_revents; /* what has happened */ + } v_pollinfo; }; #define v_mountedhere v_un.vu_mountedhere #define v_socket v_un.vu_socket #define v_specinfo v_un.vu_specinfo #define v_fifoinfo v_un.vu_fifoinfo +#define VN_POLLEVENT(vp, events) \ + do { \ + if ((vp)->v_pollinfo.vpi_events & (events)) \ + vn_pollevent((vp), (events)); \ + } while (0) + /* * Vnode flags. */ @@ -473,6 +487,9 @@ int vn_close __P((struct vnode *vp, int flags, struct ucred *cred, struct proc *p)); int vn_lock __P((struct vnode *vp, int flags, struct proc *p)); int vn_open __P((struct nameidata *ndp, int fmode, int cmode)); +void vn_pollevent __P((struct vnode *vp, int events)); +void vn_pollgone __P((struct vnode *vp)); +int vn_pollrecord __P((struct vnode *vp, struct proc *p, int events)); int vn_rdwr __P((enum uio_rw rw, struct vnode *vp, caddr_t base, int len, off_t offset, enum uio_seg segflg, int ioflg, struct ucred *cred, int *aresid, struct proc *p)); @@ -490,6 +507,7 @@ int vop_nolock __P((struct vop_lock_args *)); int vop_nopoll __P((struct vop_poll_args *)); int vop_nounlock __P((struct vop_unlock_args *)); int vop_stdpathconf __P((struct vop_pathconf_args *)); +int vop_stdpoll __P((struct vop_poll_args *)); int vop_revoke __P((struct vop_revoke_args *)); int vop_sharedlock __P((struct vop_lock_args *)); int vop_eopnotsupp __P((struct vop_generic_args *ap)); |