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
7 changes: 6 additions & 1 deletion kiwi/mount_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from kiwi.utils.temporary import Temporary
from kiwi.command import Command
from kiwi.exceptions import KiwiCommandError, KiwiUmountBusyError
from kiwi.utils.block import BlockID

log = logging.getLogger('kiwi')

Expand Down Expand Up @@ -119,8 +120,12 @@ def mount(self, options: List[str] = []) -> None:
option_list = []
if options:
option_list = ['-o'] + options
type_list = []
filesystem = BlockID(self.device).get_filesystem()
if filesystem:
type_list = ['-t', filesystem]
Command.run(
['mount'] + option_list + [self.device, self.mountpoint]
['mount'] + type_list + option_list + [self.device, self.mountpoint]
)

def umount_lazy(self) -> None:
Expand Down
4 changes: 3 additions & 1 deletion test/unit/builder/disk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,14 +1305,16 @@ def test_create_disk_standard_root_no_hypervisor_found(
with raises(KiwiDiskBootImageError):
self.disk_builder.create_disk()

@patch('kiwi.mount_manager.BlockID')
@patch('kiwi.builder.disk.Disk')
@patch('kiwi.builder.disk.create_boot_loader_config')
@patch('kiwi.builder.disk.FileSystem.new')
@patch('kiwi.builder.disk.Command.run')
def test_create_disk_standard_root_xen_server_boot(
self, mock_command, mock_fs, mock_create_boot_loader_config,
mock_Disk
mock_Disk, mock_BlockID
):
mock_BlockID.return_value.get_filesystem.return_value = 'xfs'
bootloader_config = Mock()
bootloader_config.get_boot_cmdline = Mock(
return_value='boot_cmdline'
Expand Down
17 changes: 16 additions & 1 deletion test/unit/mount_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,26 @@ def test_tmpfs_mount(self, mock_mounted, mock_command):
['mount', '-t', 'tmpfs', 'tmpfs', '/some/mountpoint']
)

@patch('kiwi.mount_manager.BlockID')
@patch('kiwi.mount_manager.Command.run')
@patch('kiwi.mount_manager.MountManager.is_mounted')
def test_mount(self, mock_mounted, mock_command):
def test_mount(self, mock_mounted, mock_command, mock_BlockID):
mock_mounted.return_value = False
mock_BlockID.return_value.get_filesystem.return_value = 'vfat'
self.mount_manager.mount(['options'])
mock_BlockID.assert_called_once_with('/dev/some-device')
mock_command.assert_called_once_with(
['mount', '-t', 'vfat', '-o', 'options', '/dev/some-device', '/some/mountpoint']
)

@patch('kiwi.mount_manager.BlockID')
@patch('kiwi.mount_manager.Command.run')
@patch('kiwi.mount_manager.MountManager.is_mounted')
def test_mount_unknown_filesystem(self, mock_mounted, mock_command, mock_BlockID):
mock_mounted.return_value = False
mock_BlockID.return_value.get_filesystem.return_value = ''
self.mount_manager.mount(['options'])
mock_BlockID.assert_called_once_with('/dev/some-device')
mock_command.assert_called_once_with(
['mount', '-o', 'options', '/dev/some-device', '/some/mountpoint']
)
Expand Down
Loading