开发者

FUSE (Filesystem in Userspace) with Qt Programming

I'm trying to use FUSE with Qt, but fuse_main() and app.exec() has their own event loop. This mean that if I start one the other will not sta开发者_如何转开发rt, since the first that starts prevents the other to start as shown below. How to deal with this?

For more info about fuse, go to http://fuse.sourceforge.net/

Please, if possible, provide example.

Thank you, Leandro.

Example:

this one will prevent fuse to start:

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv); // qt event loop
    a.exec();
    fuse_main(argc, argv, &hello_oper); // fuse event loop, it will not start
    return 0;
}

and this one will prevent qt to start:

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv); // it will not start due to fuse_main invocation
    fuse_main(argc, argv, &hello_oper);
    return a.exec();
}


You should run the filesystem on a separate thread.


You can also run FUSE on a separate process and communicate via sockets/pipes/RPC/... It is preferred in the case that FUSE crashes or is busy doing something, your GUI is still working.


i've create a simple example of how FUSE and Qt can be used together, see: https://github.com/qknight/qt-fuse-example

the fuse_main(..) convenience function can't be used as then you would not have any means of: - reroute the posix signals - you can't shutdown the fuse process easily, like with using QFuse.cpp: fuse_unmount(TUP_MNT, fs.ch); pthread_join(fs.pid, NULL);

as discussed on the fuse-devel mailinglist, there are two good ways to integrate FUSE into Qt:

  1. implement it (as i did in qt-fuse):

    Qt mainloop is running, FUSE mainloop is also running, both in different threads. i solved some issues in regards to POSIX::signal to Qt::signal conversion, so a clear shutdown is possible.

  2. modify the FUSE library to have direct access from the Qt event loop:

    Qt mainloop is running, no need for a FUSE mainloop as it would be integrated into the Qt mainloop. didn't look into this but it might have different advantages.

hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