Skip to content

Support access to block devices in the /dev directory #544

Closed
@ChinYikMing

Description

@ChinYikMing

Regarding #539, a disk image needs to be created. However, this approach is not suitable when we want the guestOS to directly access existing devices in the /dev directory, such as USB devices. Instead, we should allow specifying the path directly within the /dev directory, like /dev/sda2.

To achieve this, the current method of determining the disk image size using the fstat utility works well for disk images but is not applicable for devices like /dev/x. Therefore, ioctl should be used to retrieve the actual size of the /dev/x device.

Additionally, since exFAT is not natively supported on Linux, the exFAT (FUSE) utility (mount.exfat) should be installed on the guestOS. Moreover, the FUSE driver for Linux (Filesystem in Userspace) shall be enabled.

With these changes, my 8 GiB pendrive formatted with exFAT will be recognized by the guestOS.

Reproduce:

$ build/rv32emu -k <kernel_img_path> -i <rootfs_img_path> -x vblk:/dev/x

Boot log:

[    0.794639] virtio_blk virtio0: 1/0/0 default/read/poll queues
[    0.795975] virtio_blk virtio0: [vda] 15118336 512-byte logical blocks (7.74 GB/7.21 GiB)
[    0.889019] clk: Disabling unused clocks
[   13.805726] Freeing initrd memory: 65532K
[   13.807322] Freeing unused kernel image (initmem) memory: 176K
[   13.807519] Kernel memory protection not selected by kernel config.
[   13.807725] Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: OK

Welcome to Buildroot
buildroot login: root
# mkdir mnt
# mount.exfat /dev/vda mnt
FUSE exfat 1.4.0 (libfuse3)
#

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions