borg
borg copied to clipboard
BSD flags: compatibility between platforms
- Does the set of flags differ by platform? (probably)
- If so, when we extract an item with a flag not supported by the particular platform, does the extracted item only has that specific flag missing, or all flags?
This is the flags mapping currently used by borg:
BSD_TO_LINUX_FLAGS = {
stat.UF_NODUMP: FS_NODUMP_FL,
stat.UF_IMMUTABLE: FS_IMMUTABLE_FL,
stat.UF_APPEND: FS_APPEND_FL,
stat.UF_COMPRESSED: FS_COMPR_FL,
}
In the archived item.bsdflags, it always stores the key from this mapping (== the BSD style flags value).
Linux: https://man7.org/linux/man-pages/man2/ioctl_iflags.2.html FreeBSD: https://man.freebsd.org/cgi/man.cgi?query=chflags&sektion=2&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports Python: https://docs.python.org/3/library/os.html#os.chflags
Guess nodump, immutable, append-only should be unproblematic on linux, bsd, macOS, setting these flags at restore time should work and they have same semantics.
Note:
- as we call
set_flagsrather late for each file inborg extract, I had to remove FS_COMPR_FL support: that only works if the flag is set before writing the file contents. - there also was another change about how
set_flagsworks on Linux, FreeBSD and macOS: it needs to do a read-modify-write cycle to avoid (re)setting (or trying to (re)set) flags that are not settable for owner or super-user.
These changes are in borg 1.4.2 and will be in 2.0.0b20.