-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdemo-fs.c
More file actions
37 lines (28 loc) · 760 Bytes
/
demo-fs.c
File metadata and controls
37 lines (28 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Mount the kernfs file system inside the rump kernel and read
* version info from it. It should be the same as the one displayed
* as part of a verbose boot.
*/
#include <linux/kernel.h>
#include <linux/bug.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
void rumpkern_demo(void);
void
rumpkern_demo(void)
{
char buf[256];
ssize_t nn;
int fd, rv;
printk(KERN_INFO "reading rump kernel version from kernfs/version:\n");
rv = rump_sys_mkdir("/mnt", 0777);
BUG_ON(rv == -1);
rv = rump_sys_mount("kernfs", "/mnt", 0, NULL, 0);
BUG_ON(rv == -1);
fd = rump_sys_open("/mnt/version", RUMP_O_RDONLY, 0);
BUG_ON(rv == -1);
nn = rump_sys_read(fd, buf, sizeof(buf));
BUG_ON(nn < 1);
buf[nn] = '\0';
printk(KERN_INFO "%s", buf);
}