Miscellaneous

I’ve been keeping quite busy the last few months, thanks to the extremely time-consuming but fun masters program I’m enrolled in. Sure, I’ve also ensured that I enjoy Europe while I’m at it, but that makes my blog posts much less frequent and further apart. Between “micro-blogging” and frequent facebook updates, there is much less time for blogging these days ;)

It’s spring now and we can all stop complaining about the Dutch weather. The temperature stays around a pleasant 10 to 15 degrees. One of the more recent trips I made to take advantage of the season was to Keukenhof, the famous flower garden. Check out selected pictures here.

As I try to wrap up some of my pending assignments (did I mention they were fun?), I’m also preparing for travel in the next 2 weeks. First stop, Mountain View, for an “All Hands” session at Mozilla. Next, I head out to Italy, starting with Milan, and then heading on to Venice, Rome, the Vatican and Pisa. Looking forward to the trip!

In other news, the GSoC results were announced recently, and I’m continuing my mentoring role from last year with two students. Even though Glendix didn’t make it to the organisations list, we got several good proposals via Plan 9 and Gentoo, which was certainly very encouraging. This time, India has the second largest number of student selections (101!) – simply marvelous :) This will be my 4th Summer of Code, and I’m very happy to be involved with the program for this long.

Cheerio!

The Summer of Code is here again!

It’s that time of the year. Google is, yet again, sponsoring students to write some awesome open source code this summer. If you’re a student, and you’d like to make some money contributing to some of the most well known and exciting open source software projects out there, you’d be missing out on a lot by not applying.

If you’re wondering about what the best way to get started is, check out this great advice page. All projects have also been tagged by programming language and field in this delicious profile. You can also search for ideas here.

I’m going to be mentoring for Mozilla, Glendix (under the Plan 9 Umbrella) and Gentoo this year. Get in touch if you’re interested in any of those ideas :)

The window for applications opens in a few hours. Good luck everyone!

FOSS.IN/08: Summary

As a developer, I have to say that FOSS.IN/08 is possibly the most productive conference I’ve been to until now! In just 5 days, I’ve got more things done than I have in the last 5 months :-)

Let’s start with the Beacon workout: Nandeep joined us via VoIP and we got started almost immediately, thanks to the dynamic nature and small size of our project – we didn’t have any infrastructural trouble as a few other C/C++ projects with huge codebases and complex build systems did. We had a list of 6 tasks in mind, and we managed to complete 3 of them. Salil Kothadia got started with writing a PDO data backend, and promptly submitted the patch to us next day. Thanks Salil, hope you continue to contribute to the development of Beacon (thereby increasing the development team size by 25%)!

I also attended Philip’s workout on porting HTML::Template to Javascript. As mentioned on the Wiki page, we mostly worked on the design during the first half or so, and then moved on to writing a skeleton for the whole framework. I think this is an extremely interesting project, and am very happy to be associated with its birth. Hope we can continue the momentum and work until it is finished.

Perhaps the biggest take-away from the conference for me was the ability to give a lightning talk about Glendix, with several kernel hackers present in the audience. Christoph then kindly offered to review some of the patches during the workout. Even the possibility of Plan 9 binary emulation being considered for inclusion into the main kernel tree is amazing, let alone the fact that I got the guidance of an experienced kernel hacker for a good 2 hours! I think the effort was largely successful – I now have a better idea of what I need to do in order to get a kernel patch in order, and also got a few hints as to how I can implement the missing bits.

My primary focus at the conference was to give a talk on Mozilla Labs and Innovation. I think I managed to stir up a decent amount of interest in the various Labs initiatives. I covered the different ways in which members of the community can contribute, specifically focussing on Weave, Ubiquity and the Concept Series. We even covered how easy it is to actually write an Ubiquity command. I now look forward to increased participation by the Indian Mozilla community in Labs projects. Don’t forget to thank Mary for all the goodies!

All this, apart from regular conference happenings like catching up with old friends, making new ones and free swag (great mugs and t-shirts this time around) makes FOSS.IN/08 one of the most successful conferences I’ve been to so far! I can’t wait for the 2009 edition :-D

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!

IWP9 2008

Continuing with my travel spree, I made a trip to Volos, Greece and back for the 3rd International workshop on Plan 9. I was to make short presentation on Glendix, a paper on which was selected for the workshop.

Being a brown single guy in his early twenties, traveling around Europe is not exactly fun. Just saying. I got picked out not once, not twice, but THREE times for “random passport and security checks”. Once in Munich on my way to Volos, once on the streets of Athens, and finally on my way back at the Frankfurt airport. Not that I’m complaning, they were just doing their job; but really, they need to get better at profiling.

Athens is a really nice city, though it reminds me of India: crowded trains, chaotic traffic and sketchy bus stations. I knew most of the Greek symbols, thanks to high school Math courses, but pronouncing them wasn’t easy. Thankfully, the people at the counters in the Airport, Bus and Metro stations knew English. After a 5 hour bus ride, I reached Volos in the wee hours of Thursday. After around 3 hours of sleep and about 30 minutes of slide preparation, I was set for my talk.

Considering I was at a Plan 9 conference, talking about integrating it into Linux, my talk was very well received. Certainly beyond my general expectations: I got some really excellent questions, comments and general observations, and most importantly, a lot of help on the current issues that Glendix faces. All the other talks during the conference were extremely interesting as well, I was particularly fascinated by the concept of “Upperware”, the Inferno port to Nindento DS, and the Mrph morphological analyzer. Do check out the entire conference proceedings.

It was great to finally meet all the Plan 9 and Bell Labs folks in-person, especially: Sape Mullender, Charles Forsyth, Bruce Ellis; not to mention the IRC regulars uriel, quintile, sqweek and fgb!

The return trip was a bit more scenic, thanks to it being afternoon. After spening the night in Athens, I was back in Amsterdam the next day. More adventures followed, but that’s for another blog post.

Nothing like a trip to IWP9 to humble you!

P.S. Cool Glenda goodies for sale at Cafepress :-)

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!

Follow

Get every new post delivered to your Inbox.