summaryrefslogtreecommitdiff
path: root/minix/servers/rs/error.c
blob: 5da62acb2ddeb1f849f8b6af1647c76d3b49a7b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Changes:
 *   Mar 07, 2010:  Created  (Cristiano Giuffrida)
 */

#include "inc.h"

/* A single error entry. */
struct errentry {
    int errnum;
    char* errstr;
};

/* Initialization errors. */
static struct errentry init_errlist[] = {
  { ENOSYS,     "service does not support the requested initialization type"  },
  { ERESTART,     "service requested an initialization reset"  }
};
static const int init_nerr = sizeof(init_errlist) / sizeof(init_errlist[0]);

/* Live update errors. */
static struct errentry lu_errlist[] = {
  { ENOSYS,     "service does not support live update"                        },
  { EINVAL,     "service does not support the required state"                 },
  { EBUSY,      "service is not able to prepare for the update now"           },
  { EGENERIC,   "generic error occurred while preparing for the update"       }
};
static const int lu_nerr = sizeof(lu_errlist) / sizeof(lu_errlist[0]);

/*===========================================================================*
 *				  rs_strerror				     *
 *===========================================================================*/
static char * rs_strerror(int errnum, struct errentry *errlist, const int nerr)
{
  int i;

  for(i=0; i < nerr; i++) {
      if(errnum == errlist[i].errnum)
          return errlist[i].errstr;
  }

  return strerror(-errnum);
}

/*===========================================================================*
 *				  init_strerror				     *
 *===========================================================================*/
char * init_strerror(int errnum)
{
  return rs_strerror(errnum, init_errlist, init_nerr);
}

/*===========================================================================*
 *				   lu_strerror				     *
 *===========================================================================*/
char * lu_strerror(int errnum)
{
  return rs_strerror(errnum, lu_errlist, lu_nerr);
}