blob: f11bf217b1b0bd6d739f5c1117fbc4c461b4d83e (
plain)
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
38
39
40
41
42
43
44
45
46
|
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <dlfcn.h>
#include <stdint.h>
#include <sys/io.h>
#include <rump/rump_syscalls.h>
#include <rump/rump.h>
#include <rump/rumperrno2host.h>
static void
die (const char *msg)
{
int err = rump_errno2host(errno);
fprintf(stderr, "%s : errno = 0x%08x\n", msg, err);
exit(rump_errno2host(errno));
}
void mount(char *blockdev)
{
int fd;
int err;
char buf[8192] = {0};
if ((fd = rump_sys_open(blockdev, RUMP_O_RDONLY)) == -1)
die("open disk failed\n");
else {
printf("found %s\n", blockdev);
err = rump_sys_read(fd, buf, 512);
for (int i = 0; i < 512; i++) {
printf ("%0x ", buf[i]);
}
printf ("\nERR=%d\n", err);
}
}
int main(int argc, char **argv)
{
rump_init();
if (argc != 2) {
fprintf(stderr, "Usage: %s /dev/xxx\n", argv[0]);
exit(1);
}
mount(argv[1]);
rump_sys_reboot(0, NULL);
exit(0);
}
|