mirror of
https://github.com/sigmasternchen/Wish
synced 2025-03-15 07:28:56 +00:00
some changes in filesystem
This commit is contained in:
parent
b59e02031c
commit
35ee5b67b4
2 changed files with 26 additions and 2 deletions
|
@ -81,6 +81,30 @@ Kernel.Filesystem.devfs.populate = function() {
|
|||
return true;
|
||||
}
|
||||
Kernel.Filesystem.devfs.files.push(tty);
|
||||
|
||||
var urandom = new InnerFile();
|
||||
urandom.name = "urandom";
|
||||
urandom.id = Kernel.Filesystem.vfs.index++;
|
||||
urandom.ownerID = 0;
|
||||
urandom.groupID = 0;
|
||||
urandom.parent = NO_PARENT;
|
||||
urandom.permissions = PERM_OR | PERM_GR | PERM_UR;
|
||||
urandom.created = timestampOfCreation;
|
||||
urandom.changed = timestampOfCreation;
|
||||
urandom.onChange = function (content) {
|
||||
// writing to /dev/urandom does nothing
|
||||
return false;
|
||||
}
|
||||
urandom.removeReaded = true;
|
||||
urandom.neverEnds = true;
|
||||
urandom.onRead = function (number) {
|
||||
if (!number)
|
||||
number = 4294967296; // 2^32; cheat because we can't generate inf random numbers at once.
|
||||
for (var i = 0; i < number; i++)
|
||||
this.content += String.fromCharCode(parseInt(Math.random() * 65536));
|
||||
return true;
|
||||
}
|
||||
Kernel.Filesystem.devfs.files.push(urandom);
|
||||
}
|
||||
Kernel.Filesystem.devfs.mount = function () {
|
||||
var point = new MountPoint();
|
||||
|
|
|
@ -156,7 +156,7 @@ Kernel.Filesystem.read = function(path, length, index, readMode) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!file.onRead())
|
||||
if (!file.onRead(length))
|
||||
return "";
|
||||
var content = file.content;
|
||||
|
||||
|
@ -173,7 +173,7 @@ Kernel.Filesystem.read = function(path, length, index, readMode) {
|
|||
|
||||
var text = "";
|
||||
if (length !== undefined) {
|
||||
if (index !== undefined) {
|
||||
if (index !== undefined && !file.neverEnds) {
|
||||
text = content.substring(index, length + index);
|
||||
if ((text.length < length) && (!file.neverEnds))
|
||||
text += EOF;
|
||||
|
|
Loading…
Reference in a new issue