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-devel

[Xen-devel] [PATCH] fix libxc not to hide real errno with EBADF

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] fix libxc not to hide real errno with EBADF
From: Steven Rostedt <srostedt@xxxxxxxxxx>
Date: Fri, 04 Aug 2006 17:13:03 -0400
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 04 Aug 2006 14:12:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
I'm currently looking for a cause of a bug that's giving me an invalid argument on an ioctl call with libxc. But before I found where the problem was I was constantly getting a Bad File Descriptor error. Well that is because the clean up of gzclose is done after the file descriptor that gzdopen used is closed when it doesn't need to be. This patch allows for proper clean up and the correct errno to be presented.

-- Steve

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>

(this may have white space damage, so I'm attaching the same patch as well. Haven't yet figured out how to do proper inline patches in thunderbird)

diff -r 9632ececc8f4 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed Aug 02 10:13:30 2006 +0100
+++ b/tools/libxc/xc_linux_build.c      Fri Aug 04 17:10:30 2006 -0400
@@ -1373,10 +1373,10 @@ int xc_linux_build(int xc_handle,

 error_out:
    free(image);
-    if ( fd >= 0 )
+    if ( initrd_info.type == INITRD_file && initrd_info.u.file_handle )
+        gzclose(initrd_info.u.file_handle);
+    else if ( fd >= 0 )
        close(fd);
-    if ( initrd_info.u.file_handle )
-        gzclose(initrd_info.u.file_handle);

    return sts;
}


diff -r 9632ececc8f4 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed Aug 02 10:13:30 2006 +0100
+++ b/tools/libxc/xc_linux_build.c      Fri Aug 04 17:10:30 2006 -0400
@@ -1373,10 +1373,10 @@ int xc_linux_build(int xc_handle,
 
  error_out:
     free(image);
-    if ( fd >= 0 )
+    if ( initrd_info.type == INITRD_file && initrd_info.u.file_handle )
+        gzclose(initrd_info.u.file_handle);
+    else if ( fd >= 0 )
         close(fd);
-    if ( initrd_info.u.file_handle )
-        gzclose(initrd_info.u.file_handle);
 
     return sts;
 }
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>