1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 05:35:07 +00:00

Add a simple /dev/random.

This commit is contained in:
Andreas Kling 2018-10-15 00:44:54 +02:00
parent 9528edab92
commit 05b088ee2f
5 changed files with 65 additions and 1 deletions

View file

@ -6,6 +6,7 @@
#include "ZeroDevice.h"
#include "NullDevice.h"
#include "FullDevice.h"
#include "RandomDevice.h"
#include <cstring>
#include <AK/SimpleMalloc.h>
#include <AK/kmalloc.h>
@ -29,6 +30,9 @@ int main(int c, char** v)
auto full = make<FullDevice>();
vfs.registerCharacterDevice(1, 7, *full);
auto random = make<RandomDevice>();
vfs.registerCharacterDevice(1, 8, *random);
if (!vfs.mountRoot(makeFileSystem(filename))) {
printf("Failed to mount root :(\n");
return 1;
@ -187,7 +191,6 @@ int main(int c, char** v)
byte buffer[512];
for (;;) {
nread = handle->read(buffer, sizeof(buffer));
printf("read() returned %d\n", nread);
if (nread <= 0)
break;
fwrite(buffer, 1, nread, stdout);