Using kqueue/kevents on fuse_chan_fd

109 views
Skip to first unread message

benhj

unread,
Oct 2, 2012, 4:11:30 AM10/2/12
to osxfus...@googlegroups.com
Hi, I am attempting to write my own fuse event loop and I would like to use the kqueue system to notify when data on a given channel is available for processing. It seems however that it doesn't support fuse file descriptors. A similar issue was raised in 2008 with the original macfuse implementation, but I'm not sure if any significant headway was made; see here:


I would be very keen on getting this working. The reason is that I would like to be able to create multiple mount points and process events for those mount points as and when they arise. An alternative would be to use a threaded model but I would rather use the kqueue framework if possible.  

Cheers,
Ben.

Benjamin Fleischer

unread,
Oct 6, 2012, 10:05:42 AM10/6/12
to osxfus...@googlegroups.com
Hi Ben,

I do not think that kevents will help in your case. If you want to handle FUSE requests in your own event loop in a non-blocking way try using the select system call to find out if there are new requests to process before calling read on a FUSE channel. This feature has been introduced in OSXFUSE 2.5.0. Besides that it is possible to do nonblocking reads on the FUSE channel.

Regards,
Benjamin

benhj

unread,
Oct 16, 2012, 5:55:21 AM10/16/12
to osxfus...@googlegroups.com
Hi Benjamin, 

Many thanks for your reply. I had no idea about fuse_device_select. Seems like it will do exactly what I require. Currently, in my event loop, I'm doing something like:

struct fuse_cmd * const fc = fuse_read_cmd(fuseptr);

fuse_process_cmd(fuseptr, fc);


rather than calling directly fuse_chan_recv and fuse_chan_process as is the case in fuse_session_loop.


But I am unsure how to use fuse_device_select in either of the above contexts. Specifically I am unsure what the supplied function parameters are and how to obtain them, n.b.:


fuse_device_select(dev_t dev, int which, void *wql, struct proc *p)


I am guessing that this function will tell me if there is data available on a given fuse_chan so I imagine that the above parameters can be obtained from a fuse_chan?


Cheers,

Ben.

Benjamin Fleischer

unread,
Oct 16, 2012, 6:55:30 PM10/16/12
to osxfus...@googlegroups.com
Hi Ben,

You do not call fuse_device_select directly. fuse_device_select is just the implementing function of the select mechanism for /dev/osxfuse devices. Please see the man page of system call select for more details on how to use select. Basically you need to call select with readfds including all fuse_chan_fds you are interested in. select returns only those file descriptors that hold new messages waiting to be processed. Then you can iterate over the remaining descriptors and process new messages like you did before.

Regards,
Benjamin

benhj

unread,
Oct 17, 2012, 5:14:45 AM10/17/12
to osxfus...@googlegroups.com
Benjamin -- many thanks, that makes sense now

Cheers,
Ben.
Reply all
Reply to author
Forward
0 new messages