* include/grub/file.h (GRUB_FILE_SIZE_UNKNOWN): New definition.
* grub-core/disk/loopback.c (grub_loopback_open): Handle unknown file size.
This commit is contained in:
parent
3579415d20
commit
82a8506214
3 changed files with 14 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2010-09-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* 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 <phcoder@gmail.com>
|
||||
|
||||
* include/grub/err.h (grub_err_t): Replace GRUB_ERR_BAD_GZIP_DATA with
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue