mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
Add simplified mmap() and munmap() syscalls.
This commit is contained in:
parent
a5caf7ca99
commit
9a296d63f3
13 changed files with 116 additions and 2 deletions
1
Userland/.gitignore
vendored
1
Userland/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
id
|
||||
sh
|
||||
ps
|
||||
ls
|
||||
*.o
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
OBJS = \
|
||||
id.o \
|
||||
sh.o \
|
||||
ps.o
|
||||
ps.o \
|
||||
ls.o
|
||||
|
||||
APPS = \
|
||||
id \
|
||||
sh \
|
||||
ps
|
||||
ps \
|
||||
ls
|
||||
|
||||
ARCH_FLAGS =
|
||||
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib
|
||||
|
@ -35,6 +37,9 @@ sh: sh.o
|
|||
ps: ps.o
|
||||
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||
|
||||
ls: ls.o
|
||||
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||
|
||||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
|
|
21
Userland/ls.cpp
Normal file
21
Userland/ls.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <LibC/stdio.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibC/mman.h>
|
||||
|
||||
int main(int c, char** v)
|
||||
{
|
||||
int fd = open("/");
|
||||
if (fd == -1) {
|
||||
printf("failed to open / :(\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
byte* memory = (byte*)mmap(nullptr, 16384);
|
||||
printf("%p\n", memory);
|
||||
memory[0] = 'H';
|
||||
memory[1] = 'i';
|
||||
memory[2] = '!';
|
||||
memory[3] = '\0';
|
||||
printf("%p : %s\n", memory, memory);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue