Remove nested functions from device iterators
PATCH 1/1 Remove nested functions from device iterators
Part four of my nested functions patch set. (I promise that they will start getting less indigestibly enormous soon, although the filesystems upheaval is still to come!) There are lots of little size increases in modules here due to passing extra hook data arguments through, but as you can see it still results in smaller uncompressed and compressed kernel images and smaller typical core images:
DOWN: obj/amd64-efi/grub-core/kernel.img (96960 > 96824) - change: -136
DOWN: obj/i386-coreboot/grub-core/kernel.img (27912 > 27864) - change: -48
DOWN: obj/i386-efi/grub-core/kernel.img (59528 > 59488) - change: -40
DOWN: obj/i386-ieee1275/grub-core/kernel.img (48404 > 48360) - change: -44
DOWN: obj/i386-pc/grub-core/kernel.img (28896 > 28848) - change: -48
UP: obj/amd64-efi/grub-core/ahci.mod (13352 < 13368) - change: 16
DOWN: obj/amd64-efi/grub-core/ata.mod (8680 > 8616) - change: -64
DOWN: obj/amd64-efi/grub-core/btrfs.mod (19224 > 19112) - change: -112
UP: obj/amd64-efi/grub-core/cryptodisk.mod (13832 < 13848) - change: 16
DOWN: obj/amd64-efi/grub-core/diskfilter.mod (13872 > 13816) - change: -56
DOWN: obj/amd64-efi/grub-core/ldm.mod (8536 > 8504) - change: -32
UP: obj/amd64-efi/grub-core/loopback.mod (4720 < 4736) - change: 16
DOWN: obj/amd64-efi/grub-core/ls.mod (7032 > 7000) - change: -32
UP: obj/amd64-efi/grub-core/normal.mod (175880 < 175896) - change: 16 UP: obj/amd64-efi/grub-core/part_acorn.mod (2288 < 2304) - change: 16 UP: obj/amd64-efi/grub-core/part_amiga.mod (2568 < 2584) - change: 16 UP: obj/amd64-efi/grub-core/part_bsd.mod (4160 < 4176) - change: 16 UP: obj/amd64-efi/grub-core/part_gpt.mod (3216 < 3232) - change: 16 UP: obj/amd64-efi/grub-core/part_msdos.mod (3024 < 3040) - change: 16 UP: obj/amd64-efi/grub-core/part_plan.mod (2512 < 2528) - change: 16 UP: obj/amd64-efi/grub-core/part_sun.mod (2200 < 2216) - change: 16 UP: obj/amd64-efi/grub-core/part_sunpc.mod (2440 < 2456) - change: 16 DOWN: obj/amd64-efi/grub-core/regexp.mod (79056 > 79008) - change: -48 DOWN: obj/amd64-efi/grub-core/scsi.mod (7792 > 7760) - change: -32 DOWN: obj/amd64-efi/grub-core/search_fs_file.mod (5128 > 5064) - change: -64 DOWN: obj/amd64-efi/grub-core/search_fs_uuid.mod (5072 > 4992) - change: -80 DOWN: obj/amd64-efi/grub-core/search_label.mod (5008 > 4936) - change: -72 UP: obj/amd64-efi/grub-core/usbms.mod (11344 < 11360) - change: 16 DOWN: obj/amd64-efi/grub-core/zfs.mod (54168 > 54136) - change: -32 UP: obj/i386-coreboot/grub-core/ahci.mod (8656 < 8668) - change: 12 DOWN: obj/i386-coreboot/grub-core/ata.mod (5436 > 5420) - change: -16 DOWN: obj/i386-coreboot/grub-core/btrfs.mod (14296 > 14168) - change: -128 UP: obj/i386-coreboot/grub-core/cryptodisk.mod (8728 < 8732) - change: 4 DOWN: obj/i386-coreboot/grub-core/diskfilter.mod (9724 > 9700) - change: -24 DOWN: obj/i386-coreboot/grub-core/ldm.mod (6772 > 6756) - change: -16 UP: obj/i386-coreboot/grub-core/loopback.mod (2920 < 2932) - change: 12 DOWN: obj/i386-coreboot/grub-core/ls.mod (4320 > 4292) - change: -28 UP: obj/i386-coreboot/grub-core/normal.mod (111972 < 111980) - change: 8 UP: obj/i386-coreboot/grub-core/part_acorn.mod (1632 < 1668) - change: 36 UP: obj/i386-coreboot/grub-core/part_amiga.mod (1796 < 1808) - change: 12 UP: obj/i386-coreboot/grub-core/part_apple.mod (2064 < 2076) - change: 12 UP: obj/i386-coreboot/grub-core/part_dvh.mod (1460 < 1464) - change: 4 UP: obj/i386-coreboot/grub-core/part_gpt.mod (2368 < 2376) - change: 8 UP: obj/i386-coreboot/grub-core/part_msdos.mod (2352 < 2364) - change: 12 DOWN: obj/i386-coreboot/grub-core/part_plan.mod (1808 > 1800) - change: -8 UP: obj/i386-coreboot/grub-core/part_sun.mod (1500 < 1512) - change: 12 UP: obj/i386-coreboot/grub-core/part_sunpc.mod (1608 < 1620) - change: 12 UP: obj/i386-coreboot/grub-core/pata.mod (4676 < 4688) - change: 12 DOWN: obj/i386-coreboot/grub-core/regexp.mod (51592 > 51564) - change: -28 DOWN: obj/i386-coreboot/grub-core/scsi.mod (5068 > 5060) - change: -8 DOWN: obj/i386-coreboot/grub-core/search_fs_file.mod (3304 > 3236) - change: -68 DOWN: obj/i386-coreboot/grub-core/search_fs_uuid.mod (3276 > 3208) - change: -68 DOWN: obj/i386-coreboot/grub-core/search_label.mod (3208 > 3140) - change: -68 UP: obj/i386-coreboot/grub-core/usbms.mod (7180 < 7192) - change: 12 DOWN: obj/i386-coreboot/grub-core/zfs.mod (36560 > 36528) - change: -32 DOWN: obj/i386-efi/grub-core/ata.mod (5576 > 5552) - change: -24 DOWN: obj/i386-efi/grub-core/btrfs.mod (14640 > 14520) - change: -120 UP: obj/i386-efi/grub-core/cryptodisk.mod (8840 < 8844) - change: 4 DOWN: obj/i386-efi/grub-core/diskfilter.mod (10024 > 10000) - change: -24 DOWN: obj/i386-efi/grub-core/ldm.mod (6996 > 6964) - change: -32 DOWN: obj/i386-efi/grub-core/ls.mod (4496 > 4476) - change: -20 UP: obj/i386-efi/grub-core/normal.mod (116464 < 116468) - change: 4 UP: obj/i386-efi/grub-core/part_apple.mod (2060 < 2064) - change: 4 UP: obj/i386-efi/grub-core/part_bsd.mod (2880 < 2896) - change: 16 UP: obj/i386-efi/grub-core/part_plan.mod (1824 < 1828) - change: 4 UP: obj/i386-efi/grub-core/part_sunpc.mod (1632 < 1636) - change: 4 DOWN: obj/i386-efi/grub-core/regexp.mod (53464 > 53440) - change: -24 DOWN: obj/i386-efi/grub-core/scsi.mod (5088 > 5084) - change: -4 DOWN: obj/i386-efi/grub-core/search_fs_file.mod (3440 > 3384) - change: -56 DOWN: obj/i386-efi/grub-core/search_fs_uuid.mod (3416 > 3360) - change: -56 DOWN: obj/i386-efi/grub-core/search_label.mod (3356 > 3300) - change: -56 DOWN: obj/i386-efi/grub-core/zfs.mod (37712 > 37672) - change: -40 UP: obj/i386-ieee1275/grub-core/ahci.mod (8656 < 8668) - change: 12 DOWN: obj/i386-ieee1275/grub-core/ata.mod (5436 > 5420) - change: -16 DOWN: obj/i386-ieee1275/grub-core/btrfs.mod (14296 > 14168) - change: -128 UP: obj/i386-ieee1275/grub-core/cryptodisk.mod (8720 < 8724) - change: 4 DOWN: obj/i386-ieee1275/grub-core/diskfilter.mod (9724 > 9700) - change: -24 DOWN: obj/i386-ieee1275/grub-core/ldm.mod (6772 > 6756) - change: -16 UP: obj/i386-ieee1275/grub-core/loopback.mod (2848 < 2860) - change: 12 DOWN: obj/i386-ieee1275/grub-core/ls.mod (4312 > 4284) - change: -28 UP: obj/i386-ieee1275/grub-core/nand.mod (2520 < 2536) - change: 16 UP: obj/i386-ieee1275/grub-core/normal.mod (111964 < 111972) - change: 8 UP: obj/i386-ieee1275/grub-core/part_acorn.mod (1632 < 1668) - change: 36 UP: obj/i386-ieee1275/grub-core/part_amiga.mod (1796 < 1808) - change: 12 UP: obj/i386-ieee1275/grub-core/part_apple.mod (2064 < 2076) - change: 12 UP: obj/i386-ieee1275/grub-core/part_dvh.mod (1460 < 1464) - change: 4 UP: obj/i386-ieee1275/grub-core/part_gpt.mod (2368 < 2376) - change: 8 UP: obj/i386-ieee1275/grub-core/part_msdos.mod (2352 < 2364) - change: 12 DOWN: obj/i386-ieee1275/grub-core/part_plan.mod (1808 > 1800) - change: -8 UP: obj/i386-ieee1275/grub-core/part_sun.mod (1500 < 1512) - change: 12 UP: obj/i386-ieee1275/grub-core/part_sunpc.mod (1608 < 1620) - change: 12 UP: obj/i386-ieee1275/grub-core/pata.mod (4676 < 4688) - change: 12 DOWN: obj/i386-ieee1275/grub-core/regexp.mod (51584 > 51556) - change: -28 DOWN: obj/i386-ieee1275/grub-core/scsi.mod (5068 > 5060) - change: -8 DOWN: obj/i386-ieee1275/grub-core/search_fs_file.mod (3304 > 3236) - change: -68 DOWN: obj/i386-ieee1275/grub-core/search_fs_uuid.mod (3276 > 3208) - change: -68 DOWN: obj/i386-ieee1275/grub-core/search_label.mod (3208 > 3140) - change: -68 UP: obj/i386-ieee1275/grub-core/usbms.mod (7180 < 7192) - change: 12 DOWN: obj/i386-ieee1275/grub-core/zfs.mod (36560 > 36528) - change: -32 UP: obj/i386-pc/grub-core/ahci.mod (8656 < 8668) - change: 12 DOWN: obj/i386-pc/grub-core/ata.mod (5436 > 5420) - change: -16 UP: obj/i386-pc/grub-core/biosdisk.mod (4664 < 4684) - change: 20 DOWN: obj/i386-pc/grub-core/btrfs.mod (14296 > 14168) - change: -128 UP: obj/i386-pc/grub-core/cryptodisk.mod (8728 < 8732) - change: 4 DOWN: obj/i386-pc/grub-core/diskfilter.mod (9724 > 9700) - change: -24 DOWN: obj/i386-pc/grub-core/ldm.mod (6772 > 6756) - change: -16 UP: obj/i386-pc/grub-core/loopback.mod (2920 < 2932) - change: 12 DOWN: obj/i386-pc/grub-core/ls.mod (4320 > 4292) - change: -28 UP: obj/i386-pc/grub-core/normal.mod (111944 < 111952) - change: 8 UP: obj/i386-pc/grub-core/part_acorn.mod (1632 < 1668) - change: 36 UP: obj/i386-pc/grub-core/part_amiga.mod (1796 < 1808) - change: 12 UP: obj/i386-pc/grub-core/part_apple.mod (2064 < 2076) - change: 12 UP: obj/i386-pc/grub-core/part_dvh.mod (1460 < 1464) - change: 4 UP: obj/i386-pc/grub-core/part_gpt.mod (2368 < 2376) - change: 8 UP: obj/i386-pc/grub-core/part_msdos.mod (2352 < 2364) - change: 12 DOWN: obj/i386-pc/grub-core/part_plan.mod (1808 > 1800) - change: -8 UP: obj/i386-pc/grub-core/part_sun.mod (1500 < 1512) - change: 12 UP: obj/i386-pc/grub-core/part_sunpc.mod (1608 < 1620) - change: 12 UP: obj/i386-pc/grub-core/pata.mod (4676 < 4688) - change: 12
DOWN: obj/i386-pc/grub-core/plan9.mod (6296 > 6160) - change: -136
DOWN: obj/i386-pc/grub-core/regexp.mod (51592 > 51564) - change: -28
DOWN: obj/i386-pc/grub-core/scsi.mod (5068 > 5060) - change: -8
DOWN: obj/i386-pc/grub-core/search_fs_file.mod (3304 > 3236) - change: -68
DOWN: obj/i386-pc/grub-core/search_fs_uuid.mod (3276 > 3208) - change: -68
DOWN: obj/i386-pc/grub-core/search_label.mod (3208 > 3140) - change: -68
UP: obj/i386-pc/grub-core/usbms.mod (7180 < 7192) - change: 12
DOWN: obj/i386-pc/grub-core/zfs.mod (36560 > 36528) - change: -32
DOWN: i386-pc core image (biosdisk ext2 part_msdos) (26691 > 26670) - change: -21
DOWN: i386-pc core image (biosdisk ext2 part_msdos lvm mdraid1x) (34046 > 34033) - change: -13
In accordance with Vladimir's latest mail, I didn't document everything in the ChangeLog, although I do generally feel uncomfortable about making major internal interface changes without ChangeLog-style documentation, so I compromised and produced file-by-file descriptions of just the changes to include/. Does this look reasonable? It's certainly much shorter and clearer than a full old-style ChangeLog entry would have been.
=== modified file 'ChangeLog'
ChangeLog +26 -0
@@ -1,3 +1,29 @@ +2013-01-16 Colin Watson <[email protected]> + + Remove nested functions from device iteration. + + * include/grub/arc/arc.h (grub_arc_iterate_devs_hook_t): New type. + (grub_arc_iterate_devs): Add hook_data argument. + * include/grub/ata.h (grub_ata_dev_iterate_hook_t): New type. + (struct grub_ata_dev.iterate): Add hook_data argument. + * include/grub/device.h (grub_device_iterate_hook_t): New type. + (grub_device_iterate): Add hook_data argument. + * include/grub/disk.h (grub_disk_dev_iterate_hook_t): New type. + (struct grub_disk_dev.iterate): Add hook_data argument. + (grub_disk_dev_iterate): Likewise. + * include/grub/gpt_partition.h (grub_gpt_partition_map_iterate): + Likewise. + * include/grub/msdos_partition.h (grub_partition_msdos_iterate): + Likewise. + * include/grub/partition.h (grub_partition_iterate_hook_t): New + type. + (struct grub_partition_map.iterate): Add hook_data argument. + (grub_partition_iterate): Likewise. + * include/grub/scsi.h (grub_scsi_dev_iterate_hook_t): New type. + (struct grub_scsi_dev.iterate): Add hook_data argument. + + Update all callers. + 2013-01-16 Vladimir Serbinenko <[email protected]> Improve bidi handling in entry editor.
=== modified file 'grub-core/commands/arc/lsdev.c'
commands/arc/lsdev.c +11 -7
@@ -24,18 +24,22 @@GRUB_MOD_LICENSE ("GPLv3+" ); +/* Helper for grub_cmd_lsdev. */ +static int +grub_cmd_lsdev_iter (const char *name, +const struct grub_arc_component *comp __attribute__ ((unused)), +void *data __attribute__ ((unused))) +{ +grub_printf ("%s\n" , name); +return 0 ; +} +static grub_err_t grub_cmd_lsdev (grub_command_t cmd __attribute__ ((unused)),int argc __attribute__ ((unused)),char **args __attribute__ ((unused))) { - autoint hook (const char *name,const struct grub_arc_component *comp); -int hook (const char *name,const struct grub_arc_component *comp __attribute__ ((unused))) - { -grub_printf ("%s\n" , name); -return 0 ; - } -grub_arc_iterate_devs (hook,0 ); +grub_arc_iterate_devs (grub_cmd_lsdev_iter,0 ,0 );return 0 ; }
=== modified file 'grub-core/commands/ls.c'
commands/ls.c +15 -12
@@ -45,21 +45,24 @@ static const struct grub_arg_option optistatic const char grub_human_sizes[] = {' ' ,'K' ,'M' ,'G' ,'T' }; -static grub_err_t -grub_ls_list_devices (int longlist) +/* Helper for grub_ls_list_devices. */ +static int +grub_ls_print_devices (const char *name,void *data) { - autoint grub_ls_print_devices (const char *name); -int grub_ls_print_devices (const char *name) - { -if (longlist) -grub_normal_print_device_info (name); -else -grub_printf ("(%s) " , name); +int *longlist = data; + +if (longlist) +grub_normal_print_device_info (name); +else +grub_printf ("(%s) " , name); -return 0 ; - } +return 0 ; +} -grub_device_iterate (grub_ls_print_devices); +static grub_err_t +grub_ls_list_devices (int longlist) +{ +grub_device_iterate (grub_ls_print_devices, &longlist);grub_xputs ("\n" );#if 0
=== modified file 'grub-core/commands/search.c'
commands/search.c +216 -192
446 lines not on this page · raw message
=== modified file 'grub-core/commands/wildcard.c'
commands/wildcard.c +50 -38
109 lines not on this page · raw message
=== modified file 'grub-core/disk/ahci.c'
disk/ahci.c +3 -3
@@ -455,8 +455,8 @@ grub_ahci_restore_hw (void)static int -grub_ahci_iterate (int (*hook) (int id,int bus), -grub_disk_pull_t pull) +grub_ahci_iterate (grub_ata_dev_iterate_hook_t hook,void *hook_data, +grub_disk_pull_t pull) {struct grub_ahci_device *dev;
@@ -464,7 +464,7 @@ grub_ahci_iterate (int (*hook) (int id,return 0 ; FOR_LIST_ELEMENTS(dev, grub_ahci_devices) -if (hook (GRUB_SCSI_SUBSYSTEM_AHCI , dev->num)) +if (hook (GRUB_SCSI_SUBSYSTEM_AHCI , dev->num, hook_data))return 1 ;return 0 ;
=== modified file 'grub-core/disk/arc/arcdisk.c'
disk/arc/arcdisk.c +24 -10
@@ -80,23 +80,37 @@ arcdisk_hash_add (char *devpath) } +/* Context for grub_arcdisk_iterate. */ +struct grub_arcdisk_iterate_ctx +{ +grub_disk_dev_iterate_hook_t hook; +void *hook_data; +}; + +/* Helper for grub_arcdisk_iterate. */ +static int +grub_arcdisk_iterate_iter (const char *name, +const struct grub_arc_component *comp,void *data) +{ +struct grub_arcdisk_iterate_ctx *ctx = data; + +if (!(comp->type ==GRUB_ARC_COMPONENT_TYPE_DISK + || comp->type ==GRUB_ARC_COMPONENT_TYPE_DISK + || comp->type ==GRUB_ARC_COMPONENT_TYPE_TAPE )) +return 0 ; +return ctx->hook (name, ctx->hook_data); +} +static int grub_arcdisk_iterate (int (*hook_in) (const char *name),grub_disk_pull_t pull) { - autoint hook (const char *name,const struct grub_arc_component *comp); -int hook (const char *name,const struct grub_arc_component *comp) - { -if (!(comp->type ==GRUB_ARC_COMPONENT_TYPE_DISK - || comp->type ==GRUB_ARC_COMPONENT_TYPE_DISK - || comp->type ==GRUB_ARC_COMPONENT_TYPE_TAPE )) -return 0 ; -return hook_in (name); - } +struct grub_arcdisk_iterate_ctx ctx = { hook, hook_data }; +if (pull !=GRUB_DISK_PULL_NONE )return 0 ; -return grub_arc_iterate_devs (hook,1 ); +return grub_arc_iterate_devs (grub_arcdisk_iterate_iter, &ctx,1 ); }#define RAW_SUFFIX "partition(10)"
=== modified file 'grub-core/disk/ata.c'
disk/ata.c +71 -51
148 lines not on this page · raw message
=== modified file 'grub-core/disk/cryptodisk.c'
disk/cryptodisk.c +7 -6
@@ -448,8 +448,8 @@ grub_cryptodisk_setkey (grub_cryptodisk_ }static int -grub_cryptodisk_iterate (int (*hook) (const char *name), -grub_disk_pull_t pull) +grub_cryptodisk_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data, +grub_disk_pull_t pull) {grub_cryptodisk_t i;
@@ -460,7 +460,7 @@ grub_cryptodisk_iterate (int (*hook) (co {char buf[30 ];grub_snprintf (buf,sizeof (buf),"crypto%lu" , i->id); -if (hook (buf)) +if (hook (buf, hook_data))return 1 ; }
@@ -866,7 +866,8 @@ grub_cryptodisk_cheat_mount (const char#endif static int -grub_cryptodisk_scan_device (const char *name) +grub_cryptodisk_scan_device (const char *name, +void *data __attribute__ ((unused))) {grub_err_t err;grub_disk_t source;
@@ -908,7 +909,7 @@ grub_cmd_cryptomount (grub_extcmd_contex check_boot = state[2 ].set; search_uuid = args[0 ]; -grub_device_iterate (&grub_cryptodisk_scan_device); +grub_device_iterate (&grub_cryptodisk_scan_device,NULL ); search_uuid =NULL ;if (!have_it)
@@ -919,7 +920,7 @@ grub_cmd_cryptomount (grub_extcmd_contex { search_uuid =NULL ; check_boot = state[2 ].set; -grub_device_iterate (&grub_cryptodisk_scan_device); +grub_device_iterate (&grub_cryptodisk_scan_device,NULL ); search_uuid =NULL ;return GRUB_ERR_NONE ; }
=== modified file 'grub-core/disk/diskfilter.c'
disk/diskfilter.c +57 -54
170 lines not on this page · raw message
=== modified file 'grub-core/disk/efi/efidisk.c'
disk/efi/efidisk.c +40 -29
126 lines not on this page · raw message
=== modified file 'grub-core/disk/host.c'
disk/host.c +2 -2
@@ -27,13 +27,13 @@int grub_disk_host_i_want_a_reference;static int -grub_host_iterate (int (*hook) (const char *name), +grub_host_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {if (pull !=GRUB_DISK_PULL_NONE )return 0 ; -if (hook ("host" )) +if (hook ("host" , hook_data))return 1 ;return 0 ; }
=== modified file 'grub-core/disk/i386/pc/biosdisk.c'
disk/i386/pc/biosdisk.c +8 -7
@@ -272,20 +272,21 @@ grub_biosdisk_get_drive (const char *nam }static int -grub_biosdisk_call_hook (int (*hook) (const char *name),int drive) +grub_biosdisk_call_hook (grub_disk_dev_iterate_hook_t hook,void *hook_data, +int drive) {char name[10 ];if (cd_drive && drive == cd_drive) -return hook ("cd" ); +return hook ("cd" , hook_data);grub_snprintf (name,sizeof (name), (drive &0x80 ) ?"hd%d" :"fd%d" , drive & (~0x80 )); -return hook (name); +return hook (name, hook_data); }static int -grub_biosdisk_iterate (int (*hook) (const char *name), +grub_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull __attribute__ ((unused))) {int num_floppies;
@@ -304,7 +305,7 @@ grub_biosdisk_iterate (int (*hook) (consbreak ; } -if (grub_biosdisk_call_hook (hook, drive)) +if (grub_biosdisk_call_hook (hook, hook_data, drive))return 1 ; }return 0 ;
@@ -312,14 +313,14 @@ grub_biosdisk_iterate (int (*hook) (conscase GRUB_DISK_PULL_REMOVABLE :if (cd_drive) { -if (grub_biosdisk_call_hook (hook, cd_drive)) +if (grub_biosdisk_call_hook (hook, hook_data, cd_drive))return 1 ; }/* For floppy disks, we can get the number safely. */ num_floppies =grub_biosdisk_get_num_floppies ();for (drive =0 ; drive < num_floppies; drive++) -if (grub_biosdisk_call_hook (hook, drive)) +if (grub_biosdisk_call_hook (hook, hook_data, drive))return 1 ;return 0 ;default :
=== modified file 'grub-core/disk/ieee1275/nand.c'
disk/ieee1275/nand.c +2 -2
@@ -33,7 +33,7 @@ struct grub_nand_data };static int -grub_nand_iterate (int (*hook) (const char *name), +grub_nand_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) { autoint dev_iterate (struct grub_ieee1275_devalias *alias);
@@ -41,7 +41,7 @@ grub_nand_iterate (int (*hook) (const ch {if (grub_strcmp (alias->name,"nand" ) ==0 ) { -hook (alias->name); +hook (alias->name, hook_data);return 1 ; }
=== modified file 'grub-core/disk/ieee1275/ofdisk.c'
disk/ieee1275/ofdisk.c +2 -2
@@ -218,7 +218,7 @@ scan (void) }static int -grub_ofdisk_iterate (int (*hook) (const char *name), +grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {unsigned i;
@@ -276,7 +276,7 @@ grub_ofdisk_iterate (int (*hook) (const *optr++ = *iptr++; } *optr =0 ; -if (hook (buffer)) +if (hook (buffer, hook_data))return 1 ; } }
=== modified file 'grub-core/disk/ldm.c'
disk/ldm.c +28 -24
63 lines not on this page · raw message
=== modified file 'grub-core/disk/loopback.c'
disk/loopback.c +3 -3
@@ -135,15 +135,15 @@ fail:static int -grub_loopback_iterate (int (*hook) (const char *name), -grub_disk_pull_t pull) +grub_loopback_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data, +grub_disk_pull_t pull) {struct grub_loopback *d;if (pull !=GRUB_DISK_PULL_NONE )return 0 ;for (d = loopback_list; d; d = d->next) { -if (hook (d->devname)) +if (hook (d->devname, hook_data))return 1 ; }return 0 ;
=== modified file 'grub-core/disk/memdisk.c'
disk/memdisk.c +2 -2
@@ -30,13 +30,13 @@ static char *memdisk_addr;static grub_off_t memdisk_size =0 ;static int -grub_memdisk_iterate (int (*hook) (const char *name), +grub_memdisk_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {if (pull !=GRUB_DISK_PULL_NONE )return 0 ; -return hook ("memdisk" ); +return hook ("memdisk" , hook_data); } static grub_err_t
=== modified file 'grub-core/disk/pata.c'
disk/pata.c +3 -2
@@ -501,7 +501,7 @@ grub_pata_open (int id, int devnum, stru }static int -grub_pata_iterate (int (*hook) (int id,int bus), +grub_pata_iterate (grub_ata_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {struct grub_pata_device *dev;
@@ -510,7 +510,8 @@ grub_pata_iterate (int (*hook) (int id,return 0 ;for (dev = grub_pata_devices; dev; dev = dev->next) -if (hook (GRUB_SCSI_SUBSYSTEM_PATA , dev->port *2 + dev->device)) +if (hook (GRUB_SCSI_SUBSYSTEM_PATA , dev->port *2 + dev->device, + hook_data))return 1 ;return 0 ;
=== modified file 'grub-core/disk/scsi.c'
disk/scsi.c +45 -36
95 lines not on this page · raw message
=== modified file 'grub-core/disk/usbms.c'
disk/usbms.c +3 -2
@@ -265,7 +265,7 @@ grub_usbms_attach (grub_usb_device_t usbstatic int -grub_usbms_iterate (int NESTED_FUNC_ATTR (*hook) (int id, int bus, int luns), +grub_usbms_iterate (grub_scsi_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {unsigned i;
@@ -278,7 +278,8 @@ grub_usbms_iterate (int NESTED_FUNC_ATTRfor (i =0 ; i <ARRAY_SIZE (grub_usbms_devices); i++)if (grub_usbms_devices[i]) { -if (hook (GRUB_SCSI_SUBSYSTEM_USBMS , i, grub_usbms_devices[i]->luns)) +if (hook (GRUB_SCSI_SUBSYSTEM_USBMS , i, grub_usbms_devices[i]->luns, + hook_data))return 1 ; }
=== modified file 'grub-core/fs/btrfs.c'
fs/btrfs.c +59 -44
129 lines not on this page · raw message
=== modified file 'grub-core/fs/zfs/zfs.c'
fs/zfs/zfs.c +38 -34
81 lines not on this page · raw message
=== modified file 'grub-core/kern/corecmd.c'
kern/corecmd.c +2 -2
@@ -96,7 +96,7 @@ grub_core_cmd_insmod (struct grub_comman }static int -grub_mini_print_devices (const char *name) +grub_mini_print_devices (const char *name,void *data __attribute__ ((unused))) {grub_printf ("(%s) " , name);
@@ -119,7 +119,7 @@ grub_core_cmd_ls (struct grub_command *c {if (argc <1 ) { -grub_device_iterate (grub_mini_print_devices); +grub_device_iterate (grub_mini_print_devices,NULL );grub_xputs ("\n" );grub_refresh (); }
=== modified file 'grub-core/kern/device.c'
kern/device.c +80 -67
174 lines not on this page · raw message
=== modified file 'grub-core/kern/emu/hostdisk.c'
kern/emu/hostdisk.c +2 -2
@@ -223,7 +223,7 @@ find_free_slot (void) }static int -grub_util_biosdisk_iterate (int (*hook) (const char *name), +grub_util_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook,void *hook_data,grub_disk_pull_t pull) {unsigned i;
@@ -232,7 +232,7 @@ grub_util_biosdisk_iterate (int (*hook)return 0 ;for (i =0 ; i <sizeof (map) /sizeof (map[0 ]); i++) -if (map[i].drive &&hook (map[i].drive)) +if (map[i].drive &&hook (map[i].drive, hook_data))return 1 ;return 0 ;
=== modified file 'grub-core/kern/mips/arc/init.c'
kern/mips/arc/init.c +7 -7
@@ -48,8 +48,7 @@ const char *type_names[] = {static int iterate_rec (const char *prefix,const struct grub_arc_component *parent, -int (*hook) (const char *name, -const struct grub_arc_component *comp), +grub_arc_iterate_devs_hook_t hook,void *hook_data,int alt_names) {const struct grub_arc_component *comp;
@@ -67,12 +66,13 @@ iterate_rec (const char *prefix, const s name =grub_xasprintf ("%s%s(%lu)" , prefix, cname, comp->key);if (!name)return 1 ; -if (hook (name, comp)) +if (hook (name, comp, hook_data)) {grub_free (name);return 1 ; } -if (iterate_rec ((parent ? name : prefix), comp, hook, alt_names)) +if (iterate_rec ((parent ? name : prefix), comp, hook, hook_data, + alt_names)) {grub_free (name);return 1 ;
@@ -83,11 +83,11 @@ iterate_rec (const char *prefix, const s }int -grub_arc_iterate_devs (int (*hook) (const char *name, -const struct grub_arc_component *comp), +grub_arc_iterate_devs (grub_arc_iterate_devs_hook_t hook,void *hook_data,int alt_names) { -return iterate_rec ((alt_names ?"arc" :"" ),NULL , hook, alt_names); +return iterate_rec ((alt_names ?"arc" :"" ),NULL , hook, hook_data, + alt_names); } grub_err_t
=== modified file 'grub-core/kern/partition.c'
kern/partition.c +88 -68
189 lines not on this page · raw message
=== modified file 'grub-core/loader/i386/pc/plan9.c'
loader/i386/pc/plan9.c +275 -240
599 lines not on this page · raw message
=== modified file 'grub-core/normal/completion.c'
normal/completion.c +6 -5
@@ -99,7 +99,8 @@ add_completion (const char *completion, }static int -iterate_partition (grub_disk_t disk,const grub_partition_t p) +iterate_partition (grub_disk_t disk,const grub_partition_t p, +void *data __attribute__ ((unused))) {const char *disk_name = disk->name;char *name;
@@ -154,7 +155,7 @@ iterate_dir (const char *filename, const }static int -iterate_dev (const char *devname) +iterate_dev (const char *devname,void *data __attribute__ ((unused))) {grub_device_t dev;
@@ -180,7 +181,7 @@ iterate_dev (const char *devname) }if (dev->disk) -if (grub_partition_iterate (dev->disk, iterate_partition)) +if (grub_partition_iterate (dev->disk, iterate_partition,NULL )) {grub_device_close (dev);return 1 ;
@@ -213,7 +214,7 @@ complete_device (void)if (! p) {/* Complete the disk part. */ -if (grub_disk_dev_iterate (iterate_dev)) +if (grub_disk_dev_iterate (iterate_dev,NULL ))return 1 ; }else
@@ -228,7 +229,7 @@ complete_device (void) {if (dev->disk) { -if (grub_partition_iterate (dev->disk, iterate_partition)) +if (grub_partition_iterate (dev->disk, iterate_partition,NULL )) {grub_device_close (dev);return 1 ;
=== modified file 'grub-core/partmap/acorn.c'
partmap/acorn.c +3 -3
@@ -101,8 +101,8 @@ fail:static grub_err_t acorn_partition_map_iterate (grub_disk_t disk, -int (*hook) (grub_disk_t disk, -const grub_partition_t partition)) +grub_partition_iterate_hook_t hook, +void *hook_data) {struct grub_partition part;struct linux_part map[LINUX_MAP_ENTRIES ];
@@ -127,7 +127,7 @@ acorn_partition_map_iterate (grub_disk_t part.offset =6 ; part.number = part.index = i; -if (hook (disk, &part)) +if (hook (disk, &part, hook_data))return grub_errno; }
=== modified file 'grub-core/partmap/amiga.c'
partmap/amiga.c +3 -3
@@ -87,8 +87,8 @@ amiga_partition_map_checksum (void *buf,static grub_err_t amiga_partition_map_iterate (grub_disk_t disk, -int (*hook) (grub_disk_t disk, -const grub_partition_t partition)) +grub_partition_iterate_hook_t hook, +void *hook_data) {struct grub_partition part;struct grub_amiga_rdsk rdsk;
@@ -145,7 +145,7 @@ amiga_partition_map_iterate (grub_disk_t part.index =0 ; part.partmap = &grub_amiga_partition_map; -if (hook (disk, &part)) +if (hook (disk, &part, hook_data))return grub_errno; next =grub_be_to_cpu32 (apart.next);
=== modified file 'grub-core/partmap/apple.c'
partmap/apple.c +3 -3
@@ -101,8 +101,8 @@ static struct grub_partition_map grub_apstatic grub_err_t apple_partition_map_iterate (grub_disk_t disk, -int (*hook) (grub_disk_t disk, -const grub_partition_t partition)) +grub_partition_iterate_hook_t hook, +void *hook_data) {struct grub_partition part;struct grub_apple_header aheader;
@@ -163,7 +163,7 @@ apple_partition_map_iterate (grub_disk_tgrub_be_to_cpu32 (apart.first_phys_block), grub_be_to_cpu32 (apart.blockcnt)); -if (hook (disk, &part)) +if (hook (disk, &part, hook_data))return grub_errno; pos +=grub_be_to_cpu16 (aheader.blocksize);
=== modified file 'grub-core/partmap/bsdlabel.c'
partmap/bsdlabel.c +60 -43
141 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/dvh.c'
partmap/dvh.c +2 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/gpt.c'
partmap/gpt.c +49 -39
88 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/msdos.c'
partmap/msdos.c +3 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/plan.c'
partmap/plan.c +3 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/sun.c'
partmap/sun.c +2 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'grub-core/partmap/sunpc.c'
partmap/sunpc.c +3 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/arc/arc.h'
grub/arc/arc.h +6 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/ata.h'
grub/ata.h +3 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/device.h'
grub/device.h +4 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/disk.h'
grub/disk.h +5 -3
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/gpt_partition.h'
grub/gpt_partition.h +2 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/msdos_partition.h'
grub/msdos_partition.h +2 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/partition.h'
grub/partition.h +7 -4
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'include/grub/scsi.h'
grub/scsi.h +4 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
=== modified file 'util/getroot.c'
getroot.c +41 -31
72 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
=== modified file 'util/grub-setup.c'
grub-setup.c +70 -55
125 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Part of the diff is not shown here. View the raw message.