-/* $OpenBSD: fuse_vnops.c,v 1.19 2014/07/12 18:43:52 tedu Exp $ */
+/* $OpenBSD: fuse_vnops.c,v 1.20 2014/08/10 09:23:06 jsg Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
#include <sys/systm.h>
#include <sys/dirent.h>
#include <sys/fcntl.h>
+#include <sys/file.h>
#include <sys/lockf.h>
#include <sys/malloc.h>
#include <sys/mount.h>
int fusefs_advlock(void *);
/* Prototypes for fusefs kqfilter */
-int filt_fusefsreadwrite(struct knote *, long);
+int filt_fusefsread(struct knote *, long);
+int filt_fusefswrite(struct knote *, long);
int filt_fusefsvnode(struct knote *, long);
void filt_fusefsdetach(struct knote *);
.vop_advlock = fusefs_advlock,
};
-struct filterops fusefsreadwrite_filtops =
- { 1, NULL, filt_fusefsdetach, filt_fusefsreadwrite };
+struct filterops fusefsread_filtops =
+ { 1, NULL, filt_fusefsdetach, filt_fusefsread };
+struct filterops fusefswrite_filtops =
+ { 1, NULL, filt_fusefsdetach, filt_fusefswrite };
struct filterops fusefsvnode_filtops =
{ 1, NULL, filt_fusefsdetach, filt_fusefsvnode };
switch (kn->kn_filter) {
case EVFILT_READ:
- kn->kn_fop = &fusefsreadwrite_filtops;
+ kn->kn_fop = &fusefsread_filtops;
break;
case EVFILT_WRITE:
- kn->kn_fop = &fusefsreadwrite_filtops;
+ kn->kn_fop = &fusefswrite_filtops;
break;
case EVFILT_VNODE:
kn->kn_fop = &fusefsvnode_filtops;
}
int
-filt_fusefsreadwrite(struct knote *kn, long hint)
+filt_fusefsread(struct knote *kn, long hint)
{
+ struct vnode *vp = (struct vnode *)kn->kn_hook;
+ struct fusefs_node *ip = VTOI(vp);
+
/*
* filesystem is gone, so set the EOF flag and schedule
* the knote for deletion
return (1);
}
+ kn->kn_data = ip->filesize - kn->kn_fp->f_offset;
+ if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
+ kn->kn_fflags |= NOTE_EOF;
+ return (1);
+ }
+
return (kn->kn_data != 0);
}
+int
+filt_fusefswrite(struct knote *kn, long hint)
+{
+ /*
+ * filesystem is gone, so set the EOF flag and schedule
+ * the knote for deletion
+ */
+ if (hint == NOTE_REVOKE) {
+ kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+ return (1);
+ }
+
+ kn->kn_data = 0;
+ return (1);
+}
+
int
filt_fusefsvnode(struct knote *kn, long int hint)
{
-/* $OpenBSD: msdosfs_vnops.c,v 1.94 2014/07/08 17:19:25 deraadt Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.95 2014/08/10 09:23:06 jsg Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
/*-
static uint32_t fileidhash(uint64_t);
int msdosfs_kqfilter(void *);
-int filt_msdosfsreadwrite(struct knote *, long);
+int filt_msdosfsread(struct knote *, long);
+int filt_msdosfswrite(struct knote *, long);
int filt_msdosfsvnode(struct knote *, long);
void filt_msdosfsdetach(struct knote *);
.vop_revoke = vop_generic_revoke,
};
-struct filterops msdosfsreadwrite_filtops =
- { 1, NULL, filt_msdosfsdetach, filt_msdosfsreadwrite };
+struct filterops msdosfsread_filtops =
+ { 1, NULL, filt_msdosfsdetach, filt_msdosfsread };
+struct filterops msdosfswrite_filtops =
+ { 1, NULL, filt_msdosfsdetach, filt_msdosfswrite };
struct filterops msdosfsvnode_filtops =
{ 1, NULL, filt_msdosfsdetach, filt_msdosfsvnode };
switch (kn->kn_filter) {
case EVFILT_READ:
- kn->kn_fop = &msdosfsreadwrite_filtops;
+ kn->kn_fop = &msdosfsread_filtops;
break;
case EVFILT_WRITE:
- kn->kn_fop = &msdosfsreadwrite_filtops;
+ kn->kn_fop = &msdosfswrite_filtops;
break;
case EVFILT_VNODE:
kn->kn_fop = &msdosfsvnode_filtops;
}
int
-filt_msdosfsreadwrite(struct knote *kn, long hint)
+filt_msdosfsread(struct knote *kn, long hint)
{
+ struct vnode *vp = (struct vnode *)kn->kn_hook;
+ struct denode *dep = VTODE(vp);
+
/*
* filesystem is gone, so set the EOF flag and schedule
* the knote for deletion.
return (1);
}
+ kn->kn_data = dep->de_FileSize - kn->kn_fp->f_offset;
+ if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
+ kn->kn_fflags |= NOTE_EOF;
+ return (1);
+ }
return (kn->kn_data != 0);
}
+int
+filt_msdosfswrite(struct knote *kn, long hint)
+{
+ /*
+ * filesystem is gone, so set the EOF flag and schedule
+ * the knote for deletion.
+ */
+ if (hint == NOTE_REVOKE) {
+ kn->kn_flags |= (EV_EOF | EV_ONESHOT);
+ return (1);
+ }
+
+ kn->kn_data = 0;
+ return (1);
+}
+
int
filt_msdosfsvnode(struct knote *kn, long hint)
{