[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]


I've uploaded a pre-pre-pre-preliminary hack-around of something I'm
hoping will eventually become hurd-init. I'd appreciate it if a couple of
people could cast beady eyes over it just to make sure I've not done
anything reaaally stupid.

Currently it:

- Attempts to open a FIFO for writing and write to it. It sets a dummy
  SIGALRM handler and set a 2-second alarm. If, for whatever reason,
  the write failed, it assumes it's the primary init (i.e., the one
  started by the boot sequence).

- If the write succeeds, it does nothing *grin*
  (It does check that the file it's writing to is in fact a FIFO before
   attempting to write to it - if it's not, it's treated as a failed
   write - this is to make sure that 'touch /dev/scm' or something equally
   silly won't break things).

- If it failed, it tries to unlink whatever's there already, then creates
  a new FIFO and opens it for reading. If this fails, a big warning
  message is printed on the console (can't create FIFO, something's very
  wrong, etc), and /bin/sh is exec'd. If the exec of /bin/sh fails, the
  user's notified that things are *very* wrong, and they'll have to rescue
  things some other way, and init exits (under HURD, we could use the exit
  code of init and try and run some sort of emergency console or something
  - under Linux, this would be kludgy, without a linuxrc or something).
- If the creation succeeds, a banner message is printed to the console,
  and the FIFO is closed and unlinked (this alleviates the 2-second pause
  if the system was shut down cleanly. Clever pre-init scripts could use
  this to produce some sort of "thou shalt shut down thine system properly 
  in future" for lusers, which I'm sure Mandrake and Corel would love. :)

All in all, a productive couple of hours work. The URL is:


Before anybody picks up on it from the sources, I've deliberately missed
out the if(getuid()) check for two reasons:

- I'm writing all this in non-superuser-land at the moment
- One might want to be able to chown root.admin ; chmod /dev/scm 660
  in the future, allowing anybody in a particular group to telinit the

I'd like to get this as right as possible from the start; so if anybody
has any improvements for the existing code, they're greatly appreciated.

The contents of scm.c will eventually become part of libscm, which will
provide a nice high-level interface to the FIFO operations. Oh, and I'll
get around to writing a header file for it. RSN. :)


Mo McKinlay             Chief Software Architect          inter/open Labs
GnuPG Key: pub  1024D/76A275F9 2000-07-22 Mo McKinlay <mmckinlay@gnu.org>

Reply to: