ia64/xen-unstable

changeset 11783:f7d65fb7299b

Revert 11728:30f13007be. Breaks Solaris guests.
Will need a new method for handling padded gzip files.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Tue Oct 10 22:04:01 2006 +0100 (2006-10-10)
parents f8ddc9abf3ef
children fe54ba10e9ef
files tools/libxc/xc_linux_build.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Tue Oct 10 16:02:30 2006 +0100
     1.2 +++ b/tools/libxc/xc_linux_build.c	Tue Oct 10 22:04:01 2006 +0100
     1.3 @@ -38,7 +38,7 @@ struct initrd_info {
     1.4      enum { INITRD_none, INITRD_file, INITRD_mem } type;
     1.5      unsigned long len;
     1.6      union {
     1.7 -        int fd;
     1.8 +        gzFile file_handle;
     1.9          char *mem_addr;
    1.10      } u;
    1.11  };
    1.12 @@ -152,7 +152,7 @@ int load_initrd(int xc_handle, domid_t d
    1.13          }
    1.14          else
    1.15          {
    1.16 -            if ( read(initrd->u.fd, page, PAGE_SIZE) == -1 )
    1.17 +            if ( gzread(initrd->u.file_handle, page, PAGE_SIZE) == -1 )
    1.18              {
    1.19                  PERROR("Error reading initrd image, could not");
    1.20                  return -EINVAL;
    1.21 @@ -1344,16 +1344,20 @@ int xc_linux_build(int xc_handle,
    1.22  
    1.23      if ( (initrd_name != NULL) && (strlen(initrd_name) != 0) )
    1.24      {
    1.25 +        initrd_info.type = INITRD_file;
    1.26 +
    1.27          if ( (fd = open(initrd_name, O_RDONLY)) < 0 )
    1.28          {
    1.29              PERROR("Could not open the initial ramdisk image");
    1.30              goto error_out;
    1.31          }
    1.32  
    1.33 -        initrd_info.type = INITRD_file;
    1.34 -        initrd_info.u.fd = fd;
    1.35 -        initrd_info.len  = lseek(fd, 0, SEEK_END);
    1.36 -        lseek(fd, 0, SEEK_SET);
    1.37 +        initrd_info.len = xc_get_filesz(fd);
    1.38 +        if ( (initrd_info.u.file_handle = gzdopen(fd, "rb")) == NULL )
    1.39 +        {
    1.40 +            PERROR("Could not allocate decompression state for initrd");
    1.41 +            goto error_out;
    1.42 +        }
    1.43      }
    1.44  
    1.45      sts = xc_linux_build_internal(xc_handle, domid, image, image_size,
    1.46 @@ -1363,8 +1367,8 @@ int xc_linux_build(int xc_handle,
    1.47  
    1.48   error_out:
    1.49      free(image);
    1.50 -    if ( initrd_info.type == INITRD_file )
    1.51 -        close(initrd_info.u.fd);
    1.52 +    if ( initrd_info.type == INITRD_file && initrd_info.u.file_handle )
    1.53 +        gzclose(initrd_info.u.file_handle);
    1.54      else if ( fd >= 0 )
    1.55          close(fd);
    1.56