7

I don't know much of Javascript, and I want to host the web browser integrated Linux (which can be found here). Reason being I am not always connected to the net, would like to know how it works. No disrespect of the author's license intended.

I tried copying sources of the three files (term.js, cpux86.js and the HTML file itself) into a folder, and running the HTML, and it doesn't work.

Any way around to make it work?
Also: if it doesn't work, why is it? The directory structure is copied by me and is almost the same.

PS: I also used Javascript deobfuscator addon for Firefox, but that did not help much either. I did indent all the code to make it more readable, but it's still not understandable :P

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Anuj More
  • 122
  • 8
  • 2
    My plans are to install Lynx inside the system and open the same website from the virtual machine. That would be really meta. (Considering even GCC is not installed, it is going to be very hard) Comments on that would be appreciated too. – Anuj More May 17 '11 at 14:55
  • If you don't know much javascript figuring out Patrice's js wrapper for linux is not going to be easy – Richard H May 17 '11 at 14:57
  • I know. I badly need some hardcore programmers to make my 9hr dream (either of running it locally or going meta with it) come true. – Anuj More May 17 '11 at 14:58
  • @Anuj - there is no network interface implemented in jslinux, so unless your're going to copy the source for lynx by hand i don't know how you will do this. – Richard H May 17 '11 at 14:59
  • You can't copy paste an uuencoded document either. I was planning on writing a keyboard emulator to type the uuencoded tar into the machine (Just because you can't copy-paste text) – Anuj More May 17 '11 at 15:08
  • 1
    i've just upvoted you only for the link you provided... It's awesome :-D – Grooveek May 17 '11 at 15:11
  • Grooveek: It will be awesomer if we actually get to know how that thing exactly works. Check Richard's link to the documentation below. Nice place to start with. – Anuj More May 17 '11 at 15:41

4 Answers4

1

The JS code itself is not a "Linux clone", it's a propper x86 Virtual Machine loading a Linux kernel.

As such you need at least the file containing the compiled Linux kernel for it to work correctly.

Checking the source shows that (at least) 3 files are loadded from cpux86.js, which are: vmlinux26.bin (the Linux kernel), root.bin (probably the root file system) and linuxstart.bin (this seems to be the bootloader).

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • Right. The image (as my friend on IRC just found out through chrome-network-analyzer) is around 1.2MB. How do I save those bin files from Mozilla Firefox (lsof?) EDIT: Firefox from the host machine. EDIT: Are they stored somewhere in /proc? (Linux host) – Anuj More May 17 '11 at 15:15
  • 3
    @Anuj - you really should read the technical notes http://bellard.org/jslinux/tech.html, they are specially compiled versions. You will have to download them using wget or similar – Richard H May 17 '11 at 15:21
  • @Richard That one deserved an upvote. I will get back when I read this documentation. Thanks :) – Anuj More May 17 '11 at 15:28
1

These are the files you will need:

Throw them in along with this file into a folder and you're good to go:

<html>
<head>
<title>Javascript PC Emulator</title>
<style>
.term {
    font-family: courier,fixed,swiss,sans-serif;
    font-size: 14px;
    color: #f0f0f0;
    background: #000000;
}

.termReverse {
    color: #000000;
    background: #00ff00;
}
#note {
    font-size: 12px;
}
#copyright {
    font-size: 10px;
}

</style>
</head>
<body onload="start()">
<script src="term.js"></script>
<script src="cpux86.js"></script>
<div id="copyright">&copy; 2011 Fabrice Bellard - <a href="tech.html">Technical notes</a></div>
</body>

</html>
Marcelo Mason
  • 6,750
  • 2
  • 34
  • 43
1

In addition to given answers you can try to look at the way I am hosting jslinux on a local server in my jsmodem project at http://github.com/ewiger/jsmodem (allows Internet connectivity).

If you have python installed just start the local web server as

python -m SimpleHTTPServer
Yauhen Yakimovich
  • 13,635
  • 8
  • 60
  • 67
0

I haven't inspected the page but all you need to do is make sure that all assets required are referenced correctly. The js assets are referenced in the page, the linux binaries are loaded from within those scripts somewhere. You're going to have to dig through them and find where, and change the URLs appropriately.

And as for figuring out how the emulation etc works, this project is quite a hacking feat, so good luck :)

Richard H
  • 38,037
  • 37
  • 111
  • 138