* disk/loopback.c (grub_loopback): Replace filename with file.
(delete_loopback): Handle new semantics. (grub_cmd_loopback): Likewise. (grub_loopback_iterate): Likewise. (grub_loopback_close): Likewise.
This commit is contained in:
parent
a6a11f3cac
commit
afaec079d1
2 changed files with 16 additions and 25 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-07-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* disk/loopback.c (grub_loopback): Replace filename with file.
|
||||||
|
(delete_loopback): Handle new semantics.
|
||||||
|
(grub_cmd_loopback): Likewise.
|
||||||
|
(grub_loopback_iterate): Likewise.
|
||||||
|
(grub_loopback_close): Likewise.
|
||||||
|
|
||||||
2010-07-20 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-07-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* util/i386/efi/grub-install.in: Revert to platform-specific behaviour
|
* util/i386/efi/grub-install.in: Revert to platform-specific behaviour
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
struct grub_loopback
|
struct grub_loopback
|
||||||
{
|
{
|
||||||
char *devname;
|
char *devname;
|
||||||
char *filename;
|
grub_file_t file;
|
||||||
int has_partitions;
|
int has_partitions;
|
||||||
struct grub_loopback *next;
|
struct grub_loopback *next;
|
||||||
};
|
};
|
||||||
|
@ -63,7 +63,7 @@ delete_loopback (const char *name)
|
||||||
*prev = dev->next;
|
*prev = dev->next;
|
||||||
|
|
||||||
grub_free (dev->devname);
|
grub_free (dev->devname);
|
||||||
grub_free (dev->filename);
|
grub_file_close (dev->file);
|
||||||
grub_free (dev);
|
grub_free (dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -91,9 +91,6 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
|
||||||
if (! file)
|
if (! file)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
/* Close the file, the only reason for opening it is validation. */
|
|
||||||
grub_file_close (file);
|
|
||||||
|
|
||||||
/* First try to replace the old device. */
|
/* First try to replace the old device. */
|
||||||
for (newdev = loopback_list; newdev; newdev = newdev->next)
|
for (newdev = loopback_list; newdev; newdev = newdev->next)
|
||||||
if (grub_strcmp (newdev->devname, args[0]) == 0)
|
if (grub_strcmp (newdev->devname, args[0]) == 0)
|
||||||
|
@ -105,8 +102,8 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
|
||||||
if (! newname)
|
if (! newname)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
grub_free (newdev->filename);
|
grub_file_close (newdev->file);
|
||||||
newdev->filename = newname;
|
newdev->file = file;
|
||||||
|
|
||||||
/* Set has_partitions when `--partitions' was used. */
|
/* Set has_partitions when `--partitions' was used. */
|
||||||
newdev->has_partitions = state[1].set;
|
newdev->has_partitions = state[1].set;
|
||||||
|
@ -126,13 +123,7 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
newdev->filename = grub_strdup (args[1]);
|
newdev->file = file;
|
||||||
if (! newdev->filename)
|
|
||||||
{
|
|
||||||
grub_free (newdev->devname);
|
|
||||||
grub_free (newdev);
|
|
||||||
return grub_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set has_partitions when `--partitions' was used. */
|
/* Set has_partitions when `--partitions' was used. */
|
||||||
newdev->has_partitions = state[1].set;
|
newdev->has_partitions = state[1].set;
|
||||||
|
@ -160,7 +151,6 @@ grub_loopback_iterate (int (*hook) (const char *name))
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_loopback_open (const char *name, grub_disk_t disk)
|
grub_loopback_open (const char *name, grub_disk_t disk)
|
||||||
{
|
{
|
||||||
grub_file_t file;
|
|
||||||
struct grub_loopback *dev;
|
struct grub_loopback *dev;
|
||||||
|
|
||||||
for (dev = loopback_list; dev; dev = dev->next)
|
for (dev = loopback_list; dev; dev = dev->next)
|
||||||
|
@ -170,27 +160,20 @@ grub_loopback_open (const char *name, grub_disk_t disk)
|
||||||
if (! dev)
|
if (! dev)
|
||||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||||
|
|
||||||
file = grub_file_open (dev->filename);
|
|
||||||
if (! file)
|
|
||||||
return grub_errno;
|
|
||||||
|
|
||||||
/* Use the filesize for the disk size, round up to a complete sector. */
|
/* Use the filesize for the disk size, round up to a complete sector. */
|
||||||
disk->total_sectors = ((file->size + GRUB_DISK_SECTOR_SIZE - 1)
|
disk->total_sectors = ((dev->file->size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||||
/ GRUB_DISK_SECTOR_SIZE);
|
/ GRUB_DISK_SECTOR_SIZE);
|
||||||
disk->id = (unsigned long) dev;
|
disk->id = (unsigned long) dev;
|
||||||
|
|
||||||
disk->has_partitions = dev->has_partitions;
|
disk->has_partitions = dev->has_partitions;
|
||||||
disk->data = file;
|
disk->data = dev->file;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_loopback_close (grub_disk_t disk)
|
grub_loopback_close (grub_disk_t disk __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_file_t file = (grub_file_t) disk->data;
|
|
||||||
|
|
||||||
grub_file_close (file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
|
Loading…
Reference in a new issue