changeset 149:127b60f41bbf

common: preemptively define a number of likely RPC error codes Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 18 Oct 2015 14:09:32 -0400
parents af48a9cab13b
children 5b4d4496c9c6
files src/common/error.c src/common/include/nomad/rpc.h
diffstat 2 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/common/error.c	Sun Oct 18 14:09:09 2015 -0400
+++ b/src/common/error.c	Sun Oct 18 14:09:32 2015 -0400
@@ -29,10 +29,28 @@
 int errno_to_nerr(int e)
 {
 	switch (e) {
+		MAP_ERRNO(E2BIG);
+		MAP_ERRNO(EACCES);
+		MAP_ERRNO(EAGAIN);
 		MAP_ERRNO(EALREADY);
+		MAP_ERRNO(EBADF);
+		MAP_ERRNO(EBUSY);
 		MAP_ERRNO(EEXIST);
+		MAP_ERRNO(EFAULT);
+		MAP_ERRNO(EINTR);
+		MAP_ERRNO(EINVAL);
+		MAP_ERRNO(EIO);
+		MAP_ERRNO(EISDIR);
+		MAP_ERRNO(ENODEV);
 		MAP_ERRNO(ENOENT);
+		MAP_ERRNO(ENOMEM);
+		MAP_ERRNO(ENOSPC);
+		MAP_ERRNO(ENOTDIR);
+		MAP_ERRNO(ENXIO);
+		MAP_ERRNO(EPERM);
 		MAP_ERRNO(EPROTO);
+		MAP_ERRNO(ESRCH);
+		MAP_ERRNO(EXDEV);
 		case 0:
 			return NERR_SUCCESS;
 	}
--- a/src/common/include/nomad/rpc.h	Sun Oct 18 14:09:09 2015 -0400
+++ b/src/common/include/nomad/rpc.h	Sun Oct 18 14:09:32 2015 -0400
@@ -33,8 +33,26 @@
  */
 #define NERR_UNKNOWN_ERROR     -1
 #define NERR_SUCCESS           0
+#define NERR_EPERM             1
 #define NERR_ENOENT            2
+#define NERR_ESRCH             3
+#define NERR_EINTR             4
+#define NERR_EIO               5
+#define NERR_ENXIO             6
+#define NERR_E2BIG             7
+#define NERR_EBADF             9
+#define NERR_EAGAIN            11
+#define NERR_ENOMEM            12
+#define NERR_EACCES            13
+#define NERR_EFAULT            14
+#define NERR_EBUSY             16
 #define NERR_EEXIST            17
+#define NERR_EXDEV             18
+#define NERR_ENODEV            19
+#define NERR_ENOTDIR           20
+#define NERR_EISDIR            21
+#define NERR_EINVAL            22
+#define NERR_ENOSPC            28
 #define NERR_EPROTO            71
 #define NERR_EALREADY          149