summaryrefslogtreecommitdiff
path: root/libmachdevdde/misc.c
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2020-03-29 22:41:22 +1100
committerDamien Zammit <damien@zamaudio.com>2020-03-29 23:06:15 +1100
commit092143d506502ac81d6d9c518ac420c9bb807aa6 (patch)
tree8524a2eb6fee99cc975d4d5583512be773f91c22 /libmachdevdde/misc.c
parent90636893c91c2aa5a01de7eb7e10bd7df3b1e93f (diff)
libmachdevdde: Add dde machdev lib (net)rumpdisk-dde
Diffstat (limited to 'libmachdevdde/misc.c')
-rw-r--r--libmachdevdde/misc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/libmachdevdde/misc.c b/libmachdevdde/misc.c
new file mode 100644
index 00000000..977159bd
--- /dev/null
+++ b/libmachdevdde/misc.c
@@ -0,0 +1,50 @@
+#include <mach.h>
+#include <device/device.h>
+
+#include <ddekit/printf.h>
+
+#include "linux-errno.h"
+
+int
+linux_to_mach_error (int err)
+{
+ switch (err)
+ {
+ case 0:
+ return D_SUCCESS;
+
+ case -EPERM:
+ return D_INVALID_OPERATION;
+
+ case -EIO:
+ return D_IO_ERROR;
+
+ case -ENXIO:
+ return D_NO_SUCH_DEVICE;
+
+ case -EACCES:
+ return D_INVALID_OPERATION;
+
+ case -EFAULT:
+ return D_INVALID_SIZE;
+
+ case -EBUSY:
+ return D_ALREADY_OPEN;
+
+ case -EINVAL:
+ return D_INVALID_SIZE;
+
+ case -EROFS:
+ return D_READ_ONLY;
+
+ case -EWOULDBLOCK:
+ return D_WOULD_BLOCK;
+
+ case -ENOMEM:
+ return D_NO_MEMORY;
+
+ default:
+ ddekit_printf ("linux_to_mach_error: unknown code %d\n", err);
+ return D_IO_ERROR;
+ }
+}