diff --git a/sys/src/kern/amd64/syscall.c b/sys/src/kern/amd64/syscall.c index d55edc3..cc155df 100644 --- a/sys/src/kern/amd64/syscall.c +++ b/sys/src/kern/amd64/syscall.c @@ -293,6 +293,7 @@ syscall(Syscalls scallnr, Ureg* ureg) poperror(); } else { /* failure: save the error buffer for errstr */ + retv.l = up->syscallerr; tmp = up->syserrstr; up->syserrstr = up->errstr; up->errstr = tmp; diff --git a/sys/src/kern/port/portdat.h b/sys/src/kern/port/portdat.h index 98a2c34..a3ebb85 100644 --- a/sys/src/kern/port/portdat.h +++ b/sys/src/kern/port/portdat.h @@ -647,6 +647,7 @@ struct Proc uint8_t arg[MAXSYSARG*sizeof(void*)]; /* system call arguments */ int nerrlab; Label errlab[NERR]; + long syscallerr; /* (negative) error code to return from syscalls */ char* syserrstr; /* last error from a system call, errbuf0 or 1 */ char* errstr; /* reason we're unwinding the error stack, errbuf1 or 0 */ char errbuf0[ERRMAX]; diff --git a/sys/src/kern/port/portfns.h b/sys/src/kern/port/portfns.h index b410472..108e8b5 100644 --- a/sys/src/kern/port/portfns.h +++ b/sys/src/kern/port/portfns.h @@ -123,7 +123,8 @@ int encrypt(void*, void*, int); void envcpy(Egrp*, Egrp*); int eqchanddq(Chan*, int, uint32_t, Qid, int); int eqqid(Qid, Qid); -void error(char*) __attribute__ ((noreturn));; +void error(char*) __attribute__ ((noreturn)); +void errorl(char*, long) __attribute__ ((noreturn)); void errorf(char*, ...); void exhausted(char*); void exit(int) __attribute__ ((noreturn)); diff --git a/sys/src/kern/port/proc.c b/sys/src/kern/port/proc.c index 046af96..579df01 100644 --- a/sys/src/kern/port/proc.c +++ b/sys/src/kern/port/proc.c @@ -1459,15 +1459,21 @@ errorf(char *fmt, ...) void error(char *err) +{ + errorl(err, -1); +} + +void +errorl(char *err, long syscallerr) { if(up == nil) - panic("error(%s) not in a process", err); + panic("errorl(%s, %lld) not in a process", err, syscallerr); spllo(); if(up->nerrlab >= NERR) panic("error stack too deep"); - if(err != up->errstr) - kstrcpy(up->errstr, err, ERRMAX); + up->syscallerr = syscallerr; + kstrcpy(up->errstr, err, ERRMAX); setlabel(&up->errlab[NERR-1]); nexterror(); }