Skip to main content

.fuse_hidden files

When playing around with FUSE code I stumbled upon files with names like /tmp/.fuse_hidden0000022500000001. I didn't really find good documentation but a hint on file deletion. So I tried to find out more myself. Ignore that it's Python - say we had C code like this:

f = open("foo/output.txt")
f.write("before")
os.unlink("foo/output.txt")  # Delete while open
f.write("after")
f.close()

Now what happens when you call unlink on that open file? FUSE renames file foo/output.txt to foo/.fuse_hiddenXXXXXXXXXX with the Xs filled in with a random number. Consecutive calls to your implementation of fuse_operations.write(path, buf, size, offset, file_info) get the new name passed for path. On the call to close() your own fuse_operations.unlink(path) is finally called. A slightly different behavior can be achieved by using mount option hard_remove (by appending -ohard_remove on the command line). With that option passed, a call to unlink does not rename the file but actually deletes it. However, the file descriptor behind f stays open and working. Consecutive calls to write receive NULL as the file-system-absolute filename in path.