OK, turing.

<- leave blank

Wed Dec 12 00:00:52 EST 2018

upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: imap: imap fetch failed
upas/fs: user: ori; note: sys: trap: fault read addr=0x0 pc=0x216095
fs 97897: suicide: sys: trap: fault read addr=0x0 pc=0x216095
cpu% acid 97897
/proc/97897/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
strncmp(n=0x300000005,s2=0x40b24a)+0x1d /sys/src/libc/port/strncmp.c:10
mkstat(t=0x11,m=0x50c7be0,mb=0x41f7c8,d=0x7ffffeffeb10)+0x265
/sys/src/cmd/upas/fs/fs.c:682
	p=0x0
readmsgdir(f=0x50b8fc0,buf=0x41a470,blen=0x2000,off=0x0,cnt=0x1bc1)+0x5e
/sys/src/cmd/upas/fs/fs.c:1056
	n=0x110000043f
	pos=0x43f
	d=0x210000
	i=0x21000000000011
	msg=0x300000003
rread(f=0x3ab)+0xf8 /sys/src/cmd/upas/fs/fs.c:1110
	off=0x200000000000
	cnt=0x200002000
	p=0x13
	t=0x1300000000
io()+0x1e9 /sys/src/cmd/upas/fs/fs.c:1416
	n=0x300000018
main(argc=0x0,argv=0x7ffffeffef80)+0x319 /sys/src/cmd/upas/fs/fs.c:353
	mboxfile=0x7ffffeffef9e
	nodflt=0x300000000
	srvpost=0x0
	v=0x7ffffeffef70
	_argc=0x66
	_args=0x40b1b0
	p=0x500000003
	maildir=0x73662f6c69616d2f
	mbox=0x0
	srvfile=0x0
_main+0x40 /sys/src/libc/amd64/main9.s:15

Tue Dec 11 19:51:42 EST 2018
From: Doug McIlroy <doug@cs.dartmouth.edu>
Date: Fri, 07 Dec 2018 22:54:17 -0500
To: tuhs@tuhs.org
Subject: Re: [TUHS] C comments
Errors-To: tuhs-bounces@minnie.tuhs.org
Sender: "TUHS" <tuhs-bounces@minnie.tuhs.org>

Very little in language design is so contentious as comment conventions.

C borrowed the PL/I convention, which had the virtue of being useful
for both in-line and interlinear comments, and did not necessitate
marking every line of a long comment.  Nobody in the Unix lab had
had much experience with the convention, despite having worked on
Multics for which PL/I was the implementation language.

And how did PL/I get the convention?  It was proposed by Paul
Rogoway at the first NPL (as it was then called) design-committee
meeting that I attended.  Apparently the topic had been debated
for some while before and people were tired of the subject.  Paul
was more firmly committed to his new idea than others were to
old options, so it carried more or less by default.  Besides, there
was a much more interesting topic on the agenda.  Between the
previous meeting and that one, George Radin had revamped the
entire NPL proposal from mainly Fortran-like syntax to Algol-like.
That was heady enough stuff to divert people's attention from
comments.

As for inexperiece.  The comment conventions of previous
languages had not fostered the practice of commenting out
code.  So that idea, which is the main impetus for nesting
comments, was not in anybody's mind at the time.  Had it
been, nesting might well have carried the day.  It probably could
have been changed before 1980, but thereafter there were
too many C compilers.  Then standards introduced even more
conservatism.  Perhaps Ken can remember whether the notion
was ever seriously considered.

Doug



Tue Dec 11 15:23:22 EST 2018
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>

char *user;

enum {
	Qroot,
	Qrand,
	Qlrand,
	Qfrand,
};

typedef struct F {
	char *name;
	Qid qid;
	ulong perm;
} F;

F root = { "/", {Qroot, 0, QTDIR}, 0555|DMDIR };
F roottab[] = {
	"rand", {Qrand, 0, QTFILE}, 0444,
	"lrand", {Qlrand, 0, QTFILE}, 0444,
	"frand", {Qfrand, 0, QTFILE}, 0444,
};

Cmdtab cmd[] = {
	0, "range", 3,
};

void
usage(void)
{
	fprint(2, "%s [-D] [-m mtpt] [-s srv]\n", argv0);
	exits("usage");
}

F *
filebypath(uvlong path)
{
	int i;

	if(path == Qroot)
		return &root;
	for(i = 0; i < nelem(roottab); i++)
		if(path == roottab[i].qid.path)
			return &roottab[i];
	return nil;
}

