pythonfuseumount

fuse action on umount


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.


Solution

  • found it! it's fsdestroy() in Python-fuse. located it by:

    jcomeau@intrepid:/usr/src/google-desktop/api$ cat /usr/lib/python2.6/dist-packages/fuseparts/* | strings | grep destroy
    fsdestroy
    

    What I used was:

    def fsdestroy(self, data = None):
      syslog.syslog(syslog.LOG_INFO, 'destroy %s: %s' % (self.mountpoint, data))
      os.rmdir(self.mountpoint)
    

    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.