/net in Linux: project log

A Glendix project

My first /net code commited!

Week 5 :-

My first commit into Glendix (and incidentally and surprisingly, the first non-Anant Narayanan commit to the project!).

The design for the inode and file creation is much the same as lwnfs. I added the mechanism for read and write of files created in the /net. One of the issues I ran into was using the i_private field of the inode to point to the buffer created to store the input content in slashnet_write_file(). See comment at the bottom of this function to know more about this issue.

UPDATE:- Some memory leaks. I forgot to use kfree() after kmalloc(). Gamers will call that n00b error?! lol!

February 23, 2009 Posted by | Glendix, libfs, Linux kernel, Networking, Plan 9 from Bell Labs, vfs | Leave a Comment

Learning to write a Systhetic Filesystem on Linux

Week 4:-

Before I start with /net, I wanted to try implementing a sample FS. I thank lwn.net for providing that piece of documentation. I implemented the lwnfs.c in my home folder like they mentioned. NOTE:- A patch is needed on newer kernel versions.

My Makefile looks something like:

ifneq ($(KERNELRELEASE),)
obj-m   := lwnfs.o
else
KDIR    := /lib/modules/$(shell uname -r)/build
PWD     := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
endif

Remember, once the filesystem compiles, you need to mount the fs.
i.e. rahul@Glendix$ mount -t lwnfs none /lwnfs

Cant wait for the day when “mount -t net none /net” works!

February 19, 2009 Posted by | Glendix, libfs, Linux kernel, vfs | Leave a Comment

Discussion on 9Fans

9Fans is the official Plan 9 mailing list. Most of Glendix’s discussions are done on that channel and it is our contact with the relatively small Plan 9 community.

Here’s link to my Feb 06, 2009 email announcing my /net project among other things:

http://9fans.net/archive/2009/02/168

No real comment so far on the idea itself, although project Glendix gained another member: J.R. Mauro (a.k.a. thedoctor).

NOTE:- Catch us at #glendix channel on Freenode. We at Glendix like IRC more than mailing lists.

February 13, 2009 Posted by | Glendix, Plan 9 from Bell Labs | Leave a Comment

Plan 9 Cheat Sheet

This post is a cheat sheet of Plan 9 shell commands, different from Linux.

Linux Command  —->  Plan 9 equivalent

1) rahul@linux$ find . -name ‘cs.c’ -print  —->  term% du -a . | grep cs.c
Comments: Notice the Plan 9′s philosophy of using one program for one action?
Also, try running “du -a .” on Plan 9, it is so much faster than even “slocate” on Linux, let alone “find . -name” !!

2) Ctrl+C exit signal for running scripts  —->  “Delete” key on the keyboard.
Comments: Another example of how old UNIX is. They probably had no “Delete” key when UNIX was designed, so they used “Ctrl+C” which, logically speaking, makes absolutely no sense!

February 10, 2009 Posted by | Cheat Sheet, Plan 9 from Bell Labs | Leave a Comment

Network internals of Plan 9

Week 2:-

Most of this week’s work was to understand how network works in Plan 9 ( See here ).

There is a /net/cs file which is basically the Connection Server. This file does DNS translation. When we write “net!www.google.com!http”, we get back – “/net/tcp/clone 74.125.67.100!80″.

There are many other files and folders inside the /net directory. The /net in my virtual machine looks like this:

> term% ls /net
/net/arp
/net/bootp
/net/cs
/net/dns
/net/ether0
/net/icmp
/net/icmpv6
/net/ipifc
/net/iproute
/net/ipselftab
/net/log
/net/ndb
/net/tcp
/net/udp

After getting back the IP address of the server we are trying to connect to, we need to pass the command “connect 74.125.67.100!80″ command to /net/tcp/clone file. Doing this will return a folder under /net, say /net/ether0/6 .

NOTE:- The above drill of writing to /net/cs and subsequently writing to the clone file has to be done using the “dial” function in C programs, or using the program ndb/csquery, because per-processes namespaces in Plan 9 will otherwise result in returning nothing to a new process started by a shell command like “cat”.

Inside that numbered connection folder under the interface, there are files named data and ctrl among others. When we write to that data file, we send the text to the server, and reading from it will return information received from the otehr end.

Anant and I believe that starting at /net/cs is a good approach. There is a function gethostbyname() in Linux, which is used for DNS. It must be latching on to the Linux kernel DNS module. I must instead do the same using /net/cs .

But step 1, create /net/cs to return the same data that we give it, without resolving anything.

February 5, 2009 Posted by | Glendix, Networking, Plan 9 from Bell Labs | Leave a Comment

   

Follow

Get every new post delivered to your Inbox.