@@ -58,7 +58,8 @@ static PyObject *getattr_cb=NULL, *readlink_cb=NULL, *readdir_cb=NULL,
5858 * releasedir_cb = NULL , * fsyncdir_cb = NULL , * flush_cb = NULL , * ftruncate_cb = NULL ,
5959 * fgetattr_cb = NULL , * getxattr_cb = NULL , * listxattr_cb = NULL , * setxattr_cb = NULL ,
6060 * removexattr_cb = NULL , * access_cb = NULL , * lock_cb = NULL , * utimens_cb = NULL ,
61- * bmap_cb = NULL , * fsinit_cb = NULL , * fsdestroy_cb = NULL , * ioctl_cb = NULL ;
61+ * bmap_cb = NULL , * fsinit_cb = NULL , * fsdestroy_cb = NULL , * ioctl_cb = NULL ,
62+ * poll_cb = NULL ;
6263
6364
6465static PyObject * Py_FuseError ;
@@ -991,6 +992,44 @@ ioctl_func(const char *path, int cmd, void *arg,
991992 }
992993 EPILOGUE
993994}
995+
996+ static const char pollhandle_name [] = "pollhandle" ;
997+
998+ static void
999+ pollhandle_destructor (PyObject * p )
1000+ {
1001+ struct fuse_pollhandle * ph ;
1002+
1003+ ph = PyCapsule_GetPointer (p , pollhandle_name );
1004+ fuse_pollhandle_destroy (ph );
1005+ }
1006+
1007+ static int
1008+ poll_func (const char * path , struct fuse_file_info * fi ,
1009+ struct fuse_pollhandle * ph , unsigned * reventsp )
1010+ {
1011+ PyObject * pollhandle = Py_None ;
1012+
1013+ if (ph )
1014+ pollhandle = PyCapsule_New (ph , pollhandle_name , pollhandle_destructor );
1015+
1016+ PROLOGUE (PYO_CALLWITHFI (fi , poll_cb , sO , path , pollhandle ));
1017+
1018+ OUT_DECREF :
1019+ Py_DECREF (v );
1020+ OUT :
1021+ if (ph )
1022+ Py_DECREF (pollhandle );
1023+
1024+ PYUNLOCK ();
1025+
1026+ if (ret > 0 ) {
1027+ * reventsp = ret ;
1028+ ret = 0 ;
1029+ }
1030+
1031+ return ret ;
1032+ }
9941033#endif
9951034
9961035static int
@@ -1036,13 +1075,14 @@ Fuse_main(PyObject *self, PyObject *args, PyObject *kw)
10361075 "create" , "opendir" , "releasedir" , "fsyncdir" , "flush" ,
10371076 "ftruncate" , "fgetattr" , "getxattr" , "listxattr" , "setxattr" ,
10381077 "removexattr" , "access" , "lock" , "utimens" , "bmap" ,
1039- "fsinit" , "fsdestroy" , "ioctl" , "fuse_args" , "multithreaded" , NULL
1078+ "fsinit" , "fsdestroy" , "ioctl" , "poll" , "fuse_args" ,
1079+ "multithreaded" , NULL
10401080 };
10411081
10421082 memset (& op , 0 , sizeof (op ));
10431083
10441084 if (!PyArg_ParseTupleAndKeywords (args , kw ,
1045- "|OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOi " ,
1085+ "|OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOi " ,
10461086 kwlist , & getattr_cb , & readlink_cb ,
10471087 & readdir_cb , & mknod_cb , & mkdir_cb ,
10481088 & unlink_cb , & rmdir_cb , & symlink_cb ,
@@ -1058,7 +1098,7 @@ Fuse_main(PyObject *self, PyObject *args, PyObject *kw)
10581098 & removexattr_cb , & access_cb ,
10591099 & lock_cb , & utimens_cb , & bmap_cb ,
10601100 & fsinit_cb , & fsdestroy_cb , & ioctl_cb ,
1061- & fargseq , & multithreaded ))
1101+ & poll_cb , & fargseq , & multithreaded ))
10621102 return NULL ;
10631103
10641104#define DO_ONE_ATTR_AS (fname , pyname ) \
@@ -1120,6 +1160,7 @@ Fuse_main(PyObject *self, PyObject *args, PyObject *kw)
11201160#endif
11211161#if FUSE_VERSION >= 28
11221162 DO_ONE_ATTR (ioctl );
1163+ DO_ONE_ATTR (poll );
11231164#endif
11241165
11251166#undef DO_ONE_ATTR
@@ -1282,11 +1323,32 @@ FuseAPIVersion(PyObject *self, PyObject *args)
12821323 return favers ;
12831324}
12841325
1326+ static const char FuseNotifyPoll__doc__ [] = "Notify IO readiness event." ;
1327+
1328+ static PyObject *
1329+ FuseNotifyPoll (PyObject * self , PyObject * arg )
1330+ {
1331+ struct fuse_pollhandle * ph ;
1332+ int ret ;
1333+
1334+ ph = PyCapsule_GetPointer (arg , pollhandle_name );
1335+ if (!ph ) {
1336+ PyErr_SetString (PyExc_TypeError ,
1337+ "pollhandle is not a FUSE poll handle" );
1338+ return NULL ;
1339+ }
1340+
1341+ ret = fuse_notify_poll (ph );
1342+
1343+ return PyInt_FromLong (ret );
1344+ }
1345+
12851346static PyMethodDef Fuse_methods [] = {
12861347 {"main" , (PyCFunction )Fuse_main , METH_VARARGS |METH_KEYWORDS },
12871348 {"FuseGetContext" , (PyCFunction )FuseGetContext , METH_VARARGS , FuseGetContext__doc__ },
12881349 {"FuseInvalidate" , (PyCFunction )FuseInvalidate , METH_VARARGS , FuseInvalidate__doc__ },
12891350 {"FuseAPIVersion" , (PyCFunction )FuseAPIVersion , METH_NOARGS , FuseAPIVersion__doc__ },
1351+ {"FuseNotifyPoll" , (PyCFunction )FuseNotifyPoll , METH_O , FuseNotifyPoll__doc__ },
12901352 {NULL , NULL } /* sentinel */
12911353};
12921354
0 commit comments