kernel: in Proc defined syscallerr to hold the return value of failing syscalls
This commit is contained in:
@ -293,6 +293,7 @@ syscall(Syscalls scallnr, Ureg* ureg)
|
|||||||
poperror();
|
poperror();
|
||||||
} else {
|
} else {
|
||||||
/* failure: save the error buffer for errstr */
|
/* failure: save the error buffer for errstr */
|
||||||
|
retv.l = up->syscallerr;
|
||||||
tmp = up->syserrstr;
|
tmp = up->syserrstr;
|
||||||
up->syserrstr = up->errstr;
|
up->syserrstr = up->errstr;
|
||||||
up->errstr = tmp;
|
up->errstr = tmp;
|
||||||
|
@ -647,6 +647,7 @@ struct Proc
|
|||||||
uint8_t arg[MAXSYSARG*sizeof(void*)]; /* system call arguments */
|
uint8_t arg[MAXSYSARG*sizeof(void*)]; /* system call arguments */
|
||||||
int nerrlab;
|
int nerrlab;
|
||||||
Label errlab[NERR];
|
Label errlab[NERR];
|
||||||
|
long syscallerr; /* (negative) error code to return from syscalls */
|
||||||
char* syserrstr; /* last error from a system call, errbuf0 or 1 */
|
char* syserrstr; /* last error from a system call, errbuf0 or 1 */
|
||||||
char* errstr; /* reason we're unwinding the error stack, errbuf1 or 0 */
|
char* errstr; /* reason we're unwinding the error stack, errbuf1 or 0 */
|
||||||
char errbuf0[ERRMAX];
|
char errbuf0[ERRMAX];
|
||||||
|
@ -123,7 +123,8 @@ int encrypt(void*, void*, int);
|
|||||||
void envcpy(Egrp*, Egrp*);
|
void envcpy(Egrp*, Egrp*);
|
||||||
int eqchanddq(Chan*, int, uint32_t, Qid, int);
|
int eqchanddq(Chan*, int, uint32_t, Qid, int);
|
||||||
int eqqid(Qid, Qid);
|
int eqqid(Qid, Qid);
|
||||||
void error(char*) __attribute__ ((noreturn));;
|
void error(char*) __attribute__ ((noreturn));
|
||||||
|
void errorl(char*, long) __attribute__ ((noreturn));
|
||||||
void errorf(char*, ...);
|
void errorf(char*, ...);
|
||||||
void exhausted(char*);
|
void exhausted(char*);
|
||||||
void exit(int) __attribute__ ((noreturn));
|
void exit(int) __attribute__ ((noreturn));
|
||||||
|
@ -1459,15 +1459,21 @@ errorf(char *fmt, ...)
|
|||||||
|
|
||||||
void
|
void
|
||||||
error(char *err)
|
error(char *err)
|
||||||
|
{
|
||||||
|
errorl(err, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
errorl(char *err, long syscallerr)
|
||||||
{
|
{
|
||||||
if(up == nil)
|
if(up == nil)
|
||||||
panic("error(%s) not in a process", err);
|
panic("errorl(%s, %lld) not in a process", err, syscallerr);
|
||||||
spllo();
|
spllo();
|
||||||
|
|
||||||
if(up->nerrlab >= NERR)
|
if(up->nerrlab >= NERR)
|
||||||
panic("error stack too deep");
|
panic("error stack too deep");
|
||||||
if(err != up->errstr)
|
up->syscallerr = syscallerr;
|
||||||
kstrcpy(up->errstr, err, ERRMAX);
|
kstrcpy(up->errstr, err, ERRMAX);
|
||||||
setlabel(&up->errlab[NERR-1]);
|
setlabel(&up->errlab[NERR-1]);
|
||||||
nexterror();
|
nexterror();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user