borg icon indicating copy to clipboard operation
borg copied to clipboard

BSD flags: compatibility between platforms

Open enkore opened this issue 9 years ago • 2 comments

  • 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?

enkore avatar Jul 18 '16 07:07 enkore

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.

ThomasWaldmann avatar Apr 02 '23 20:04 ThomasWaldmann

Note:

  • as we call set_flags rather late for each file in borg 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_flags works 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.

ThomasWaldmann avatar Nov 03 '25 18:11 ThomasWaldmann