ref: 0ffa574bd8e98e9494ac465b9510dc6d3d2db6d5
parent: 0dd9f39cf5c2ffc4ea83abcc703b1944e7d19093
author: cosarara <cosa@cosarara.me>
date: Sat Sep 6 10:15:56 EDT 2025
Allow mounting nested imap inboxes e.g. `echo open /imaps/mail.example.org/user/lists/9front-fqa 9front-fqa >/mail/fs/ctl` will mount the imap inbox `lists/9front-fqa` under the name 9front-fqa. the index file path will be /mail/box/glenda/imap.mail.example.org.user.9front-fqa.idx (instead of /mail/box/glenda/imap.mail.example.org.user.lists/9front-fqa.idx, that would not work).
--- a/sys/src/cmd/upas/fs/imap.c
+++ b/sys/src/cmd/upas/fs/imap.c
@@ -1113,13 +1113,13 @@
}
static char*
-mkmbox(Imap *imap, char *p, char *e)
+mkmbox(Imap *imap, char* name, char *p, char *e)
{p = seprint(p, e, "%s/box/%s/imap.%s", MAILROOT, getlog(), imap->host);
if(imap->user && strcmp(imap->user, getlog()))
p = seprint(p, e, ".%s", imap->user);
- if(cistrcmp(imap->mbox, "inbox"))
- p = seprint(p, e, ".%s", imap->mbox);
+ if(cistrcmp(name, "mbox"))
+ p = seprint(p, e, ".%s", name);
return p;
}
@@ -1151,7 +1151,7 @@
return r;
free(imap->mbox);
imap->mbox = smprint("%s", new);- mkmbox(imap, mb->path, mb->path + sizeof mb->path);
+ mkmbox(imap, mb->name, mb->path, mb->path + sizeof mb->path);
return 0;
}
@@ -1198,7 +1198,7 @@
imap->mbox = strdup("inbox");else
imap->mbox = strdup(f[4]);
- mkmbox(imap, mb->path, mb->path + sizeof mb->path);
+ mkmbox(imap, mb->name, mb->path, mb->path + sizeof mb->path);
mb->aux = imap;
mb->sync = imap4sync;
mb->close = imap4close;
--
⑨