void
fsattach(Req *r)
{
	r->fid->qid = filebypath(Qroot)->qid;
	r->ofcall.qid = r->fid->qid;
	respond(r, nil);
}

char *
fswalk1(Fid *fid, char *name, Qid *qid)
{
	int i;

	switch(fid->qid.path){
	case Qroot:
		for(i = 0; i < nelem(roottab); i++){
			if(strcmp(roottab[i].name, name) == 0){
				*qid = roottab[i].qid;
				fid->qid = *qid;
				return nil;
			}
		}
		if(strcmp("..", name) == 0){
			*qid = root.qid;
			fid->qid = *qid;
			return nil;
		}
		break;
	}
	return "not found";
}

void
fillstat(Dir *d, uvlong path)
{
	F *f;

	f = filebypath(path);
	d->name = estrdup9p(f->name);
	d->qid = f->qid;
	d->mode = f->perm;
	d->uid = estrdup9p(user);
	d->gid = estrdup9p(user);
	d->muid = estrdup9p(user);
	d->length = 0;
	d->atime = time(0);
	d->mtime = time(0);
}

void
fsstat(Req *r)
{
	fillstat(&r->d, r->fid->qid.path);
	respond(r, nil);
	return;
}

int
rootgen(int n, Dir *d, void *)
{
	if(n >= nelem(roottab))
		return -1;
	fillstat(d, roottab[n].qid.path);
	return 0;
}

void
fsread(Req *r)
{
	char buf[128];
	int count;
	uvlong path;

	path = r->fid->qid.path;
	if(path == Qroot){
		dirread9p(r, rootgen, nil);
		respond(r, nil);
		return;
	}

	switch(path){
	case Qrand:
		snprint(buf, sizeof buf, "%d\n", rand());
		break;
	case Qlrand:
		snprint(buf, sizeof buf, "%ld\n", lrand());
		break;
	case Qfrand:
		snprint(buf, sizeof buf, "%f\n", frand());
		break;
	}

	count = strlen(buf);
	if(r->ifcall.count < count)
		count = r->ifcall.count;
	r->ofcall.count = count;
	memmove(r->ofcall.data, buf, count);
	respond(r, nil);
}

void
fswrite(Req *r)
{
	uvlong path;
	Cmdbuf *cb;
	Cmdtab *cp;

	cb = parsecmd(r->ifcall.data, r->ifcall.count);
	cp = lookupcmd(cb, cmd, nelem(cmd));
	if(cp == nil){
		respondcmderror(r, cb, "%r");
		return;
	}

	path = r->fid->qid.path;
	switch(path){
	case Qrand:
		print("%s %s\n", cb->f[0], cb->f[1]);
		break;
	}
	respond(r, nil);
}

Srv fs = {
.attach = fsattach,
.read = fsread,
.write = fswrite,
.stat = fsstat,
.walk1 = fswalk1,
};

void
main(int argc, char *argv[])
{
	char *mtpt, *srv;

	mtpt = "/mnt/rng";
	srv = nil;
	ARGBEGIN{
	case 'm':
		mtpt = EARGF(usage());
		break;
	case 's':
		srv = EARGF(usage());
		break;
	case 'D':
		chatty9p++;
		break;
	default:
		usage();
	}ARGEND;

	user = getuser();
	srand(time(0));
	postmountsrv(&fs, srv, mtpt, MREPL);

	exits(nil);
}


Tue Dec 11 08:04:01 EST 2018
#include <u.h>
#include <libc.h>

static void
f(void)
{
	goto Middle;
	while(1){
		sysfatal("!");
	Middle:
		;
	}
}

void
main(void)
{
	f();
}

Tue Dec 11 00:11:34 EST 2018
#include <u.h>
#include <libc.h>

enum {
	MUsed = (1 << 15),
	MSize = (~(1<<15)),
};

#define Mused MUsed
#define Msize MSize
#define USED(x) ((x & Mused)>>15)
#define SIZE(x) (x & Msize)

typedef struct Memblock Memblock;

struct Memblock {
	u16int st; // [15] used bit, [14:0] len + sizeof(Memblock)
	Memblock *next;
};

/*
memory block layout:;
	struct {
		Memblock header;
		byte data[SIZE(header->st)];
	};
*/

Memblock *memstart;
u16int memused;
u16int memfree;
u8int frees;

