Skip to content

Commit

Permalink
Merge pull request #1 from cmercur2/filesystem-time-corrections
Browse files Browse the repository at this point in the history
Correcting errors with filesystem time
  • Loading branch information
coltonmercurio committed Apr 12, 2016
2 parents 4a2090e + 394d884 commit 56c4892
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
26 changes: 14 additions & 12 deletions demos/jor1k-worker-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -5131,23 +5131,23 @@ FS.prototype.CheckEarlyload = function(path)
// The filesystem is responsible to add the correct time. This is a hack
// Have to find a better solution.
FS.prototype.AppendDateHack = function(idx) {
if (this.GetFullPath(idx) != "etc/init.d/rcS") return;
if (this.GetFullPath(idx) != "home/user/.profile") return;
var inode = this.inodes[idx];
var date = new Date();
var datestring =
"\ndate -s \"" +
date.getFullYear() +
date.getUTCFullYear() +
"-" +
(date.getMonth()+1) +
(date.getUTCMonth()+1) +
"-" +
date.getDate() +
date.getUTCDate() +
" " +
date.getHours() +
date.getUTCHours() +
":" +
date.getMinutes() +
date.getUTCMinutes() +
":" +
date.getSeconds() +
"\"\n";
date.getUTCSeconds() +
"\" &>/dev/null\n";
var size = inode.size;
this.ChangeSize(idx, size+datestring.length);
for(var i=0; i<datestring.length; i++) {
Expand Down Expand Up @@ -5206,10 +5206,7 @@ FS.prototype.LoadFile = function(idx) {
inode.data = new Uint8Array(buffer);
if (inode.size != inode.data.length) message.Warning("Size wrong for uncompressed non-lazily loaded file: " + inode.name);
inode.size = inode.data.length; // correct size if the previous was wrong.
inode.status = STATUS_OK;
if (inode.name == "rcS") {
this.AppendDateHack(idx);
}
inode.status = STATUS_OK;
this.filesinloadingqueue--;
this.HandleEvent(idx);
}.bind(this);
Expand Down Expand Up @@ -5359,6 +5356,11 @@ FS.prototype.OpenInode = function(id, mode) {
this.LoadFile(id);
return false;
}

if (inode.name == ".profile") {
this.AppendDateHack(id);
}

return true;
}

Expand Down
26 changes: 14 additions & 12 deletions js/worker/filesystem/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,23 @@ FS.prototype.CheckEarlyload = function(path)
// The filesystem is responsible to add the correct time. This is a hack
// Have to find a better solution.
FS.prototype.AppendDateHack = function(idx) {
if (this.GetFullPath(idx) != "etc/init.d/rcS") return;
if (this.GetFullPath(idx) != "home/user/.profile") return;
var inode = this.inodes[idx];
var date = new Date();
var datestring =
"\ndate -s \"" +
date.getFullYear() +
date.getUTCFullYear() +
"-" +
(date.getMonth()+1) +
(date.getUTCMonth()+1) +
"-" +
date.getDate() +
date.getUTCDate() +
" " +
date.getHours() +
date.getUTCHours() +
":" +
date.getMinutes() +
date.getUTCMinutes() +
":" +
date.getSeconds() +
"\"\n";
date.getUTCSeconds() +
"\" &>/dev/null\n";
var size = inode.size;
this.ChangeSize(idx, size+datestring.length);
for(var i=0; i<datestring.length; i++) {
Expand Down Expand Up @@ -284,10 +284,7 @@ FS.prototype.LoadFile = function(idx) {
inode.data = new Uint8Array(buffer);
if (inode.size != inode.data.length) message.Warning("Size wrong for uncompressed non-lazily loaded file: " + inode.name);
inode.size = inode.data.length; // correct size if the previous was wrong.
inode.status = STATUS_OK;
if (inode.name == "rcS") {
this.AppendDateHack(idx);
}
inode.status = STATUS_OK;
this.filesinloadingqueue--;
this.HandleEvent(idx);
}.bind(this);
Expand Down Expand Up @@ -437,6 +434,11 @@ FS.prototype.OpenInode = function(id, mode) {
this.LoadFile(id);
return false;
}

if (inode.name == ".profile") {
this.AppendDateHack(id);
}

return true;
}

Expand Down

0 comments on commit 56c4892

Please sign in to comment.