Sync with cat.c from netbsd-8
[minix3.git] / minix / servers / rs / error.c
blob5da62acb2ddeb1f849f8b6af1647c76d3b49a7b0
1 /*
2 * Changes:
3 * Mar 07, 2010: Created (Cristiano Giuffrida)
4 */
6 #include "inc.h"
8 /* A single error entry. */
9 struct errentry {
10 int errnum;
11 char* errstr;
14 /* Initialization errors. */
15 static struct errentry init_errlist[] = {
16 { ENOSYS, "service does not support the requested initialization type" },
17 { ERESTART, "service requested an initialization reset" }
19 static const int init_nerr = sizeof(init_errlist) / sizeof(init_errlist[0]);
21 /* Live update errors. */
22 static struct errentry lu_errlist[] = {
23 { ENOSYS, "service does not support live update" },
24 { EINVAL, "service does not support the required state" },
25 { EBUSY, "service is not able to prepare for the update now" },
26 { EGENERIC, "generic error occurred while preparing for the update" }
28 static const int lu_nerr = sizeof(lu_errlist) / sizeof(lu_errlist[0]);
30 /*===========================================================================*
31 * rs_strerror *
32 *===========================================================================*/
33 static char * rs_strerror(int errnum, struct errentry *errlist, const int nerr)
35 int i;
37 for(i=0; i < nerr; i++) {
38 if(errnum == errlist[i].errnum)
39 return errlist[i].errstr;
42 return strerror(-errnum);
45 /*===========================================================================*
46 * init_strerror *
47 *===========================================================================*/
48 char * init_strerror(int errnum)
50 return rs_strerror(errnum, init_errlist, init_nerr);
53 /*===========================================================================*
54 * lu_strerror *
55 *===========================================================================*/
56 char * lu_strerror(int errnum)
58 return rs_strerror(errnum, lu_errlist, lu_nerr);