WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] Fail Unixext calls with a proper Unix_error

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] Fail Unixext calls with a proper Unix_error
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Thu, 8 Jul 2010 15:02:08 +0100
Delivery-date: Thu, 08 Jul 2010 07:17:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User Daniel Stodden <daniel.stodden@xxxxxxxxxx>
# Date 1278597649 -3600
# Node ID 9e891e13c6c0f2eefc26d4b73a1bcffb6b406792
# Parent  ed0c73a17101261806413883c511526854fda8bc
CA-38567: Fail Unixext calls with a proper Unix_error.

Signed-off-by: Daniel Stodden <daniel.stodden@xxxxxxxxxx>

diff -r ed0c73a17101 -r 9e891e13c6c0 stdext/unixext_stubs.c
--- a/stdext/unixext_stubs.c    Thu Jul 08 14:59:21 2010 +0100
+++ b/stdext/unixext_stubs.c    Thu Jul 08 15:00:49 2010 +0100
@@ -30,16 +30,7 @@
 #include <caml/custom.h>
 #include <caml/fail.h>
 #include <caml/callback.h>
-
-static void failwith_errno(void)
-{
-        char buf[256];
-       char buf2[280];
-       memset(buf, '\0', sizeof(buf));
-       strerror_r(errno, buf, sizeof(buf));
-       snprintf(buf2, sizeof(buf2), "errno: %d msg: %s", errno, buf);
-       caml_failwith(buf2);
-}
+#include <caml/unixsupport.h>
 
 /* Set the TCP_NODELAY flag on a Unix.file_descr */
 CAMLprim value stub_unixext_set_tcp_nodelay (value fd, value bool)
@@ -48,7 +39,7 @@
        int c_fd = Int_val(fd);
        int opt = (Bool_val(bool)) ? 1 : 0;
        if (setsockopt(c_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, 
sizeof(opt)) != 0){
-               failwith_errno();
+               uerror("setsockopt", Nothing);
        }
        CAMLreturn(Val_unit);
 }
@@ -57,7 +48,7 @@
 {
        CAMLparam1(fd);
        int c_fd = Int_val(fd);
-       if (fsync(c_fd) != 0) failwith_errno();
+       if (fsync(c_fd) != 0) uerror("fsync", Nothing);
        CAMLreturn(Val_unit);
 }
        
@@ -67,7 +58,7 @@
   uint64_t size;
   int c_fd = Int_val(fd);
   if(ioctl(c_fd,BLKGETSIZE64,&size)) {
-    failwith_errno();
+    uerror("ioctl(BLKGETSIZE64)", Nothing);
   }
   CAMLreturn(caml_copy_int64(size));
 }
 stdext/unixext_stubs.c |  17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)


Attachment: CA-38567-unixext-errors.diff
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] Fail Unixext calls with a proper Unix_error, David Scott <=