simplify char/block device file dispatching

This commit is contained in:
Thomas Waldmann 2017-03-26 14:03:39 +02:00
parent 9478e8abd0
commit 1f6dc55eab
2 changed files with 11 additions and 8 deletions

View File

@ -864,14 +864,11 @@ Utilization of max. archive size: {csize_max:.0%}
item.update(self.stat_attrs(st, path))
return status
def process_dev(self, path, st):
with self.create_helper(path, st, None) as (item, status, hardlinked, hardlink_master): # no status yet
def process_dev(self, path, st, dev_type):
with self.create_helper(path, st, dev_type) as (item, status, hardlinked, hardlink_master): # char/block device
item.rdev = st.st_rdev
item.update(self.stat_attrs(st, path))
if stat.S_ISCHR(st.st_mode):
return 'c' # char device
elif stat.S_ISBLK(st.st_mode):
return 'b' # block device
return status
def process_symlink(self, path, st):
with self.create_helper(path, st, 's') as (item, status, hardlinked, hardlink_master): # symlink

View File

@ -562,10 +562,16 @@ class Archiver:
status = archive.process_fifo(path, st)
else:
status = archive.process_file(path, st, cache)
elif stat.S_ISCHR(st.st_mode) or stat.S_ISBLK(st.st_mode):
elif stat.S_ISCHR(st.st_mode):
if not dry_run:
if not read_special:
status = archive.process_dev(path, st)
status = archive.process_dev(path, st, 'c')
else:
status = archive.process_file(path, st, cache)
elif stat.S_ISBLK(st.st_mode):
if not dry_run:
if not read_special:
status = archive.process_dev(path, st, 'b')
else:
status = archive.process_file(path, st, cache)
elif stat.S_ISSOCK(st.st_mode):