卸载时的熔断操作
我已经用 Python-fuse 编写了一些简单的文件系统,但现在我想做一些在 pydoc 和我找到的示例脚本中都找不到的事情:当使用 fusermount 卸载文件系统时-u,我想捕获该操作,执行卸载,然后 rmdir 由我的程序初始化脚本创建的安装目录。如果有可能的话,捕获 umount 操作的魔法咒语是什么?
我可以看到这很容易变成无限循环,但我希望能够弄清楚如何在第一次遇到 umount 陷阱时禁用它。
Update: I found
destroy
at http://omake.metaprl.org/prerelease/omake-dll-fuse.html#htoc582 and added the method, but it doesn't seem to be called.I've written some simple filesystems with Python-fuse, but now I'm wanting to do something that I can't find in the pydoc nor in the sample scripts I've found: when the filesystem is unmounted with fusermount -u
, I want to trap that action, perform the umount, and then rmdir the mount directory created by my program's initialization script. If it is even possible, what's the magic incantation to trap the umount action?
I can see how that could easily turn into an endless loop, but I can hopefully figure out how to disable the umount trap the first time it's hit.
Update: I found
destroy
at http://omake.metaprl.org/prerelease/omake-dll-fuse.html#htoc582 and added the method, but it doesn't seem to be called.
找到了!它是 Python-fuse 中的 fsdestroy()。找到它的方式:
我使用的是:
不知道数据参数是否必要,但不会造成伤害。显然,它是在 umount 之后调用的,所以我不必担心如何处理它。
found it! it's fsdestroy() in Python-fuse. located it by:
What I used was:
Don't know if the data parameter is necessary or not, but doesn't hurt. And apparently, it's called after the umount, so I didn't have to worry about handling that.