From: Vladimir 'phcoder' Serbinenko Date: Sun, 5 Sep 2010 15:01:16 +0000 (+0200) Subject: * include/grub/file.h (GRUB_FILE_SIZE_UNKNOWN): New definition. X-Git-Tag: 1.99~585 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82a85062149a8b22c18d7a803c202a4f6ac9e3bc;p=thirdparty%2Fgrub.git * include/grub/file.h (GRUB_FILE_SIZE_UNKNOWN): New definition. * grub-core/disk/loopback.c (grub_loopback_open): Handle unknown file size. --- diff --git a/ChangeLog b/ChangeLog index 416b660c0..93fedc014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-09-05 Vladimir Serbinenko + + * include/grub/file.h (GRUB_FILE_SIZE_UNKNOWN): New definition. + * grub-core/disk/loopback.c (grub_loopback_open): Handle unknown file + size. + 2010-09-05 Vladimir Serbinenko * include/grub/err.h (grub_err_t): Replace GRUB_ERR_BAD_GZIP_DATA with diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c index 8153478ed..878369e5f 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -167,8 +167,11 @@ grub_loopback_open (const char *name, grub_disk_t disk) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); /* Use the filesize for the disk size, round up to a complete sector. */ - disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1) - / GRUB_DISK_SECTOR_SIZE); + if (dev->file->size != GRUB_FILE_SIZE_UNKNOWN) + disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1) + / GRUB_DISK_SECTOR_SIZE); + else + disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN; disk->id = (unsigned long) dev; disk->has_partitions = dev->has_partitions; diff --git a/include/grub/file.h b/include/grub/file.h index a9f9552da..0986c98b8 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -104,6 +104,9 @@ grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf, grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset); grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file); +/* Return value of grub_file_size() in case file size is unknown. */ +#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL + static inline grub_off_t grub_file_size (const grub_file_t file) {