A => sites/pmikkelsen.com/plan9/basic_9p_server.md +58 -0
@@ 0,0 1,58 @@
+## Writing a basic 9P server
+
+On plan 9 the entire system is build around the idea of namespaces
+and that _"everything is a file"_. For this reason it is very easy to write
+a new 9P fileserver in C since all the boring tasks are implemented in
+libraries. This note describes a minimal program which serves a folder to
+`/mnt/hello9p` containing a single synthetic file with the contents "Hello from 9P!".
+
+## The code
+
+ #include <u.h>
+ #include <libc.h>
+ #include <fcall.h>
+ #include <thread.h>
+ #include <9p.h>
+
+ void
+ fsread(Req *r)
+ {
+ readstr(r, "Hello from 9P!\n");
+ respond(r, nil);
+ }
+
+ Srv fs = {
+ .read = fsread,
+ };
+
+ void
+ main(void)
+ {
+ Tree *tree;
+
+ tree = alloctree(nil, nil, DMDIR|0555, nil);
+ fs.tree = tree;
+ createfile(tree->root, "hello", nil, 0555, nil);
+
+ postmountsrv(&fs, nil, "/mnt/hello9p", MREPL | MCREATE);
+ }
+
+## Explanation
+
+The global variable `fs` is a structure which contains function pointers
+to all the 9P handlers, but since I only plan on reading from the file,
+only the `read` field is set. The fsread function calls two helper functions
+from the 9p(2) library which will create a response with the given string as
+the file contents.
+
+In `main` I start by allocating a new file tree, since this 9P server deals with
+a fileserver that has a tree structure, and therefore I don't have to worry
+about how directories are handled for example. A file is added with `createfile`
+to the root of the tree.
+
+The call to `postmountsrv` will mount the 9P server under `/mnt/hello9p`.
+
+## Thats it
+
+This is not very complicated, but see the manpages at 9p(2) and 9pfile(2)
+and intro(5) for more information about the libraries and 9P itself.
A => sites/pmikkelsen.com/plan9/network_booting.md +30 -0
@@ 0,0 1,30 @@
+## Network booting into the server at pmikkelsen.com
+
+Sometimes it is nice to be able to connect directly to a remote server
+from my laptop and have the same root filesystem available.
+This is possible by typing `tls` at the boot prompt and then
+typing `pmikkelsen.com` for the fs and auth server.
+
+## Speed
+
+On my internet connection some things can be very slow
+(such as compiling the entire system), because of fs access now happens
+over the network. The easy fix is to just start a cpu connection to the server
+where the fs access can happen fast since it is on the same machine. This is
+done by typing
+
+ rcpu -h pmikkelsen.com
+
+Of course the server has a pretty slow cpu..
+
+## Server settings
+
+Some steps are needed to make this work:
+
+1. The user must be added to the fileserver and auth server.
+2. The fileserver must be listening for remote connections.
+3. The correct ndb entries must be set (in the beginning I forgot `fs` and I could
+only connect via tcp, not tls)
+
+More information about all those steps can be found in section 7 of [the 9front FQA](http://fqa.9front.org/fqa7.html).
+
A => sites/pmikkelsen.com/plan9/using_irc.md +37 -0
@@ 0,0 1,37 @@
+# Using IRC on 9front
+
+While 9front comes with an irc client called `ircrc`, it can be quite annoying that it does not
+keep a persistent connection.
+
+A different program `irc7` provides a server part which keeps a connection open to an irc server,
+and a client part which allows for connecting to the server. This works great since it makes it possible to
+get all the messages on a channel without being online all the time.
+
+## Setup
+
+Download the irc7 code via `hg`:
+
+ hg clone https://code.9front.org/hg/irc7/
+
+Build and install
+
+ cd irc7
+ mk install
+
+## Usage
+
+First the server program `ircsrv` must be started, so I would run
+
+ ircsrv pmikkelsen irc.freenode.net
+
+to connect as `pmikkelsen` to freenode. After this (and maybe logging in),
+it is possible to connect to different channels by opening new rio windows
+and running
+
+ irc -t '#cat-v' -b
+
+to connect to the cat-v channel. The `-b` option without any extra arguments
+prints the entire conversation since the ircsrv was started, so it might not always be desirable.
+
+I run this on a remote cpu server that is rarely powered off, and then I just connect via
+drawterm from linux to chat.
No newline at end of file