Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Xen/Xentools 3.3 Domain-Unnamed



On Tuesday 19 August 2008 16:15:04 Manuel Bouyer wrote:
> On Tue, Aug 19, 2008 at 02:44:10PM +0200, Christoph Egger wrote:
> > > Not yet. I'd rather take the whole macro list and see what the
> > > differences are.
> >
> > Attached is xen's errno file from the source.
> > In the source, this is: xen/include/xen/errno.h
> >
> > It is basically a merge of Linux'  asm-generic/errno-generic.h and
> > asm-generic/errno.h
>
> OK, so what about using the attached function then ?
> It should convert all common error types, and warn if an unkown error is
> returned.

It's fine with me. I merged your function in my patch (see attachment).
It works fine for me.

Christoph
Index: privcmd.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/xen/privcmd.c,v
retrieving revision 1.27
diff -u -p -r1.27 privcmd.c
--- privcmd.c   18 Aug 2008 23:09:37 -0000      1.27
+++ privcmd.c   19 Aug 2008 14:44:06 -0000
@@ -77,6 +77,185 @@ static int privpgop_fault(struct uvm_fau
                         int, int, vm_prot_t, int);
 static int privcmd_map_obj(struct vm_map *, vaddr_t, paddr_t *, int, int);
 
+
+static int
+privcmd_xen2bsd_errno(int error)
+{
+       /*
+        * Xen uses System V error codes.
+        * In order to keep bloat as minimal as possible,
+        * only convert what really impact us.
+        */
+
+       switch(-error) {
+       case 1:
+               return EPERM;
+       case 2:
+               return ENOENT;
+       case 3:
+               return ESRCH;
+       case 4:
+               return EINTR;
+       case 5:
+               return EIO;
+       case 6:
+               return ENXIO;
+       case 7:
+               return E2BIG;
+       case 8:
+               return ENOEXEC;
+       case 9:
+               return EBADF;
+       case 10:
+               return ECHILD;
+       case 11:
+               return EAGAIN;
+       case 12:
+               return ENOMEM;
+       case 13:
+               return EACCES;
+       case 14:
+               return EFAULT;
+       case 15:
+               return ENOTBLK;
+       case 16:
+               return EBUSY;
+       case 17:
+               return EEXIST;
+       case 18:
+               return EXDEV;
+       case 19:
+               return ENODEV;
+       case 20:
+               return ENOTDIR;
+       case 21:
+               return EISDIR;
+       case 22:
+               return EINVAL;
+       case 23:
+               return ENFILE;
+       case 24:
+               return EMFILE;
+       case 25:
+               return ENOTTY;
+       case 26:
+               return ETXTBSY;
+       case 27:
+               return EFBIG;
+       case 28:
+               return ENOSPC;
+       case 29:
+               return ESPIPE;
+       case 30:
+               return EROFS;
+       case 31:
+               return EMLINK;
+       case 32:
+               return EPIPE;
+       case 33:
+               return EDOM;
+       case 34:
+               return ERANGE;
+       case 35:
+               return EDEADLK;
+       case 36:
+               return ENAMETOOLONG;
+       case 37:
+               return ENOLCK;
+       case 38:
+               return ENOSYS;
+       case 39:
+               return ENOTEMPTY;
+       case 40:
+               return ELOOP;
+       case 42:
+               return ENOMSG;
+       case 43:
+               return EIDRM;
+       case 60:
+               return ENOSTR;
+       case 61:
+               return ENODATA;
+       case 62:
+               return ETIME;
+       case 63:
+               return ENOSR;
+       case 66:
+               return EREMOTE;
+       case 74:
+               return EBADMSG;
+       case 75:
+               return EOVERFLOW;
+       case 84:
+               return EILSEQ;
+       case 87:
+               return EUSERS;
+       case 88:
+               return ENOTSOCK;
+       case 89:
+               return EDESTADDRREQ;
+       case 90:
+               return EMSGSIZE;
+       case 91:
+               return EPROTOTYPE;
+       case 92:
+               return ENOPROTOOPT;
+       case 93:
+               return EPROTONOSUPPORT;
+       case 94:
+               return ESOCKTNOSUPPORT;
+       case 95:
+               return EOPNOTSUPP;
+       case 96:
+               return EPFNOSUPPORT;
+       case 97:
+               return EAFNOSUPPORT;
+       case 98:
+               return EADDRINUSE;
+       case 99:
+               return EADDRNOTAVAIL;
+       case 100:
+               return ENETDOWN;
+       case 101:
+               return ENETUNREACH;
+       case 102:
+               return ENETRESET;
+       case 103:
+               return ECONNABORTED;
+       case 104:
+               return ECONNRESET;
+       case 105:
+               return ENOBUFS;
+       case 106:
+               return EISCONN;
+       case 107:
+               return ENOTCONN;
+       case 108:
+               return ESHUTDOWN;
+       case 109:
+               return ETOOMANYREFS;
+       case 110:
+               return ETIMEDOUT;
+       case 111:
+               return ECONNREFUSED;
+       case 112:
+               return EHOSTDOWN;
+       case 113:
+               return EHOSTUNREACH;
+       case 114:
+               return EALREADY;
+       case 115:
+               return EINPROGRESS;
+       case 116:
+               return ESTALE;
+       case 122:
+               return EDQUOT;
+       default:
+               printf("unknown xen error code %d\n", -error);
+               return -error;
+       }
+}
+
 static int
 privcmd_ioctl(void *v)
 {
@@ -150,11 +329,11 @@ privcmd_ioctl(void *v)
                                error = 0;
                        } else {
                                /* error occured, return the errno */
-                               error = -error;
+                               error = privcmd_xen2bsd_errno(error);
                                hc->retval = 0;
                        }
                } else {
-                       error = -error;
+                       error = privcmd_xen2bsd_errno(error);
                }
                break;
        }


Home | Main Index | Thread Index | Old Index