Fixes up readnum() and readstr()

They now copy the trailing \0, if there is room in the buffer.

readnum() was doing some funky stuff where it would also copy up to
NUMSIZE bytes of gibberish out (which you could see from cat-ing certain
ctls, though not from #I, which rolls its own readnum for now).

Most everyone picks NUMSIZE (12) when using readnum().  proc has an
interesting usage of it, but otherwise we might want to remove that.
Dev zeros the dir path before genning

It's useful for devices to be able to get information about the last run
through their gen function when run in a tight loop.  There's no good
way to do pass an arbitrary value back, but we can use the dir to
communicate the result of the previous run.  So long as we handle the
initial case.

Gens communicate via the dir, and dir->qid.path is the last path used in
the previous run.  This works if we can bootstrap it, and passing in
gibberish (on the stack) or ancient versions of dir will mess things up.
So now any caller of a gen in a loop will make sure dir's path is 0.

Also, it's not sufficient to just check for {s,i} == 0 to detect the
"first run" of a gen.  Sometimes (devdirread()), a device will be asked
to gen starting at a higher value of its iterator.  By zeroing dir's
path, a gen can tell if it is in the middle or not of a series of runs.
Fixes reset_alarm_abs()

It couldn't handle an alarm that had never been set, since has_fired was
initially 0.  Renaming has_fired clarifies its use, fixes the init
problem, and makes the code clearer.
Kernel alarm handling moved to RKM context

Instead of running handlers from IRQ context, we shift them to RKM
context.  Alternatively, we could only do this for the awaiter handlers
(and not the semaphores), but it's probably not a big deal.

The reason for this so that we can easily send_event from an alarm
handler.  Right now, you can't send_event from IRQ context since it
might trigger a proc wakeup (grab the proclock, scheduler callbacks,
etc), all of which are not irqsave.

While I could change all of those, I'd rather cut down on the amount of
things in IRQ context (both for interrupt latency as well as for code
safety - RKMs can block, etc, though a block will delay all alarms under
the current code).  Keep in mind that send_event() can also trigger an
mmap call.  If we ever want blockable alarms, we can easily put that in
(IRQ handler wakes sems, executes handlers marked "IRQOK", and launched
an RKM otherwise).
Safety checks in send_event()

Catch future IRQ calls of send_event().  Also, send_event() might be
able to handle PROC_DYING, but just in case, we abort.  Once again,
we're using "the immutable state of DYING" here (no worry of races once
your DYING when you hold a ref).
Adds read-only umem helper
Stub sleep in glibc (XCC)

Some plan9 programs are calling sleep, and that links to some old
half-built POSIX sleep in glibc that ends up just busy waiting.

We don't support the regular sleep() directly; specifically, we don't
inrerupt sleep on signal delivery.  2LSs could build this if they want,
though signals are sent to processes, not to threads.  In that sense,
sleep is a bit wrong for what we want to do.

If you want to just put a uthread to sleep for a certain amount of time,
you can call uthread_sleep().  Its dumb and just uses the debugging
sys_block to wait in the kernel (we could do it in userspace, for
instance, with an alarm system).

Anyway, I mostly wanted to see stub warnings when compiling something
that calls sleep(), since that is a sign that the program will have
issues with signal handling / porting.

You need to copy over the sleep file into glibc-2.14.1/ and rebuild, or
do a make clean and rebuild your cross compiler.
Fixes name len error in #s

And removes one of the compiler warnings / clarifies dirty hacks.
Fix up of file open flags (XCC)

Plan9 and glibc differed in their open flags, as well as semantics on
things like CREATE.  Note there is no OCREAT in plan9, so we've got more
of a mashup of flags and syscalls.

I tried to get the intent of openmode() correct: reduce to the access
mode type, with EXEC => RDONLY, and ignore all the other flags.

devsrv was aborting for TRUNC, though I don't see why.  These fake
devices should be ignoring it anyways; everything is one big write from
the beginning, for all writes.

Reinstall your kernel headers, if you want access to the flags from
userspace.
Hack for mon_bin_run()

This only matters when you run bin_run (or bb) while another process is
current on the core.  Say you lock up a process and want to get another
shell, prior to this the new shell would inherit certain things from the
active process, due to assumptions in the create paths about the
relationship between the parent and current.
O_CLOEXEC support for 9ns

Pending an overhaul of process creation.
Fixes O_EXCL support for 9ns

I'm pretty sure whenever you create #s files, you want them O_EXCL.
Otherwise, with glibc open/create semantics, you can't tell between
opening an existing srvfile and creating a new one.
Adds devalarm (#A)

It is an alarm service for processes.  Check out the top of
k/d/d/alarm.c and the test for more details.