Skip to content

Commit ca2b17e

Browse files
Update readme and make virtio-fs optional
If -s parameter is empty, virtio-fs is unused. Add the explanation about virtio-fs in `Usage` of README.md.
1 parent 254d4b3 commit ca2b17e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ You can exit the emulator using: \<Ctrl-a x\>. (press Ctrl+A, leave it, afterwar
7777
## Usage
7878

7979
```shell
80-
./semu -k linux-image [-b dtb-file] [-i initrd-image] [-d disk-image]
80+
./semu -k linux-image [-b dtb-file] [-i initrd-image] [-d disk-image] [-s mount-folder]
8181
```
8282

8383
* `linux-image` is the path to the Linux kernel `Image`.
8484
* `dtb-file` is optional, as it specifies the user-specified device tree blob.
8585
* `initrd-image` is optional, as it specifies the user-specified initial RAM disk image.
8686
* `disk-image` is optional, as it specifies the path of a disk image in ext4 file system for the virtio-blk device.
87-
87+
* `mount-folder` is optional, as it specifies the path of a folder you want to mount in host.
8888
## Build Linux kernel image and root file system
8989

9090
An automated build script is provided to compile the RISC-V cross-compiler, Busybox, and Linux kernel from source.

main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,10 @@ static void map_file(char **ram_loc, const char *name)
536536

537537
static void usage(const char *execpath)
538538
{
539-
fprintf(
540-
stderr,
541-
"Usage: %s -k linux-image [-b dtb] [-i initrd-image] [-d disk-image]\n",
542-
execpath);
539+
fprintf(stderr,
540+
"Usage: %s -k linux-image [-b dtb] [-i initrd-image] [-d "
541+
"disk-image] [-s mount-folder]\n",
542+
execpath);
543543
}
544544

545545
static void handle_options(int argc,

virtio-fs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,11 @@ bool virtio_fs_init(virtio_fs_state_t *vfs, char *mtag, char *dir)
833833

834834
vfs->priv = &vfs_configs[vfs_dev_cnt++];
835835

836+
if (!dir) {
837+
/* -s parameter is empty, virtio-fs is unused. */
838+
return NULL;
839+
}
840+
836841
int dir_fd = open(dir, O_RDONLY);
837842
if (dir_fd < 0) {
838843
fprintf(stderr, "Could not open directory: %s\n", dir);

0 commit comments

Comments
 (0)