mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Lots of hacking to make a very simple "ls" utility.
I added a dead-simple malloc that only allows allocations < 4096 bytes. It just forwards the request to mmap() every time. I also added simplified versions of opendir() and readdir().
This commit is contained in:
parent
0c5bbac86e
commit
bca4b71bfa
19 changed files with 277 additions and 67 deletions
|
@ -1,21 +1,17 @@
|
|||
#include <LibC/stdio.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibC/mman.h>
|
||||
#include <LibC/dirent.h>
|
||||
|
||||
int main(int c, char** v)
|
||||
{
|
||||
int fd = open("/");
|
||||
if (fd == -1) {
|
||||
printf("failed to open / :(\n");
|
||||
DIR* dirp = opendir("/");
|
||||
if (!dirp) {
|
||||
printf("opendir failed :(\n");
|
||||
return 1;
|
||||
}
|
||||
while (auto* de = readdir(dirp)) {
|
||||
printf("%s\n", de->d_name);
|
||||
|
||||
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