oscourse-tsinghua / rcore_plus

Rust version of THU uCore OS. Linux compatible.
MIT License
172 stars 26 forks source link

rCore Loadable Kernel Module: Device file #60

Closed gjz010 closed 5 years ago

gjz010 commented 5 years ago

This requires modification on rcore-fs and rcore-sfs supporting INode::create2 (https://github.com/rcore-os/rcore-fs/pull/7) to work.

  1. Added support for device file. Now developer can override some features of INode. (The example is EMMC for aarch64: the file is to be moved out as a module, though.) Although not used, support for overriding mmap allows us to implement a real /dev/fb0, and support for overriding symbolic link (not implemented, only interface) allows us to implement a real /proc/self/exec.
  2. Allowing filesystem (for example, SFS) to be built on device file, using the interface compatible with BlockDevice. This allows mounting SFS from device file immediately. Now SD card can be tested in the following way:
    /busybox insmod ramfs.ko
    /busybox mount -t ramfs ramfs /dev
    /busybox mknod /dev/emmcblk0 c 179 0
    /busybox mknod /dev/emmcblk0p1 c 179 1
    /busybox mknod /dev/emmcblk0p2 c 179 2
    /busybox mount -t sfs /dev/emmcblk0p2 /mnt

    The SD card image can be generated on your own. It should be a standard img/qcow2 file with MBR table, first partition FAT32 (from the raspi image you like) and second partition SFS. (My SD card image in qcow2 is 60M large, so I'm not sure whether to upload it to rcore-user repository.) The SD card image that I use: https://cloud.tsinghua.edu.cn/f/afcce5488a4644eab186/

  3. Fixed a bug in getcwd (only revealed after mounting SFS).
  4. Added make option -sd for aarch64 only.
    #   sd = <path to sdcard img>    Only available on aarch64, specify a sd card image.