2

Is it possible to have, assigning groups or ownership, something like

ln -s original link

where the original folder will be updated, all link folders will receive the new files, but any change to the files will not be in the original. The user will have write permission to the folder, but not to the files.

2
  • . You didn't say when you needs these to happen. – 炸鱼薯条德里克 Oct 17 '19 at 22:41
  • The user will have write permission to the folder, but not to the files. Note that, in general, that means the user will be able to delete or rename the files, as file deletion and renaming merely requires write permission to the directory, not the file itself. You need to look into how files in /tmp are protected from removal by other users... – Andrew Henle Oct 17 '19 at 23:06
2

On Linux and Solaris you can also use a "reflink" to the original file. A "reflink" is a copy of a file where only the metadata is initially copied. Any changes to the copy do not propagate back to the original file. Likewise, any changes to the original file are not reflected in the copy. Reflinks require the underlying filesystem to support copy-on-write semantics.

Reflinks are supported on Linux by the BTRFS and XFS filesystems (XFS requires kernel version 4.8 or later). Reflinks can be created on Linux using the cp --reflink... command or the ioctl( ..., FI_CLONE, ...) or ioctl( ..., FI_CLONERANGE, ...) functions.

Solaris 11.4 supports reflinks on ZFS, where reflinks can be created with the cp -z ... command or the reflink() function.

1

A symbolic link is just a redirection sign telling the directory traversal code “look there instead”. Once you get to the location of the files, it doesn't matter how you got there, it's the same files.

What you describe is exactly one of the common use cases for union mounts. See also Union mount on Linux although as I write it doesn't have the comprehensive answer that I'd hoped for. The basic principle of a union mount of override over original mounted at link is that link/file is override/file if it exists and original/file otherwise.

On Linux you can make a union mount with the overlay filesystem. Something like this (untested):

mkdir override work
chgrp users override; chmod g+rwxs override
mount -t overlay overlay -o lowerdir=link,upperdir=override,workdir=work link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.