mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
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.
This commit is contained in:
parent
b960d3cd23
commit
85b711fc88
1 changed files with 10 additions and 10 deletions
|
@ -1095,15 +1095,15 @@ def process_fifo(self, *, path, parent_fd, name, st):
|
||||||
|
|
||||||
def process_dev(self, *, path, parent_fd, name, st, dev_type):
|
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 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:
|
# looks like we can not work fd-based here without causing issues when trying to open/close the device
|
||||||
with backup_io('fstat'):
|
with backup_io('stat'):
|
||||||
curr_st = os.fstat(fd)
|
curr_st = os.stat(name, dir_fd=parent_fd, follow_symlinks=False)
|
||||||
# XXX do some checks here: st vs. curr_st
|
# 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)
|
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
|
# make sure stats refer to same object that we are processing below
|
||||||
st = curr_st
|
st = curr_st
|
||||||
item.rdev = st.st_rdev
|
item.rdev = st.st_rdev
|
||||||
item.update(self.metadata_collector.stat_attrs(st, path, fd=fd))
|
item.update(self.metadata_collector.stat_attrs(st, path))
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def process_symlink(self, *, path, parent_fd, name, st):
|
def process_symlink(self, *, path, parent_fd, name, st):
|
||||||
|
|
Loading…
Reference in a new issue