aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@localhost.localdomain <kaf24@localhost.localdomain>2006-10-10 22:04:01 +0100
committerkaf24@localhost.localdomain <kaf24@localhost.localdomain>2006-10-10 22:04:01 +0100
commit83a53cd75c76fc27773167ca047f858ef762ceff (patch)
tree363058613d8d95092292f8ee66888d2245c33ec4
parent741fad235ce073fae20aec7f38ee8e9772681f13 (diff)
downloadxen-83a53cd75c76fc27773167ca047f858ef762ceff.tar.gz
xen-83a53cd75c76fc27773167ca047f858ef762ceff.tar.bz2
xen-83a53cd75c76fc27773167ca047f858ef762ceff.zip
Revert 11728:30f13007be. Breaks Solaris guests.
Will need a new method for handling padded gzip files. Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r--tools/libxc/xc_linux_build.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c
index 594aed0aaf..98c84da3b2 100644
--- a/tools/libxc/xc_linux_build.c
+++ b/tools/libxc/xc_linux_build.c
@@ -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 dom,
}
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);