Glendix on the Web!

Glendix has been making the rounds on the web lately, with coverage from OSNews, Reddit, and even a Russian site, Linux.org.ru. It’s really motivating to see some buzz around the project, giving me the extra boost needed to push the completion of a usable release!

Some of the major obstacles that have to be crossed before making a beta-quality release are the completion of critical synthetic filesystems – especially /net and /draw. We also have to work out the kinks with per-process namespaces and union mounts. I don’t know if we’ll be able to get Rio running as a WM before an official release; if not, Plan9Port‘s Rio and WMII are good candidates.

The biggest criticism of Glendix seems to be the reasoning that Plan9 user-space tools are somehow superior to their GNU counterparts, and several people have asked us to substantiate our claims. At this point, however, I don’t think that it is really important, or even relevant. Even if Plan9 user-space tools aren’t somehow better – I think it is generally a refreshing idea to see Linux combined with a user-space other than GNU.

We’re at FOSS.IN this year, where a large number of kernel developers have gathered; and I hope to get some of their valuable input on the problems Glendix currently faces, and maybe even write some code to solve them :-)

Thanks for all the community support and critical comments, they are all very vital feedback for the project and are much appreciated!

FOSS.IN 08: Mozilla Labs, Beacon and Glendix

FOSS.IN 2008 begins tomorrow!

It’s going to be really interesting to see how the departure from the ‘07 formula works out.

I’ll be conducting a Workout on Beacon, the web-based GuideXML editor on Day 4 (Friday). If you’re interested in contributing to a next generation AJAX powered web application and are familiar with Javascript with a bit of PHP or Python, I highly recommend dropping in!

There will also be a talk on Innovation and Mozilla Labs on Day 5 (Saturday), where we’ll take Weave as a case-study to see how ideas are incubated at the Labs. I’ll be talking about how you can contribute to the various initatives at Mozilla Labs. Or maybe you’re just curious about the future of the web and how you can help shape it. In any case, you want to be there (*hint* there will be goodies *hint*)!

Two Glendix hackers, myself and Shantanu are also going to be at the event, and there’s a whole day dedicated to Linux kernel hacking. I’m planning a lightning talk on Glendix during the gathering,  and hopefully we can gather enough interest to get some work done on some of the project’s priorities!

See you at India’s largest FOSS event :-)

Weeks 8 & 9: Load balancing, OAuth

So, after a fun July 4 weekend at Atlanta (which comprised of visits to white water and stone mountain, not to mention quality time with family and some amazing mini-golf), it was back to work.

Week 8 was mostly consolidating the server-side, as post 0.2 releases of Weave increased the number of active users. We needed to make sure we can scale well (one of the main reasons why WebDAV was chosen as a data store), so Chris and I came up with a few quick-fixes.

Tip 1: If you have a large number of files or directories in a single directory, consider splitting them into buckets. We put usernames with the same first letter in a directory, sourceforge takes it a step further by creating one-letter directory names and then two-letter ones in them.

Tip 2: There’s only so much load one server can handle. Get another one and load-balance ;-)

Ok, I admit the second tip was not really a tip.

Building scalable web applications is definitely a hard problem; which is why we have some amazing technology like Amazon EC2 and Google App Engine. Hacking up a quick PHP script to do something is one thing, making sure a million users can use it simultaneously is another. Which is why working at the Mozilla Labs has exposed me to an entirely different way of looking at things – sure, it works now – but will it work when thousands of people bang on it? I’m loving it here :-)

One of the other important aspects of Weave that has been doing the rounds is that of data sharing. Sharing your bookmarks with a friend is cool, but sharing your browsing history or bookmarks with a third party web service can potentially lead to some awesome mashups and services.

To maintain the integrity of your (encrypted) data, we need data sharing with third parties to work in a secure way. OAuth is an open protocol to share personal data with services, and we think it’d be an excellent choice for Weave.

This week, I’m looking into the OAuth spec and coming up with a suitable implementation for Weave. This will also potentially tie-in to the web client (previewed earlier) – you could authorize your own web server (on which you setup the web client) to access your data and decrypt it server-side to make the client a lot more faster, while losing none of the security.

On a different note, if you haven’t read Jono’s post on software development and UIs yet, DO IT NOW. Definitely one of the best posts I’ve seen around the blogosphere in a while.

Well, back to discussing fun – we interns had a basketball match with the full-timers today. And there’s more to come: some of us have tickets to the opening of The Dark Knight tomorrow, followed by the Intern BBQ on Friday (co-incidentally, also my 21st birthday). As if that weren’t enough, I’m going to Los Angeles to catch Russell Peters on Saturday, and maybe spend Sunday at Disneyland.

And then, there’s the summit, no saying what we’re in for ;)

Weave 0.2!

It’s been a long night, but Weave 0.2 is finally out! Grab it while it’s hot :)

The last week was mostly spent sprinting towards this release. We’ve fixed over 75 bugs, the major features being: streamlined first-run experience; passwords, tabs and form history synchronization; switch to NSS-based component instead of openssl; better encryption (AES and RSA instead of DES3); and general performance improvements. For a more detailed overview of the changes, check out the release notes.

Ubuntu users: You can’t use the Firefox that the package manager installs, you need to get a stock build here and use that instead. (This is because Ubuntu doesn’t include some parts of Firefox that Weave depends on).

I’m really excited to be a part of this, because I’m very new to the feeling of being part of a team that writes software that a ton of people use. Within minutes of the release, we started getting feedback from users; which is really awesome, and I doubt I can get this kind of experience elsewhere.

