Message ID | 1456877652-19389-3-git-send-email-leif.lindholm@linaro.org |
---|---|
State | New |
Headers | show |
On Wed, Mar 02, 2016 at 06:46:52AM +0300, Andrei Borzenkov wrote: > 02.03.2016 03:14, Leif Lindholm пишет: > > Implement a driver-specific malloc function that allocates a buffer > > with the alignment specified by grub_efi_block_io_media structure. > > --- > > grub-core/disk/efi/efidisk.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c > > index 3b79f7b..ac99ea7 100644 > > --- a/grub-core/disk/efi/efidisk.c > > +++ b/grub-core/disk/efi/efidisk.c > > @@ -457,6 +457,13 @@ get_device (struct grub_efidisk_data *devices, int num) > > return 0; > > } > > > > +static void * > > +aligned_malloc (struct grub_disk *disk, grub_size_t size) > > +{ > > + struct grub_efidisk_data *d = disk->data; > > + return grub_memalign (d->block_io->media->io_align, size); > > +} > > + > > static grub_err_t > > grub_efidisk_open (const char *name, struct grub_disk *disk) > > { > > @@ -512,6 +519,7 @@ grub_efidisk_open (const char *name, struct grub_disk *disk) > > (1U << disk->log_sector_size) < m->block_size; > > disk->log_sector_size++); > > disk->data = d; > > + disk->malloc = aligned_malloc; > > > > grub_dprintf ("efidisk", "opening %s succeeded\n", name); > > Did you drop sanity check in grub_efidisk_open intentionally? Not consiously, but my unconsious may well have done it intentionally. Mmmno, I left it out because 51f375d688529b7c1819ba40188ee52b9333887c already includes that. / Leif
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b79f7b..ac99ea7 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -457,6 +457,13 @@ get_device (struct grub_efidisk_data *devices, int num) return 0; } +static void * +aligned_malloc (struct grub_disk *disk, grub_size_t size) +{ + struct grub_efidisk_data *d = disk->data; + return grub_memalign (d->block_io->media->io_align, size); +} + static grub_err_t grub_efidisk_open (const char *name, struct grub_disk *disk) { @@ -512,6 +519,7 @@ grub_efidisk_open (const char *name, struct grub_disk *disk) (1U << disk->log_sector_size) < m->block_size; disk->log_sector_size++); disk->data = d; + disk->malloc = aligned_malloc; grub_dprintf ("efidisk", "opening %s succeeded\n", name);