From: Daniel Stodden Date: Thu, 8 Jul 2010 14:00:49 +0000 (+0100) Subject: CA-38567: Fail Unixext calls with a proper Unix_error. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5137ae14f480670a8c4c2e6da92245312cf760b3;p=xcp%2Fxen-api-libs.git CA-38567: Fail Unixext calls with a proper Unix_error. Signed-off-by: Daniel Stodden --- diff --git a/stdext/unixext_stubs.c b/stdext/unixext_stubs.c index a681605..b3e0905 100644 --- a/stdext/unixext_stubs.c +++ b/stdext/unixext_stubs.c @@ -30,16 +30,7 @@ #include #include #include - -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 /* 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 @@ CAMLprim value stub_unixext_set_tcp_nodelay (value fd, value bool) 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 @@ CAMLprim value stub_unixext_fsync (value fd) { 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 @@ CAMLprim value stub_unixext_blkgetsize64(value fd) 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)); }