mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-04-11 22:40:01 +03:00
zfs check initial version (wip)
This commit is contained in:
parent
a115f0bd17
commit
14c45d2b34
@ -39,8 +39,8 @@ class ZfsCheck(CliBase):
|
||||
|
||||
return args
|
||||
|
||||
def hash_filesystem(self, snapshot):
|
||||
"""
|
||||
def hash_filesystem(self, snapshot, count, bs):
|
||||
""" recursively hash all files in this snapshot, using block_hash_tree()
|
||||
|
||||
:type snapshot: ZfsDataset.ZfsDataset
|
||||
"""
|
||||
@ -54,14 +54,16 @@ class ZfsCheck(CliBase):
|
||||
|
||||
self.debug("Hashing tree: {}".format(mnt))
|
||||
if not self.args.test:
|
||||
for (file, block, hash) in block_hash_tree(mnt):
|
||||
for (file, block, hash) in block_hash_tree(mnt, count, bs):
|
||||
print("{}\t{}\t{}".format(file, block, hash))
|
||||
|
||||
finally:
|
||||
self.debug("Cleaning up temporary mount point")
|
||||
snapshot.unmount()
|
||||
self.debug("Cleaning up temporary mount point")
|
||||
self.node.run(["rmdir", mnt], hide_errors=True, valid_exitcodes=[])
|
||||
|
||||
# def hash_volume(self, snapshot):
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
@ -78,9 +80,9 @@ class ZfsCheck(CliBase):
|
||||
dataset_type=snapshot.parent.properties['type']
|
||||
|
||||
if dataset_type=='volume':
|
||||
self.checksum_volume(snapshot)
|
||||
self.checksum_volume(snapshot, self.args.count, self.args.block_size)
|
||||
elif dataset_type=='filesystem':
|
||||
self.hash_filesystem(snapshot)
|
||||
self.hash_filesystem(snapshot, self.args.count, self.args.block_size)
|
||||
else:
|
||||
raise Exception("huh?")
|
||||
|
||||
|
@ -36,7 +36,7 @@ def block_hash(fname, count=10000, bs=4006):
|
||||
hash = hashlib.sha1()
|
||||
block_nr = 0
|
||||
chunk_nr = 0
|
||||
for block in iter(lambda: f.read(4096), b""):
|
||||
for block in iter(lambda: f.read(bs), b""):
|
||||
hash.update(block)
|
||||
block_nr = block_nr + 1
|
||||
if block_nr % count == 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user