mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 17:27:31 +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,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,
|
||||
|
|
Loading…
Reference in a new issue