Remove nested functions from disk and file read hooks.
* include/grub/disk.h (grub_disk_read_hook_t): New type. (struct grub_disk): Add read_hook_data member. * include/grub/file.h (struct grub_file): Likewise. * include/grub/fshelp.h (grub_fshelp_read_file): Add read_hook_data argument. Update all callers.
This commit is contained in:
parent
df6da5a52d
commit
4eb8b75659
29 changed files with 409 additions and 345 deletions
|
@ -331,8 +331,7 @@ grub_ufs_get_file_block (struct grub_ufs_data *data, grub_disk_addr_t blk)
|
|||
POS. Return the amount of read bytes in READ. */
|
||||
static grub_ssize_t
|
||||
grub_ufs_read_file (struct grub_ufs_data *data,
|
||||
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length),
|
||||
grub_disk_read_hook_t read_hook, void *read_hook_data,
|
||||
grub_off_t pos, grub_size_t len, char *buf)
|
||||
{
|
||||
struct grub_ufs_sblock *sblock = &data->sblock;
|
||||
|
@ -380,6 +379,7 @@ grub_ufs_read_file (struct grub_ufs_data *data,
|
|||
if (blknr)
|
||||
{
|
||||
data->disk->read_hook = read_hook;
|
||||
data->disk->read_hook_data = read_hook_data;
|
||||
grub_disk_read (data->disk,
|
||||
blknr << grub_ufs_to_cpu32 (data->sblock.log2_blksz),
|
||||
skipfirst, blockend, buf);
|
||||
|
@ -455,7 +455,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
|
|||
&& INODE_SIZE (data) <= sizeof (data->inode.symlink))
|
||||
grub_strcpy (symlink, (char *) data->inode.symlink);
|
||||
else
|
||||
grub_ufs_read_file (data, 0, 0, INODE_SIZE (data), symlink);
|
||||
grub_ufs_read_file (data, 0, 0, 0, INODE_SIZE (data), symlink);
|
||||
symlink[INODE_SIZE (data)] = '\0';
|
||||
|
||||
/* The symlink is an absolute path, go back to the root inode. */
|
||||
|
@ -509,7 +509,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
|
|||
if (grub_strlen (name) == 0)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
if (grub_ufs_read_file (data, 0, pos, sizeof (dirent),
|
||||
if (grub_ufs_read_file (data, 0, 0, pos, sizeof (dirent),
|
||||
(char *) &dirent) < 0)
|
||||
return grub_errno;
|
||||
|
||||
|
@ -521,7 +521,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path)
|
|||
{
|
||||
char filename[namelen + 1];
|
||||
|
||||
if (grub_ufs_read_file (data, 0, pos + sizeof (dirent),
|
||||
if (grub_ufs_read_file (data, 0, 0, pos + sizeof (dirent),
|
||||
namelen, filename) < 0)
|
||||
return grub_errno;
|
||||
|
||||
|
@ -659,7 +659,7 @@ grub_ufs_dir (grub_device_t device, const char *path,
|
|||
struct grub_ufs_dirent dirent;
|
||||
int namelen;
|
||||
|
||||
if (grub_ufs_read_file (data, 0, pos, sizeof (dirent),
|
||||
if (grub_ufs_read_file (data, 0, 0, pos, sizeof (dirent),
|
||||
(char *) &dirent) < 0)
|
||||
break;
|
||||
|
||||
|
@ -679,7 +679,7 @@ grub_ufs_dir (grub_device_t device, const char *path,
|
|||
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
|
||||
if (grub_ufs_read_file (data, 0, pos + sizeof (dirent),
|
||||
if (grub_ufs_read_file (data, 0, 0, pos + sizeof (dirent),
|
||||
namelen, filename) < 0)
|
||||
break;
|
||||
|
||||
|
@ -752,7 +752,8 @@ grub_ufs_read (grub_file_t file, char *buf, grub_size_t len)
|
|||
struct grub_ufs_data *data =
|
||||
(struct grub_ufs_data *) file->data;
|
||||
|
||||
return grub_ufs_read_file (data, file->read_hook, file->offset, len, buf);
|
||||
return grub_ufs_read_file (data, file->read_hook, file->read_hook_data,
|
||||
file->offset, len, buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue