Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ pub fn mount_apivfs(dst: &str, fstype: &str, flags: MsFlags, data: Option<&str>)
Ok(())
}

pub fn mount_regular(
src: Option<&str>,
dst: &str,
fstype: Option<&str>,
flags: MsFlags,
data: Option<&str>,
) -> Result<()> {
if fstype.is_some() {
do_mount(src, dst, fstype, flags, data)
} else {
let mut result = Ok(());
for fstype in ["ext4", "erofs", "squashfs", "f2fs", "btrfs"] {
result = do_mount(src, dst, Some(fstype), flags, data);
if result.is_ok() {
return Ok(());
}
}
result
}
}

pub fn mount_root(
device: Option<&str>,
fstype: Option<&str>,
Expand All @@ -61,7 +82,7 @@ pub fn mount_root(
fsflags.bits(),
flags.unwrap_or_default()
);
do_mount(device, "/root", fstype, fsflags, flags)?;
mount_regular(device, "/root", fstype, fsflags, flags)?;

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def assert_apivfs(result):
def test_basic_ext4(genimage, qemu):
qemu.set_initramfs(genimage.get_initramfs())
qemu.set_diskimage(genimage.get_ext4_disk())
qemu.set_cmdline("rootwait root=/dev/vda1 rootfstype=ext4")
qemu.set_cmdline("rootwait root=/dev/vda1")
result = qemu.run()
result.assert_system_state()
root_mount = result.get_mount(mount_point="/")
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_nfs_bind_mounts(rsinit, genimage, qemu):

def test_missing_root(genimage, qemu):
qemu.set_initramfs(genimage.get_initramfs())
qemu.set_cmdline("root=/dev/vda1 rootfstype=ext4")
qemu.set_cmdline("root=/dev/vda1")
result = qemu.run()
assert result.rsinit_messages == [
{"message": "Timeout reached while waiting for the device"}
Expand All @@ -103,7 +103,7 @@ def test_verity(rsinit, genimage, qemu):
qemu.set_diskimage(disk)
files = {"/init": rsinit.rdinit_path, "/verity-params": verity_params}
qemu.set_initramfs(genimage.create_initramfs_with_files("ext4-verity", files))
qemu.set_cmdline("rootwait rsinit.verity_root=/dev/vda1 rootfstype=ext4")
qemu.set_cmdline("rootwait rsinit.verity_root=/dev/vda1")
result = qemu.run()
result.assert_system_state()
root_mount = result.get_mount(mount_point="/")
Expand Down
Loading