Memblock*
nextfree(u16int sz)
{
	Memblock *cur;

	cur = memstart;
	while(cur != nil){
		if((USED(cur->st) == 0) && (SIZE(cur->st) >= sz))
			return cur;
		cur = cur->next;
	}
	return nil;
}

int
coalesce(Memblock *a, Memblock *b)
{
	u16int asize;

	if(a->next != b)
		return -1;
	if(USED(a->st) || USED(b->st))
		return -1;
	asize = SIZE(a->st) + SIZE(b->st);
	a->next = b->next;
	a->st = asize & Msize;
	return 0;
}

void // not a real garbage collector ;)
rungc(void)
{
	Memblock *cur, *next;

	cur = memstart;
	next = memstart->next;
	while(next != nil){
		if(!USED(cur->st) && !USED(next->st))
			coalesce(cur, next);
		cur = cur->next;
		if(cur == nil)
			break;
		next = cur->next;
	}
	frees = 0; // if this gets done outside of free, free doesn't need
				// to do it as well.
}

int // block to split, new size of block + sizeof(Memblock)
splitblock(Memblock *a, u16int sz)
{
	char *cb;
	void *anext;
	Memblock *mb;
	u16int blen;

	if((SIZE(a->st) - sz > SIZE(a->st)) || (SIZE(a->st) - sz ==
	0))
		return -1;
	if(USED(a->st))
		return -2;
	if(sz & MUsed)
		return -3;
	cb = a;
	anext = a->next;
	cb += sz;
	mb = (void*)cb;
	mb->st = SIZE(a->st) - sz;
	mb->next = anext;
	a->st = mb;
	a->next = mb;
	return 0;
}

int
allocinit(void *heap, u16int len)
{
	Memblock *mst, *mnext;
	char *cb;
	u16int sza = 0, szb = 0;

	mst = heap;
	if(len < sizeof(Memblock))
		return -1;
	if(USED(len)){
		sza = ~(1<<15);
		szb = len - sza;
		if(szb > (~(1<<15)))
			return -2;
	} else
		sza = len;
	mst->st = sza;
	mst->next = nil;
	if(szb != 0){
		cb = (void*)mst;
		cb += sza;
		mnext = cb;
		mst->next = mnext;
		mnext->st = szb;
		mnext->next = nil;
	}
	memstart = mst;
	memused = 0;
	memfree = len;
	frees = 0;
	return 0;
}


void*
kalloc(u16int sz)
{
	Memblock *blk;
	char *cb;

	sz += sizeof(Memblock);
	if(!(blk = nextfree(sz))){
		rungc();
		if(!(blk = nextfree(sz)))
			return nil;
	}
	if(SIZE(blk->st) > sz)
		if(!splitblock(blk, sz))
			return nil;
	blk->st |= MUsed;
	cb = (void*)blk;
	cb += sizeof(Memblock);
	memfree -= sz;
	memused += sz;
	return (void*)cb;
}

void*
kallocz(u16int sz)
{
	void *ptr;

	if(!(ptr = kalloc(sz)))
		return nil;
	memset(ptr, 0, sz);
	return ptr;
}

int
kfree(void *ptr)
{
	Memblock *blk;
	char *cb;
	u16int sz;

	cb = ptr;
	cb -= sizeof(Memblock);
	blk = (void*)cb;
	if(USED(blk->st)) // check for a double free
		return -1;
	blk->st &= ~MUsed;
	sz = SIZE(blk->st);
	memfree += sz;
	memused -= sz;
	frees++;
	if(frees > FREES2GC)
		rungc();
	return 0;
}

int
memstats(Memstats *stats)
{
	u16int blks = 0, ublks = 0, fnd = 0;
	Memblock *cur;

	cur = memstart;
	stats->total = memused+memfree;
	stats->used = memused;
	stats->free = memfree;
	stats->sincegc = frees;
	while(cur != nil){
		blks++;
		fnd += SIZE(cur->st);
		if(USED(cur->st))
			ublks++;
		cur = cur->next;
	}
	stats->ublocks = ublks;
	stats->blocks = blks;
	stats->found = fnd;
	return 0;
}


Mon Dec 10 23:19:30 EST 2018
# SearchFS
File server for searches using various backends
Layout:

