From 85b711fc887a6eca633c9ac18cac80bdafbdb654 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 24 Dec 2018 01:30:51 +0100 Subject: [PATCH] opening device files is troublesome, don't do it for fd-based operations, we would have to open the file, but for char / block devices this has unwanted effects, even if we do not read from the device. thus, we use path (or dir_fd + name) based ops here. --- src/borg/archive.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 87ebf1926..eb887218b 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -1095,16 +1095,16 @@ def process_fifo(self, *, path, parent_fd, name, st): def process_dev(self, *, path, parent_fd, name, st, dev_type): with self.create_helper(path, st, dev_type) as (item, status, hardlinked, hardlink_master): # char/block device - with OsOpen(path=path, parent_fd=parent_fd, name=name, flags=flags_normal, noatime=True) as fd: - with backup_io('fstat'): - curr_st = os.fstat(fd) - # XXX do some checks here: st vs. curr_st - assert stat.S_ISBLK(curr_st.st_mode) or stat.S_ISCHR(curr_st.st_mode) - # make sure stats refer to same object that we are processing below - st = curr_st - item.rdev = st.st_rdev - item.update(self.metadata_collector.stat_attrs(st, path, fd=fd)) - return status + # looks like we can not work fd-based here without causing issues when trying to open/close the device + with backup_io('stat'): + curr_st = os.stat(name, dir_fd=parent_fd, follow_symlinks=False) + # XXX do some checks here: st vs. curr_st + assert stat.S_ISBLK(curr_st.st_mode) or stat.S_ISCHR(curr_st.st_mode) + # make sure stats refer to same object that we are processing below + st = curr_st + item.rdev = st.st_rdev + item.update(self.metadata_collector.stat_attrs(st, path)) + return status def process_symlink(self, *, path, parent_fd, name, st): # note: using hardlinkable=False because we can not support hardlinked symlinks,