Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChinYikMing opened this issue Jan 24, 2025 · 0 comments
Open

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

ChinYikMing opened this issue Jan 24, 2025 · 0 comments
Assignees

Comments

@ChinYikMing
Copy link
Collaborator

ChinYikMing commented Jan 24, 2025

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)
#
@ChinYikMing ChinYikMing self-assigned this Jan 24, 2025
@ChinYikMing ChinYikMing changed the title Support access to devices in the /dev directory Support access to block devices in the /dev directory Jan 25, 2025
ChinYikMing added a commit to ChinYikMing/rv32emu that referenced this issue Feb 20, 2025
The user may not always have a disk image but might have a /dev/x block
device, such as a USB drive that they want to share with the guest OS.
So, allowing this type of virtio-blk source is intuitive. To support
this, ioctl is used to retrieve the actual size of the /dev/x block
device. This implementation supports both Apple and Linux platforms.

Close sysprog21#544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant