summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2023-07-29 23:04:44 +0200
committerThomas Waldmann <tw@waldmann-edv.de>2023-07-29 23:04:44 +0200
commited7a41008457443caae4cf5ab1a53f5a5195e359 (patch)
tree75e6c7bcd9bd8276780ec44d740a9050eadf9976 /src
parent453d35fa475e44996a6c14270995a1f545e2d474 (diff)
create: do not try to read parent dir of recursion root, fixes #7746
Diffstat (limited to 'src')
-rw-r--r--src/borg/archiver.py35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/borg/archiver.py b/src/borg/archiver.py
index 024f2a5ac..ba962dcf8 100644
--- a/src/borg/archiver.py
+++ b/src/borg/archiver.py
@@ -590,31 +590,20 @@ class Archiver:
self.print_file_status(status, path)
continue
path = os.path.normpath(path)
- parent_dir = os.path.dirname(path) or '.'
- name = os.path.basename(path)
try:
- # note: for path == '/': name == '' and parent_dir == '/'.
- # the empty name will trigger a fall-back to path-based processing in os_stat and os_open.
- with OsOpen(path=parent_dir, flags=flags_root, noatime=True, op='open_root') as parent_fd:
- try:
- st = os_stat(path=path, parent_fd=parent_fd, name=name, follow_symlinks=False)
- except OSError as e:
- self.print_warning('%s: %s', path, e)
- continue
- if args.one_file_system:
- restrict_dev = st.st_dev
- else:
- restrict_dev = None
- self._rec_walk(path=path, parent_fd=parent_fd, name=name,
- fso=fso, cache=cache, matcher=matcher,
- exclude_caches=args.exclude_caches, exclude_if_present=args.exclude_if_present,
- keep_exclude_tags=args.keep_exclude_tags, skip_inodes=skip_inodes,
- restrict_dev=restrict_dev, read_special=args.read_special, dry_run=dry_run)
- # if we get back here, we've finished recursing into <path>,
- # we do not ever want to get back in there (even if path is given twice as recursion root)
- skip_inodes.add((st.st_ino, st.st_dev))
+ with backup_io('stat'):
+ st = os_stat(path=path, parent_fd=None, name=None, follow_symlinks=False)
+ restrict_dev = st.st_dev if args.one_file_system else None
+ self._rec_walk(path=path, parent_fd=None, name=None,
+ fso=fso, cache=cache, matcher=matcher,
+ exclude_caches=args.exclude_caches, exclude_if_present=args.exclude_if_present,
+ keep_exclude_tags=args.keep_exclude_tags, skip_inodes=skip_inodes,
+ restrict_dev=restrict_dev, read_special=args.read_special, dry_run=dry_run)
+ # if we get back here, we've finished recursing into <path>,
+ # we do not ever want to get back in there (even if path is given twice as recursion root)
+ skip_inodes.add((st.st_ino, st.st_dev))
except (BackupOSError, BackupError) as e:
- # this comes from OsOpen, self._rec_walk has own exception handler
+ # this comes from os.stat, self._rec_walk has own exception handler
self.print_warning('%s: %s', path, e)
continue
if not dry_run: