Hello all you smart people, ;)
I'm trying to do something custom with the filesystem, and I'm hitting roadblocks. I'm hoping you can suggest solutions?
I have a file, let's call it somepath/somefile.txt
I want to create a link to this file that keeps working even if the file changes path or name:
I've thought of a few solutions, but none are great:
Is there a standard way to solve this problem? If not, is there a hacky way to solve it? :D
I'm open to any suggestions, thanks!
I'm trying to do something custom with the filesystem, and I'm hitting roadblocks. I'm hoping you can suggest solutions?
I have a file, let's call it somepath/somefile.txt
I want to create a link to this file that keeps working even if the file changes path or name:
- Create linktofile.link -> somepath/somefile.txt
- File gets moved, renamed: somepath_new/somefile_new.txt
- Link is seamlessly auto-updated: linktofile.link -> somepath_new/somefile_new.txt
I've thought of a few solutions, but none are great:
- Use a symbolic link: links don't follow when the file is renamed or moved
- Create a primary key for each file, encode it in the filename, and write code to find the key in the filesystem. Will technically work, but not great. Mangles my filenames, risk that I might accidentally delete the PK from the filename.
- Encode a primary key in the extended attributes, and write code to find the key across the filesystem. I can't find a good "find" tool for the xattrs. I could write code to iterate over every file in the system and check its xattrs for the PK, but I imagine this would be very slow.
Is there a standard way to solve this problem? If not, is there a hacky way to solve it? :D
I'm open to any suggestions, thanks!