File 0001-testsuite-get-fs-flags-before-setting-them.patch of Package borgbackup
From f36c935c934b0e72a216a45689ae280d933d86bb Mon Sep 17 00:00:00 2001
From: Jiri Slaby <jslaby@suse.cz>
Date: Thu, 9 Oct 2025 08:25:15 +0200
Subject: [PATCH] testsuite: get fs flags before setting them
FS_IOC_SETFLAGS called without fetching flags first can remove for
example an ext4 flag like EXT4_EXTENTS_FL which results in EOPNOTSUPP.
That one is indeed handled in the code, but this is still incorrect. The
flags should be fetched with FS_IOC_GETFLAGS, updated and only then
stored back with FS_IOC_SETFLAGS.
Fixes #9039.
Closes: https://bugzilla.suse.com/show_bug.cgi?id=1251048
With the commit applied I now see:
newfstatat(AT_FDCWD, "/tmp/tmp5tlytc1a", {st_mode=S_IFREG|0600, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
openat(AT_FDCWD, "/tmp/tmp5tlytc1a", O_RDONLY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC) = 4
ioctl(4, FS_IOC_GETFLAGS, [FS_EXTENT_FL]) = 0
ioctl(4, FS_IOC_SETFLAGS, [FS_NODUMP_FL|FS_EXTENT_FL]) = 0
close(4) = 0
---
src/borg/testsuite/__init__.py | 4 +++-
src/borg/testsuite/archiver.py | 10 ++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/borg/testsuite/__init__.py b/src/borg/testsuite/__init__.py
index 1955351f8712..7249f4a2c764 100644
--- a/src/borg/testsuite/__init__.py
+++ b/src/borg/testsuite/__init__.py
@@ -37,7 +37,9 @@
has_lchflags = hasattr(os, 'lchflags') or sys.platform.startswith('linux')
try:
with tempfile.NamedTemporaryFile() as file:
- platform.set_flags(file.name, stat.UF_NODUMP)
+ st = os.stat(file.name, follow_symlinks=False)
+ flags = platform.get_flags(file.name, st)
+ platform.set_flags(file.name, flags | stat.UF_NODUMP)
except OSError:
has_lchflags = False
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
index 5dc14faee21e..0c28560d1f31 100644
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -365,7 +365,10 @@ def create_test_files(self, create_hardlinks=True):
if are_fifos_supported():
os.mkfifo(os.path.join(self.input_path, 'fifo1'))
if has_lchflags:
- platform.set_flags(os.path.join(self.input_path, 'flagfile'), stat.UF_NODUMP)
+ file = os.path.join(self.input_path, 'flagfile')
+ st = os.stat(file, follow_symlinks=False)
+ flags = platform.get_flags(file, st)
+ platform.set_flags(file, flags | stat.UF_NODUMP)
try:
# Block device
os.mknod('input/bdev', 0o600 | stat.S_IFBLK, os.makedev(10, 20))
@@ -2079,7 +2082,10 @@ def test_file_status_excluded(self):
self.create_regular_file('file2', size=1024 * 80)
if has_lchflags:
self.create_regular_file('file3', size=1024 * 80)
- platform.set_flags(os.path.join(self.input_path, 'file3'), stat.UF_NODUMP)
+ file = os.path.join(self.input_path, 'file3')
+ st = os.stat(file, follow_symlinks=False)
+ flags = platform.get_flags(file, st)
+ platform.set_flags(file, flags | stat.UF_NODUMP)
self.cmd('init', '--encryption=repokey', self.repository_location)
output = self.cmd('create', '--list', '--exclude-nodump', self.repository_location + '::test', 'input')
self.assert_in("A input/file1", output)
--
2.51.0