commit - 1a8bd157b665a7ef92f490430ba6b1eb7484b1e6
commit + 0df4c01ecab67c56ef701997189a281bc3cb303d
blob - d4685000e985feaf1d988247a300dd524d96c5da
blob + 2e24c121145f4c19c00a194394f0cbc1aa6d1af4
--- src/cmd/upas/marshal/marshal.c
+++ src/cmd/upas/marshal/marshal.c
return -1;
buf[n] = 0;
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*
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;
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;
}
ftype[n-1] = 0;
a->type = estrdup(ftype);
}
+fprint(2, "got type %s\n", a->type);
close(pfd[1]);
procwait(pid);