mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-22 12:54:37 +00:00
test: Add size granularity parameter to mk_fs
Without this commit it is only possible to create filesystem images with a size granularity of 1MB. This commit adds the option to create file systems with different sizes, e.g 8.5MB. Signed-off-by: Christian Taedcke <christian.taedcke@weidmueller.com>
This commit is contained in:
parent
1e85b66212
commit
c667b26b26
1 changed files with 4 additions and 3 deletions
|
@ -9,7 +9,7 @@ import re
|
||||||
import os
|
import os
|
||||||
from subprocess import call, check_call, check_output, CalledProcessError
|
from subprocess import call, check_call, check_output, CalledProcessError
|
||||||
|
|
||||||
def mk_fs(config, fs_type, size, prefix):
|
def mk_fs(config, fs_type, size, prefix, size_gran = 0x100000):
|
||||||
"""Create a file system volume
|
"""Create a file system volume
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -17,6 +17,7 @@ def mk_fs(config, fs_type, size, prefix):
|
||||||
fs_type (str): File system type, e.g. 'ext4'
|
fs_type (str): File system type, e.g. 'ext4'
|
||||||
size (int): Size of file system in bytes
|
size (int): Size of file system in bytes
|
||||||
prefix (str): Prefix string of volume's file name
|
prefix (str): Prefix string of volume's file name
|
||||||
|
size_gran (int): Size granularity of file system image in bytes
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
CalledProcessError: if any error occurs when creating the filesystem
|
CalledProcessError: if any error occurs when creating the filesystem
|
||||||
|
@ -38,7 +39,7 @@ def mk_fs(config, fs_type, size, prefix):
|
||||||
else:
|
else:
|
||||||
fs_lnxtype = fs_type
|
fs_lnxtype = fs_type
|
||||||
|
|
||||||
count = (size + 0x100000 - 1) // 0x100000
|
count = (size + size_gran - 1) // size_gran
|
||||||
|
|
||||||
# Some distributions do not add /sbin to the default PATH, where mkfs lives
|
# Some distributions do not add /sbin to the default PATH, where mkfs lives
|
||||||
if '/sbin' not in os.environ["PATH"].split(os.pathsep):
|
if '/sbin' not in os.environ["PATH"].split(os.pathsep):
|
||||||
|
@ -46,7 +47,7 @@ def mk_fs(config, fs_type, size, prefix):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
check_call(f'rm -f {fs_img}', shell=True)
|
check_call(f'rm -f {fs_img}', shell=True)
|
||||||
check_call(f'dd if=/dev/zero of={fs_img} bs=1M count={count}',
|
check_call(f'dd if=/dev/zero of={fs_img} bs={size_gran} count={count}',
|
||||||
shell=True)
|
shell=True)
|
||||||
check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True)
|
check_call(f'mkfs.{fs_lnxtype} {mkfs_opt} {fs_img}', shell=True)
|
||||||
if fs_type == 'ext4':
|
if fs_type == 'ext4':
|
||||||
|
|
Loading…
Add table
Reference in a new issue