shithub: riscv

Download patch

ref: e18a70a9487952902bc9a69f2a398bfc6e8620ea
parent: 84e88b845cb3e96e6e8ebe04a50694a29264560c
author: cinap_lenrek <cinap_lenrek@centraldogma>
date: Fri Sep 16 03:25:27 EDT 2011

page: add cbz support

--- a/sys/src/cmd/page.c
+++ b/sys/src/cmd/page.c
@@ -238,6 +238,36 @@
 	return fd;
 }
 
+int
+popentape(Page *p)
+{
+	char mnt[32], cmd[NPATH], *argv[4];
+
+	snprint(mnt, sizeof(mnt), "/n/tapefs.%.12d%.8lux", getpid(), (ulong)p);
+	switch(rfork(RFREND|RFPROC|RFFDG)){
+	case -1:
+		close(p->fd);
+		p->fd = -1;
+		return -1;
+	case 0:
+		dup(p->fd, 0);
+		argv[0] = "rc";
+		argv[1] = "-c";
+		snprint(cmd, sizeof(cmd), "%s -m %s /fd/0", p->data, mnt);
+		argv[2] = cmd;
+		argv[3] = nil;
+		exec("/bin/rc", argv);
+		sysfatal("exec: %r");
+	}
+	waitpid();
+	close(p->fd);
+	p->fd = -1;
+	p->open = popenfile;
+	p->data = strdup(mnt);
+	return p->open(p);
+}
+
+
 typedef struct Ghost Ghost;
 struct Ghost
 {
@@ -524,6 +554,10 @@
 	else if(memcmp(buf, "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1", 8) == 0){
 		p->data = "doc2ps";
 		p->open = popengs;
+	}
+	else if(memcmp(buf, "PK\x03\x04", 4) == 0){
+		p->data = "fs/zipfs";
+		p->open = popentape;
 	}
 	else if(memcmp(buf, "GIF", 3) == 0)
 		p->data = "gif -t9";