diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-08 15:39:26 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-08 15:39:26 +0100 |
commit | 3b2dcd5929316dae75147c84b243ae69a2101af5 (patch) | |
tree | e121ba2b1c6cb6fcdfd6d36c0392e3c15066ec17 /Userland | |
parent | 862f108cb5cf0c3708f245aaf9620c674f371fa0 (diff) | |
download | serenity-3b2dcd5929316dae75147c84b243ae69a2101af5.zip |
Add a VMO pointer to VNode.
This way, if anyone tries to map an already mapped file, we share the VMO.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/sh.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/sh.cpp b/Userland/sh.cpp index e20dbb9d1a..1fa46877ae 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -139,6 +139,27 @@ close_it: return 0; } +static int sh_mp(int, const char**) +{ + int rc; + int fd = open("/kernel.map", O_RDONLY); + if (fd < 0) { + perror("open(/kernel.map)"); + return 1; + } + printf("opened /kernel.map, calling mmap...\n"); + byte* data = (byte*)mmap(nullptr, getpagesize() * 10, PROT_READ, MAP_PRIVATE, fd, 0); + if (data == MAP_FAILED) { + perror("mmap()"); + return 1; + } + printf("mapped file @ %p\n", data); + printf("contents: %c%c%c%c%c%c%c...\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); + + printf("leaving it open :)\n"); + return 0; +} + static int sh_exit(int, const char**) { printf("Good-bye!\n"); @@ -221,6 +242,10 @@ static bool handle_builtin(int argc, const char** argv, int& retval) retval = sh_mf(argc, argv); return true; } + if (!strcmp(argv[0], "mp")) { + retval = sh_mp(argc, argv); + return true; + } if (!strcmp(argv[0], "fork")) { retval = sh_fork(argc, argv); return true; |