kernel: in Proc defined syscallerr to hold the return value of failing syscalls
This commit is contained in:
parent
bb58ca33aa
commit
a9745e02c5
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue