devdetour / TelegramFUSE

A FUSE filesystem written in Python for reading and writing files to and from Telegram.
304 stars 36 forks source link

Bug at fuse_impl.py: For entry.st_nlink >1 (example: on multiple hard links to an inode) the _remove fails to remove dentry. #6

Closed oliomin closed 6 months ago

oliomin commented 6 months ago

Consider the following contents table entry:

name inode parent_inode
myfile 5 2
hardlink_to_myfile 5 3
another_hardlink_to_myfile 5 2

Now if I try to delete one of the links, say hardlink_to_myfile, then the operation fails because entry.st_nlink > 1 and the conditional at line 249 in fuse_impl.py is never reached. So, I propose to add another conditional at entry.st_nlink > 1 where only the dentry is deleted.

devdetour commented 6 months ago

Thanks for opening a PR! I tested this out locally and your change seems to have the desired behavior. I'll note this is also an issue in the tmpfs.py example I based this on from pyfuse3 so you may want to consider opening a similar PR there as well!