]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: use truncate in mk_fs()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 6 Mar 2025 17:46:59 +0000 (18:46 +0100)
committerTom Rini <trini@konsulko.com>
Sun, 30 Mar 2025 15:13:34 +0000 (09:13 -0600)
While the dd command actually writes to the block device the truncate
command only updates the metadata (at least on ext4). This is faster and
reduces wear on the block device.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
test/py/tests/fs_helper.py

index ccfc0201a49f4a66da9c6592a548117fed73384c..d85e2b98a243c5ea0c559420a50b608db5282028 100644 (file)
@@ -54,7 +54,7 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, size_gran = 0x100000):
 
     try:
         check_call(f'rm -f {fs_img}', shell=True)
-        check_call(f'dd if=/dev/zero of={fs_img} bs={size_gran} count={count}',
+        check_call(f'truncate -s $(( {size_gran} * {count} )) {fs_img}',
                    shell=True)
         check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True)
         if fs_type == 'ext4':