Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:lp-1868177 into
curtin:master.
Commit message:
do not fail when wiping tiny partitions
There are a few ways to skin this cat I guess -- I could also have
changed zero_file_at_offsets to clamp to the file boundaries rather than
failing and left quick_zero alone.
LP: #1868177
Requested reviews:
curtin developers (curtin-dev)
Related bugs:
Bug #1868177 in curtin:
"/snap/subiquity/1561/usr/bin/subiquity:ValueError:main:wrapper:log_time:block_meta:meta_clear:clear_holders:wipe_superblock:_wipe_superblock:wipe_volume:quick_zero:zero_file_at_offsets"
https://bugs.launchpad.net/curtin/+bug/1868177
For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/399893
i haven't tested this beyond running the unittests yet. I guess I should add
some more of those too.
--
Your team curtin developers is requested to review the proposed merge of
~mwhudson/curtin:lp-1868177 into curtin:master.
diff --git a/curtin/block/__init__.py b/curtin/block/__init__.py
index 1b33002..ae85da9 100644
--- a/curtin/block/__init__.py
+++ b/curtin/block/__init__.py
@@ -1209,14 +1209,24 @@ def quick_zero(path, partitions=True, exclusive=True, strict=False):
if this is a block device and partitions is true, then
zero 1M at front and end of each partition.
"""
- buflen = 1024
- count = 1024
- zero_size = buflen * count
- offsets = [0, -zero_size]
is_block = is_block_device(path)
if not (is_block or os.path.isfile(path)):
raise ValueError("%s: not an existing file or block device", path)
+ if is_block:
+ dev_size = read_sys_block_size_bytes(path_to_kname(path))
+ else:
+ dev_size = os.path.getsize(path)
+ buflen = 1024
+ count = 1024
+ zero_size = buflen * count
+
+ if zero_size < dev_size:
+ offsets = [0, -zero_size]
+ else:
+ zero_size = dev_size
+ offsets = [0]
+
pt_names = []
if partitions and is_block:
ptdata = sysfs_partition_data(path)
--
Mailing list: https://launchpad.net/~curtin-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~curtin-dev
More help : https://help.launchpad.net/ListHelp