[PATCH 3/3] save: use open_noatime, not os.open(..., O_NOATIME)

0 views
Skip to first unread message

Rob Browning

unread,
Mar 15, 2026, 6:22:13 PM (9 days ago) Mar 15
to bup-...@googlegroups.com
Switch back to our open_noatime because os.open with O_NOATIME may die
with EPERM in some situations (e.g. when you're not the owner), and
we've long handled that in our wrapper.

See also the comments in _open_noatime and

58d9e56cc749853baa9ef59166d86c1dda0430f2
Replace hashsplit.open_noatime with os.open

Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/cmd/save.py | 8 ++++----
lib/bup/compat.py | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/bup/cmd/save.py b/lib/bup/cmd/save.py
index 4d09b06d..df9db328 100644
--- a/lib/bup/cmd/save.py
+++ b/lib/bup/cmd/save.py
@@ -4,10 +4,10 @@ from errno import ENOENT
from os import O_NOFOLLOW, O_RDONLY
import math, os, stat, sys, time

-from bup import hashsplit, options, index, client, metadata
-from bup import hlinkdb
+from bup import hashsplit, hlinkdb, options, index, client, metadata
+from bup._helpers import open_noatime
from bup.commit import commit_message
-from bup.compat import MAYBE_NOATIME, argv_bytes, get_argvb
+from bup.compat import argv_bytes, get_argvb
from bup.config import ConfigError
from bup.hashsplit import \
(GIT_MODE_TREE,
@@ -387,7 +387,7 @@ def save_tree(opt, reader, hlink_db, msr, repo, split_cfg):
return repo.write_data(data)
before_saving_regular_file(ent.name)

- with open(os.open(ent.name, O_RDONLY | O_NOFOLLOW | MAYBE_NOATIME),
+ with open(open_noatime(ent.name, O_RDONLY | O_NOFOLLOW),
'rb', buffering=1024 * 1024) as f:
mode, id = \
split_to_blob_or_tree(write_data, repo.write_tree,
diff --git a/lib/bup/compat.py b/lib/bup/compat.py
index 7ace4f90..0ac7f44b 100644
--- a/lib/bup/compat.py
+++ b/lib/bup/compat.py
@@ -12,7 +12,6 @@ import bup_main

ver = sys.version_info

-MAYBE_NOATIME = getattr(os, 'O_NOATIME', 0) # mostly linux
MAYBE_LARGEFILE = getattr(os, 'O_LARGEFILE', 0)

if (ver.major, ver.minor) >= (3, 10):
--
2.47.3

Reply all
Reply to author
Forward
0 new messages