setmalloctag

This commit is contained in:
Russ Cox 2006-05-21 23:32:55 +00:00
parent 1125f094ce
commit 083b5a0e40
4 changed files with 37 additions and 1 deletions

View File

@ -464,6 +464,7 @@ enum{
Qrandom,
Qreboot,
Qsecstore,
Qshowfile,
Qsnarf,
Qswap,
Qsysname,
@ -497,6 +498,7 @@ static Dirtab consdir[]={
"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,
@ -915,6 +917,9 @@ conswrite(Chan *c, void *va, long n, vlong off)
memmove(secstorebuf+offset, va, n);
return n;
case Qshowfile:
return showfilewrite(a, n);
case Qsnarf:
if(offset >= SnarfSize || offset+n >= SnarfSize)
error(Etoobig);

View File

@ -305,10 +305,11 @@ void segclock(ulong);
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);

View File

@ -213,3 +213,9 @@ ticks(void)
return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000;
}
long
showfilewrite(char *a, int n)
{
error("not implemented");
return -1;
}

View File

@ -444,3 +444,27 @@ oserrstr(void)
{
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;
}