rpodgorny / unionfs-fuse

union filesystem using fuse
Other
309 stars 76 forks source link

Writing to symlinks #60

Open Kyuuhachi opened 7 years ago

Kyuuhachi commented 7 years ago

When writing to a symlink in a RO branch, the data is written to the symlink's target instead of writing to a RW branch.

Setup:

$ tree
.
├── a
├── b
│   └── file -> ../file
├── file
└── u
$ unionfs -ocow a=RW:b u
$ echo "bar" > u/file

Expected behavior:

$ cat a/file
bar
$ cat file
foo

Actual behavior:

$ cat a/file
cat: a/file: No such file or directory
$ cat file
bar
rpodgorny commented 7 years ago

hmm, i'm not really sure whether it should really behave like what you expect...

that's just how symlimks work:

radek@pupik /tmp> echo 'a' >a
radek@pupik /tmp> ln -s a b
radek@pupik /tmp> echo 'b' >b
radek@pupik /tmp> cat a
b
Kyuuhachi commented 7 years ago

Yeah, I know that. I just feel it's kinda unintuitive that writing to a RO-file and a RO-symlink behaves differently. Since I usually use unionfs to make sure my game installations aren't dirtied by savefiles or mods, it's also kinda destructive.

My current use-case is a little more complex (as it actually involves the aforementioned symlinks), but it's mostly irrelevant.

rpodgorny commented 7 years ago

well, the problem here is, partially, that your symlink is pointing "outside" of the union.

anyway, if you're able to describe your use case, maybe we may come up with a solution...

Kyuuhachi commented 7 years ago

Yeah, I know.

Basically, I'm trying to union a lot of folders together (in order to keep game, mods, and save files separate), except the folders aren't rooted at the same place. I do this by creating a tree with a lot of symlinks (which as the additional advantages of making them all lowercase, which I think improves Wine performance, as well as allowing me to put links to files as well), and then unioning that tree to keep writes separate. Sometimes, the game writes to an existing file, such as a config file. I'd like that write to go where I tell it to.

Maybe I should look for/create some kind of resolve-symlink-fs and put that between the symlink tree and the union?