I’m also a little nervous, because I got to work on some of the server-side code that Weave depends on, and I’ve actually never written code that is going to be tested by thousands of people. My only hope is that all goes well and that I didn’t break something. My best moment was when I wiped all the old accounts to start afresh (that means all 0.2 users have to register again, irrespective of whether they had an account before. Weave should automatically popup a registration wizard when you install it). All in all, it’s been a wonderful experience so far, and I definitely look forward to more releases working at the Labs!

On a side note, the Labs upgraded to a really snazzy looking website today, going hand-in-hand with the 0.2 release.

So, I’ll be heading to bed now, and check if the world hasn’t ended tomorrow morning. Enjoy the new Weave release!

The joy of combination

As some of you may already know, I’ve been working on the Glendix project for quite some time now. The basic idea is to combine the Linux kernel with utilities from Plan 9, in order to create a developer-oriented operating system distribution. I say it would combine the best of both worlds, but there are those who disagree :)

I’ve been working on the project by splitting the project into two separate modules. The first module was to make Linux understand the Plan 9 a.out binary format – and this was easily done by writing a kernel module, using existing binfmt functionality. The second part was to make Linux understand Plan 9 system calls, so it wouldn’t choke when the binaries are actually executed.

The usual way in which user-space applications communicate with the kernel in almost all modern operating systems is via system calls. What differentiates these operating systems from each other in this aspect, are the number of calls, and the mechanism by which they are invoked.

For instance, Linux applications use the INT instruction to raise software interrupt 0×80 (We’re only dealing with the x86 architecture here). The number stored in the accumulator (EAX) at the time the interrupt was raised is used to tell the kernel which system call is to be invoked. The arguments, if any, to the system call are passed via the other registers (EBX, ECX, EDX…) On the other hand, Plan 9 applications use interrupt number 0×40 (don’t ask why) to invoke a system call. The system call number is put on the accumulator, but the arguments are passed just like to any other regular function – on the (user-space) stack.

Writing the code for this part turned out to be a little tricky, since: a) Linux does not give us a clean way to capture software interrupts, and b) the argument passing convention is different. I finally resorted to patching the kernel rather than writing a module. Brute force, but it works!

So, till now, each of the two modules were working as expected when tested individually. I tested the first module by assembling a program using Linux conventions in Plan 9:

DATA string<>+0(SB)/8, $"Linux\n\z\z"
GLOBL string<>+0(SB), $8

TEXT _main+0(SB), 1, $0

/* Arguments for write(2) */
MOVL $1, BX
MOVL $string<>+0(SB), CX
MOVL $7, DX

/* Number for sys_write is 4 */
MOVL $4, AX
INT $0x80

/* Argument for exit(2) */
MOVL $0, BX

/* Number for sys_exit is 1 */
MOVL $1, AX
INT $0x80

After running `8a hello.s; 8l hello.8′, copying the executable to Linux and running it, it worked. The other module, I tested by writing a program for nasm in Linux, but this time using Plan 9 conventions:

section .data
    hello: db 'Hello World!', 10
    hlen: equ $-hello

section .text
    global _start

_start:
    ; 4 arguments for plan 9's pwrite call, last one is vlong (8 bytes)
    push 1
    push hello
    push hlen
    push 0
    push 0

    ; syscall number for pwrite is 51
    mov eax, 51
    int 64

    ; sycall number for exit is 8
    mov eax, 8
    int 64

After running `nasm -f elf hello.asm; ld -o hello hello.o; ./hello’, the output came onto the screen as expected. Now, the moment of truth, the ultimate test, was to combine the two portions of the project and run a Plan 9 executable directly on Linux :)

$ ./convert 8.out
P9: 1eb 4af9 94c 314 1034
P9: Padding 4b19 bytes from 4af9
Done! Output written to linux.out
$ ./linux.out
Segmentation fault
$ dmesg | tail -n 1
linux.out[7762]: segfault at c0000000 eip 00001051 esp bfffffb8 error 5

Damn, what went wrong? The first step was to find out what error 5 meant. The strerror function is supposed to be used for returning meaningful strings corresponding to cryptic error numbers, but all I got as output, a small program later, was ‘Input/output error’. Big help that was :p

Closer inspection of eip and esp revealed a bug in the loader I wrote earlier. The instruction at address 0×1051 was a MOVL to a stack offset (4(SP)), which resolved to 0xC0000000. However, the main function also receives arguments (namely argc and argv), so the loader had to accommodate those values and set the stack pointer to a little lower value (which is around 0xBFFFF000 in the average case). Voila, the hello world program worked after that small tweak. Ah, the joy of combination :)

We’re still a while away from getting 8c to run though, I’m going to be implementing all the system calls it needs one by one, starting with brk. Updated sources can be found here. See you later!

Command History

Looks like everyone’s doing one of these around the blogosphere lately, so I’m joining in the fun:

[theghost ~]$ uname -a
Darwin theghost.local 9.2.2 Darwin Kernel Version 9.2.2: Tue Mar  4 21:17:34 PST 2008;
root:xnu-1228.4.31~1/RELEASE_I386 i386
[theghost ~]$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
118 ls
81 cd
61 hg
39 exit
29 vi
24 ssh
24 mate
23 grep
19 rm
9 wget

And for the Linux virtual machine:

anant@tg-nix ~ $ uname -a
Linux tg-nix 2.6.24-gentoo-r1 #32 SMP Sun Apr 13 09:15:20 IST 2008
i686 Genuine Intel(R) CPU T2600 @ 2.16GHz GenuineIntel GNU/Linux

anant@tg-nix ~ $ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
142 ls
88 cd
83 sudo
48 vi
33 emerge
30 exit
8 rm
8 mv
7 startx
7 cmake

I’m going to leave it for you to figure out what mate is :)

Follow

Get every new post delivered to your Inbox.