ref: 083b5a0e40e7eb56469ac1705ae437f4353d15ee
parent: 1125f094ce2a6854ef568b8c62602ce07c6a2935
	author: Russ Cox <rsc@swtch.com>
	date: Sun May 21 19:32:55 EDT 2006
	
setmalloctag
--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -464,6 +464,7 @@
Qrandom,
Qreboot,
Qsecstore,
+ Qshowfile,
Qsnarf,
Qswap,
Qsysname,
@@ -497,6 +498,7 @@
 	"random",	{Qrandom},	0,		0444, 	"reboot",	{Qreboot},	0,		0664, 	"secstore",	{Qsecstore},	0,		0666,+	"showfile",	{Qshowfile},	0,	0220, 	"snarf",	{Qsnarf},		0,		0666, 	"swap",		{Qswap},	0,		0664, 	"sysname",	{Qsysname},	0,		0664,@@ -914,6 +916,9 @@
secstoretab->qid.vers++;
memmove(secstorebuf+offset, va, n);
return n;
+
+ case Qshowfile:
+ return showfilewrite(a, n);
case Qsnarf:
if(offset >= SnarfSize || offset+n >= SnarfSize)
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -305,10 +305,11 @@
void segpage(Segment*, Page*);
void setkernur(Ureg*, Proc*);
int setlabel(Label*);
-void setmalloctag(void*, ulong);
+void setmalloctag(void*, uintptr);
void setrealloctag(void*, ulong);
void setregisters(Ureg*, char*, char*, int);
void setswapchan(Chan*);
+long showfilewrite(char*, int);
char* skipslash(char*);
void sleep(Rendez*, int(*)(void*), void*);
void* smalloc(ulong);
--- a/kern/posix.c
+++ b/kern/posix.c
@@ -213,3 +213,9 @@
return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000;
}
+long
+showfilewrite(char *a, int n)
+{+	error("not implemented");+ return -1;
+}
--- a/kern/win32.c
+++ b/kern/win32.c
@@ -444,3 +444,27 @@
 {osrerrstr(up->errstr, ERRMAX);
}
+
+long
+showfilewrite(char *a, int n)
+{+ Rune *action, *arg, *cmd;
+	static Rune Lopen[] = { 'o', 'p', 'e', 'n', 0 };+
+	cmd = runesmprint("%.*s", n, a);+ if(cmd == nil)
+		error("out of memory");+ if(cmd[runestrlen(cmd)-1] == '\n')
+ cmd[runestrlen(cmd)] = 0;
+ p = runestrchr(cmd, ' ');
+	if(p){+ action = cmd;
+ *p++ = 0;
+ arg = p;
+	}else{+ action = Lopen;
+ arg = cmd;
+ }
+ ShellExecute(0, 0, action, arg, 0, SW_SHOWNORMAL);
+ return n;
+}
--
⑨