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

[Xen-changelog] [xen-3.0.3-testing] merge

# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1160510750 -3600
# Node ID 64b3e8596dc9ad4a419de69a64080c17cfd84ad1
# Parent  fd7643e548e667d41ad71809a7c02da663bc3d37
# Parent  f7d65fb7299b95b8b6d3a44134a9f2af211393c6
merge
---
 tools/libxc/xc_linux_build.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff -r fd7643e548e6 -r 64b3e8596dc9 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Tue Oct 10 17:17:38 2006 +0100
+++ b/tools/libxc/xc_linux_build.c      Tue Oct 10 21:05:50 2006 +0100
@@ -38,7 +38,7 @@ struct initrd_info {
     enum { INITRD_none, INITRD_file, INITRD_mem } type;
     unsigned long len;
     union {
-        int fd;
+        gzFile file_handle;
         char *mem_addr;
     } u;
 };
@@ -152,7 +152,7 @@ int load_initrd(int xc_handle, domid_t d
         }
         else
         {
-            if ( read(initrd->u.fd, page, PAGE_SIZE) == -1 )
+            if ( gzread(initrd->u.file_handle, page, PAGE_SIZE) == -1 )
             {
                 PERROR("Error reading initrd image, could not");
                 return -EINVAL;
@@ -1344,16 +1344,20 @@ int xc_linux_build(int xc_handle,
 
     if ( (initrd_name != NULL) && (strlen(initrd_name) != 0) )
     {
+        initrd_info.type = INITRD_file;
+
         if ( (fd = open(initrd_name, O_RDONLY)) < 0 )
         {
             PERROR("Could not open the initial ramdisk image");
             goto error_out;
         }
 
-        initrd_info.type = INITRD_file;
-        initrd_info.u.fd = fd;
-        initrd_info.len  = lseek(fd, 0, SEEK_END);
-        lseek(fd, 0, SEEK_SET);
+        initrd_info.len = xc_get_filesz(fd);
+        if ( (initrd_info.u.file_handle = gzdopen(fd, "rb")) == NULL )
+        {
+            PERROR("Could not allocate decompression state for initrd");
+            goto error_out;
+        }
     }
 
     sts = xc_linux_build_internal(xc_handle, domid, image, image_size,
@@ -1363,8 +1367,8 @@ int xc_linux_build(int xc_handle,
 
  error_out:
     free(image);
-    if ( initrd_info.type == INITRD_file )
-        close(initrd_info.u.fd);
+    if ( initrd_info.type == INITRD_file && initrd_info.u.file_handle )
+        gzclose(initrd_info.u.file_handle);
     else if ( fd >= 0 )
         close(fd);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>