aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-14 19:44:29 +0000
committerrsc <devnull@localhost>2006-02-14 19:44:29 +0000
commit0df4c01ecab67c56ef701997189a281bc3cb303d (patch)
tree0ef201c5c091d3eaff4871197842b3501a6d1b8c /src/cmd/upas
parent1a8bd157b665a7ef92f490430ba6b1eb7484b1e6 (diff)
downloadplan9port-0df4c01ecab67c56ef701997189a281bc3cb303d.tar.gz
plan9port-0df4c01ecab67c56ef701997189a281bc3cb303d.tar.bz2
plan9port-0df4c01ecab67c56ef701997189a281bc3cb303d.zip
forgot this
Diffstat (limited to 'src/cmd/upas')
-rw-r--r--src/cmd/upas/marshal/marshal.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/cmd/upas/marshal/marshal.c b/src/cmd/upas/marshal/marshal.c
index d4685000..2e24c121 100644
--- a/src/cmd/upas/marshal/marshal.c
+++ b/src/cmd/upas/marshal/marshal.c
@@ -813,6 +813,18 @@ printinreplyto(Biobuf *out, char *dir)
return Bprint(out, "In-Reply-To: %s\n", buf);
}
+int
+mopen(char *file, int mode)
+{
+ int fd;
+
+ if((fd = open(file, mode)) >= 0)
+ return fd;
+ if(strncmp(file, "Mail/", 5) == 0 && mountmail() >= 0 && (fd = fsopenfd(mailfs, file+5, mode)) >= 0)
+ return fd;
+ return -1;
+}
+
Attach*
mkattach(char *file, char *type, int inline)
{
@@ -824,11 +836,8 @@ mkattach(char *file, char *type, int inline)
if(file == nil)
return nil;
- if((fd = open(file, OREAD)) < 0)
- if(strncmp(file, "Mail/", 5) != 0 || mountmail() < 0 || (fd = fsopenfd(mailfs, file+5, OREAD)) < 0){
- fprint(2, "%s: %s can't read file\n", argv0, file);
+ if((fd = mopen(file, OREAD)) < 0)
return nil;
- }
a = emalloc(sizeof(*a));
a->fd = fd;
a->path = file;
@@ -877,11 +886,12 @@ mkattach(char *file, char *type, int inline)
if(pipe(pfd) < 0)
return a;
- xfd[0] = pfd[0];
+ xfd[0] = mopen(file, OREAD);
xfd[1] = pfd[0];
xfd[2] = dup(2, -1);
- if((pid=threadspawnl(xfd, unsharp("#9/bin/file"), "file", "-m", file, nil)) < 0){
+ if((pid=threadspawnl(xfd, unsharp("#9/bin/file"), "file", "-m", nil)) < 0){
close(xfd[0]);
+ close(xfd[1]);
close(xfd[2]);
return a;
}
@@ -892,6 +902,7 @@ mkattach(char *file, char *type, int inline)
ftype[n-1] = 0;
a->type = estrdup(ftype);
}
+fprint(2, "got type %s\n", a->type);
close(pfd[1]);
procwait(pid);