Hello, Here is an adjusted patch for upas/fs (and its manpage) that adds an 'finit' control mesage to the mailbox ctl file. When 'finit' is written to said file, upas/fs will plumb all the messages back to faces, resulting in identical behavior to the old faces -i. diff -r e05e4b6c6546 sys/man/4/upasfs --- a/sys/man/4/upasfs Mon Oct 12 02:03:52 2020 +0200 +++ b/sys/man/4/upasfs Sat Oct 17 22:21:13 2020 -0500 @@ -194,6 +194,12 @@ Deleting message directories causes the message to be removed from the mailbox. .PP +Each mailbox, if the underlying protocol supports it, has a `ctl' file +under the mailbox directory as well. For now, the only documented +message is `finit', which will plumb all existing messages in the +mailbox to +.IR faces(1). +.PP The mailbox is scanned and the structure updated whenever the mailbox changes. Message directories are not renumbered. The results of the scan are diff -r e05e4b6c6546 sys/src/cmd/upas/fs/dat.h --- a/sys/src/cmd/upas/fs/dat.h Mon Oct 12 02:03:52 2020 +0200 +++ b/sys/src/cmd/upas/fs/dat.h Sat Oct 17 22:21:13 2020 -0500 @@ -241,6 +241,8 @@ void parsebody(Message*, Mailbox*); int strtotm(char*, Tm*); char* lowercase(char*); +void mailplumb(Mailbox*, Message*); + char* sputc(char*, char*, int); char* seappend(char*, char*, char*, int); diff -r e05e4b6c6546 sys/src/cmd/upas/fs/fs.c --- a/sys/src/cmd/upas/fs/fs.c Mon Oct 12 02:03:52 2020 +0200 +++ b/sys/src/cmd/upas/fs/fs.c Sat Oct 17 22:21:13 2020 -0500 @@ -1194,6 +1194,7 @@ { char *argvbuf[1024], **argv, file[Pathlen], *err, *v0; int i, t, argc, flags; + Message *m; t = FILE(f->qid.path); rhdr.count = thdr.count; @@ -1288,6 +1289,11 @@ argc = tokenize(thdr.data, argv, nelem(argvbuf)); if(argc == 0) return Ebadctl; + if(strcmp(argv[0], "finit") == 0){ + for(m = f->mb->root->part; m != nil; m = m->next) + mailplumb(f->mb, m); + return nil; + } return f->mb->ctl(f->mb, argc, argv); case Qflags: /* diff -r e05e4b6c6546 sys/src/cmd/upas/fs/mbox.c --- a/sys/src/cmd/upas/fs/mbox.c Mon Oct 12 02:03:52 2020 +0200 +++ b/sys/src/cmd/upas/fs/mbox.c Sat Oct 17 22:21:13 2020 -0500 @@ -56,7 +56,6 @@ }; static void delmessage(Mailbox*, Message*); -static void mailplumb(Mailbox*, Message*); char* syncmbox(Mailbox *mb, int doplumb) @@ -1544,14 +1543,20 @@ return n; } -static void +void mailplumb(Mailbox *mb, Message *m) { - char buf[256], dbuf[SHA1dlen*2 + 1], len[10], date[32], *from, *subject; + char buf[256], dbuf[SHA1dlen*2 + 1], len[10], date[32], addr[320], *from, *subject, *bang, *unixfrom; int ai; Plumbmsg p; Plumbattr a[7]; static int fd = -1; + int didflip; + + if(m == nil){ + fprint(2, "upasfs mailplumb: nil message\n"); + return; + } subject = m->subject; if(subject == nil) @@ -1572,8 +1577,27 @@ if(fd < 0) return; + /* convert uucp address for faces */ + didflip = 0; + if(from == m->unixfrom){ + unixfrom = strdup(m->unixfrom); + if(unixfrom == nil) + return; + bang = strchr(unixfrom, '!'); + *bang++ = '\0'; + strcpy(addr, bang); + strcat(addr, "@"); + strcat(addr, unixfrom); + from = strdup(addr); + if(from == nil){ + free(unixfrom); + return; + } + didflip++; + } + p.src = "mailfs"; - p.dst = "seemail"; + p.dst = "notify"; p.wdir = "/mail/fs"; p.type = "text"; @@ -1603,12 +1627,18 @@ a[ai].value = date; a[ai-1].next = &a[ai]; - if(m->digest){ - snprint(dbuf, sizeof dbuf, "%A", m->digest); - a[++ai].name = "digest"; - a[ai].value = dbuf; - a[ai-1].next = &a[ai]; - } + if(m->digest == nil) + digestmessage(mb, m); + snprint(dbuf, sizeof dbuf, "%A", m->digest); + + a[++ai].name = "digest"; + a[ai].value = dbuf; + a[ai-1].next = &a[ai]; + + a[++ai].name = "dst"; + a[ai].value = "showmail"; + a[ai-1].next = &a[ai]; + a[ai].next = nil; p.attr = a; snprint(buf, sizeof buf, "%s/%s/%s", @@ -1617,6 +1647,11 @@ p.data = buf; myplumbsend(fd, &p); + + if(didflip != 0){ + free(unixfrom); + free(from); + } } /*