:; fortune
You can't build a bomb at 300 baud.

:; ls -l
--rw-rw-r-- M 117298 a sys  554 Jun  6  2022 about
d-rwxrwxr-x M 117298 a sys    0 Jul  5  2021 banner
d-rwxrwxr-x M 117298 a sys    0 Mar  5 10:21 daily
d-rwxrwxr-x M 117298 a sys    0 Dec  8  2021 edterm
d-rwxrwxr-x M 117298 a sys    0 Jun  8  2021 finger
d-rwxrwxr-x M 117298 a sys    0 May 30  2022 fingers
d-rwxrwxr-x M 117298 a sys    0 Mar  2  2021 mtte
d-rwxrwxr-x M 117298 a sys    0 Feb 14  2021 tw
d-rwxrwxr-x M 117298 a sys    0 Nov 14  2022 wikifs
d-rwxrwxr-x M 117298 a sys    0 Nov  7  2021 zine

:; cat about
: txtpunk;
Text is a self-describing interface.

ed(1) is the standard text editor.

	programs for printing banners at a terminal.
	ed(1) is a distraction-free writing environment.
	client and server implementation for 'finger' protocol for Plan 9.
	scan a set of 'finger' endpoints and monitor them for changes.
	minimum time to ed(1).
	twtxt client for Plan 9.
	modifications to wikifs(4) to get it to produce gemtext.
	serve a text zine, inspired by A New Session and dial_a_zine by caraesten.

:; man 5 read

     READ(5)                                                   READ(5)

          read, write - transfer data from and to a file

          size[4] Tread tag[2] fid[4] offset[8] count[4]
          size[4] Rread tag[2] count[4] data[count]

          size[4] Twrite tag[2] fid[4] offset[8] count[4] data[count]
          size[4] Rwrite tag[2] count[4]

          The read request asks for count bytes of data from the file
          identified by fid, which must be opened for reading, start-
          ing offset bytes after the beginning of the file.  The bytes
          are returned with the read reply message.

          The count field in the reply indicates the number of bytes
          returned.  This may be less than the requested amount.  If
          the offset field is greater than or equal to the number of
          bytes in the file, a count of zero will be returned.

          For directories, read returns an integral number of direc-
          tory entries exactly as in stat (see stat(5)), one for each
          member of the directory.  The read request message must have
          offset equal to zero or the value of offset in the previous
          read on the directory, plus the number of bytes returned in
          the previous read.  In other words, seeking other than to
          the beginning is illegal in a directory (see seek(2)).

          The write request asks that count bytes of data be recorded
          in the file identified by fid, which must be opened for
          writing, starting offset bytes after the beginning of the
          file.  If the file is append-only, the data will be placed
          at the end of the file regardless of offset. Directories may
          not be written.

          The write reply records the number of bytes actually writ-
          ten.  It is usually an error if this is not the same as

          Because 9P implementations may limit the size of individual
          messages, more than one message may be produced by a single
          read or write call.  The iounit field returned by open(5),
          if non-zero, reports the maximum size that is guaranteed to
          be transferred atomically.

          Read and write messages are generated by the corresponding
          calls.  Because they include an offset, the pread and pwrite
          calls correspond more directly to the 9P messages.  Although
          seek(2) affects the offset, it does not generate a message.

#include <u.h>
#include <libc.h>
#include <bio.h>

char choice[2048];
char index[] = "/sys/games/lib/fortunes.index";
char fortunes[] = "/sys/games/lib/fortunes";

main(int argc, char *argv[])
	int i;
	long offs;
	uchar off[4];
	int ix, nix;
	int newindex, oldindex;
	char *p;
	Dir *fbuf, *ixbuf;
	Biobuf *f, g;

	newindex = 0;
	oldindex = 0;
	ix = offs = 0;
	if((f=Bopen(argc>1?argv[1]:fortunes, OREAD)) == 0){
	ixbuf = nil;
	if(argc == 1){
		ix = open(index, OREAD);
			ixbuf = dirfstat(ix);
			fbuf = dirfstat(Bfildes(f));
			if(ixbuf == nil || fbuf == nil){
			if(ixbuf->length == 0){
				/* someone else is rewriting the index */
				goto NoIndex;
			oldindex = 1;
			if(fbuf->mtime > ixbuf->mtime){
				nix = create(index, OWRITE, 0666);
				if(nix >= 0){
					ix = nix;
					newindex = 1;
					oldindex = 0;
			ix = create(index, OWRITE, 0666);
			if(ix >= 0)
				newindex = 1;
		seek(ix, truerand()%(ixbuf->length/sizeof(offs))*sizeof(offs), 0);
		read(ix, off, sizeof(off));
		Bseek(f, off[0]|(off[1]<<8)|(off[2]<<16)|(off[3]<<24), 0);
		p = Brdline(f, '\n');
			p[Blinelen(f)-1] = 0;
			strcpy(choice, p);
			strcpy(choice, "Misfortune!");
		Binit(&g, ix, 1);
				offs = Boffset(f);
			p = Brdline(f, '\n');
			if(p == 0)
			p[Blinelen(f)-1] = 0;
				off[0] = offs;
				off[1] = offs>>8;
				off[2] = offs>>16;
				off[3] = offs>>24;
				Bwrite(&g, off, sizeof(off));
				strcpy(choice, p);
	print("%s\n", choice);