```
ls <dir>/
	google/ # Query Google (normal searches)
	youtube/ # Single videos, playlists, channels, users
	code/ # Search predefined directories for snippets of code
	dictionary/ # Wrap your favorite dict protocol
	documents/ # Search tags for matching (local) documents
	games/ # Search tags for matching games
	github/ # May be abandoned for a dedicated filesystem
	images/ # Multi-service image search
	bookmarks/ # Search tags for matching bookmarks (this will index your
	bookmark collection)
	lyrics/ # Lyrical snippets returning matching song or artist - title
	quote/ # Your local quote db, saved from IRC or other things
	music/ # Wrapper for your preferred music streaming service - initially
	just google music
	wikipedia # May be abandoned for a dedicated filesystem

ls <dir>/code/
	mysearch/
	<list of searches>/
	ctl

ls <dir>/code/mysearch/
	list
	of
	related
	results

cat <dir>/code/mysearch/result
	/path/to/some/file

cat <dir>/code/mysearch/webresult
	http://path.to/some/site
```

You query a search into a ctl file, it will create a directory for that search.
If an entry exists for the query in question, it will use backend-specific
semantics to either fetch more results, for example with a google search; or in
the cases of local searches it will simply recreate the entry.


Mon Dec 10 16:57:21 EST 2018
proc ::capSessionUtil::enumerateOpenLibsAndDesigns { } {
set lSession $::DboSession_s_pDboSession
DboSession -this $lSession
set lStatus [DboState]
set lName [DboTclHelper_sMakeCString]
set lMessageStr [DboTclHelper_sMakeCString "Open Designs -->"]
DboState_WriteToSessionLog $lMessageStr
set lDesignsIter [$lSession NewDesignsIter $lStatus]
set lDesign [$lDesignsIter NextDesign $lStatus]
set lNullObj NULL
while { $lDesign!= $lNullObj} {
$lDesign GetName $lName
DboState_WriteToSessionLog $lName
set lDesign [$lDesignsIter NextDesign $lStatus]
}
delete_DboSessionDesignsIter $lDesignsIter
set lMessageStr [DboTclHelper_sMakeCString "Open Libraries -->"]
DboState_WriteToSessionLog $lMessageStr
set lLibsIter [$lSession NewLibsIter $lStatus]
set lLib [$lLibsIter NextLib $lStatus]
set lNullObj NULL
while { $lLib!= $lNullObj} {
$lLib GetName $lName
DboState_WriteToSessionLog $lName
set lLib [$lLibsIter NextLib $lStatus]
}
delete_DboSessionLibsIter $lLibsIter
$lStatus -delete
}

Mon Dec 10 16:51:54 EST 2018
myvar=foo echo $myvar; echo $myvar;
foo

»»»»
myvar=foo { echo $myvar; echo $myvar; }
foo
foo
»»»»
myvar=foo @{ echo $myvar; echo $myvar; }
foo
foo
»»»»


Mon Dec 10 12:54:32 EST 2018
#!/bin/rc
from=$1
to=$2
charconst='''[^'']*'''
strconst='"([^"]|\\")*"'
name='[a-zA-Z_][a-zA-Z_0-9]*'
partial=`{echo -n $from |
	awk '{for(i = 0; i < length($1) + 1; i++) printf "."}'}
echo 'y/'$charconst'/ y/'$strconst'/ x/'$name'/ g/'$from'/ v/'$partial'/ c/'$to


Mon Dec 10 09:46:50 EST 2018
state-sponsored trolling

Sun Dec 9 17:10:32 EST 2018
: y
upas/fs:<-Twalk tag 68 fid 2051 newfid 2031 nwname 0
upas/fs:->Rwalk tag 68 nwqid 0
upas/fs:<-Tstat tag 68 fid 2031
upas/fs:->Rstat tag 68 stat 'mbox' 'kvik' 'kvik' 'kvik' q (0000000000000420 2
d) m 020000000555 at 1544393033 mt 1544393033 l 0 t 0 d 0
upas/fs:<-Twalk tag 68 fid 2035 newfid 2013 nwname 1 0:ctl
upas/fs:->Rwalk tag 68 nwqid 1 0:(0000000000000022 0 )
upas/fs:<-Tclunk tag 31 fid 2031
upas/fs:->Rclunk tag 31
upas/fs:<-Topen tag 68 fid 2013 mode 2
upas/fs:->Ropen tag 68 qid (0000000000000022 0 ) iounit 0
upas/fs:<-Tclunk tag 68 fid 2013
upas/fs:->Rclunk tag 68
: y
upas/fs:<-Twalk tag 68 fid 2051 newfid 2055 nwname 0


prev | next