2008-08-28 Felix Zielcke * disk/lvm.c (modname): Add new static variable. * disk/scsi.c (modname): Likewise. * disk/ata.c (modname): Likewise. * disk/i386/pc/biosdisk.c (modname): Likewise. * disk/host.c (modname): Likewise. * disk/raid.c (modname): Likewise. * disk/efi/efidisk.c (modname): Likewise. * disk/memdisk.c (modname): Likewise. Index: disk/lvm.c =================================================================== --- disk/lvm.c (Revision 1831) +++ disk/lvm.c (Arbeitskopie) @@ -24,6 +24,8 @@ #include #include +static const char[] modname = "lvm"; + static struct grub_lvm_vg *vg_list; static int lv_count; @@ -569,7 +571,7 @@ grub_lvm_scan_device (const char *name) static struct grub_disk_dev grub_lvm_dev = { - .name = "lvm", + .name = modname, .id = GRUB_DISK_DEVICE_LVM_ID, .iterate = grub_lvm_iterate, .open = grub_lvm_open, Index: disk/scsi.c =================================================================== --- disk/scsi.c (Revision 1831) +++ disk/scsi.c (Arbeitskopie) @@ -27,6 +27,8 @@ #include #include +static const char modname[] = "scsi"; + static grub_scsi_dev_t grub_scsi_dev_list; @@ -248,7 +250,7 @@ grub_scsi_open (const char *name, grub_d { if (! p->open (name, scsi)) { - disk->id = (unsigned long) "scsi"; /* XXX */ + disk->id = (unsigned long) modname; /* XXX */ disk->data = scsi; scsi->dev = p; scsi->lun = lun; @@ -259,17 +261,17 @@ grub_scsi_open (const char *name, grub_d return grub_errno; } - grub_dprintf ("scsi", "dev opened\n"); + grub_dprintf (modname, "dev opened\n"); err = grub_scsi_inquiry (scsi); if (err) { - grub_dprintf ("scsi", "inquiry failed\n"); + grub_dprintf (modname, "inquiry failed\n"); p->close (scsi); return grub_errno; } - grub_dprintf ("scsi", "inquiry: devtype=0x%02x removable=%d\n", + grub_dprintf (modname, "inquiry: devtype=0x%02x removable=%d\n", scsi->devtype, scsi->removable); /* Try to be conservative about the device types @@ -290,7 +292,7 @@ grub_scsi_open (const char *name, grub_d err = grub_scsi_read_capacity (scsi); if (err) { - grub_dprintf ("scsi", "READ CAPACITY failed\n"); + grub_dprintf (modname, "READ CAPACITY failed\n"); p->close (scsi); return grub_errno; } @@ -300,7 +302,7 @@ grub_scsi_open (const char *name, grub_d disk->total_sectors = ((scsi->size * scsi->blocksize) << GRUB_DISK_SECTOR_BITS); - grub_dprintf ("scsi", "capacity=%d, blksize=%d\n", + grub_dprintf (modname, "capacity=%d, blksize=%d\n", (int) disk->total_sectors, scsi->blocksize); return GRUB_ERR_NONE; @@ -364,7 +366,7 @@ grub_scsi_write (grub_disk_t disk __attr static struct grub_disk_dev grub_scsi_dev = { - .name = "scsi", + .name = modname, .id = GRUB_DISK_DEVICE_SCSI_ID, .iterate = grub_scsi_iterate, .open = grub_scsi_open, Index: disk/ata.c =================================================================== --- disk/ata.c (Revision 1831) +++ disk/ata.c (Arbeitskopie) @@ -27,6 +27,8 @@ /* XXX: For now this only works on i386. */ #include +static const char modname = modname; + typedef enum { GRUB_ATA_CHS, @@ -246,16 +248,16 @@ grub_ata_dumpinfo (struct grub_ata_devic /* The device information was read, dump it for debugging. */ grub_ata_strncpy (text, info + 20, 20); - grub_dprintf ("ata", "Serial: %s\n", text); + grub_dprintf (modname, "Serial: %s\n", text); grub_ata_strncpy (text, info + 46, 8); - grub_dprintf ("ata", "Firmware: %s\n", text); + grub_dprintf (modname, "Firmware: %s\n", text); grub_ata_strncpy (text, info + 54, 40); - grub_dprintf ("ata", "Model: %s\n", text); + grub_dprintf (modname, "Model: %s\n", text); if (! dev->atapi) { - grub_dprintf ("ata", "Addressing: %d\n", dev->addr); - grub_dprintf ("ata", "Sectors: %lld\n", dev->size); + grub_dprintf (modname, "Addressing: %d\n", dev->addr); + grub_dprintf (modname, "Sectors: %lld\n", dev->size); } } @@ -399,7 +401,7 @@ grub_ata_device_initialize (int port, in struct grub_ata_device *dev; struct grub_ata_device **devp; - grub_dprintf ("ata", "detecting device %d,%d (0x%x, 0x%x)\n", + grub_dprintf (modname, "detecting device %d,%d (0x%x, 0x%x)\n", port, device, addr, addr2); dev = grub_malloc (sizeof(*dev)); @@ -436,7 +438,7 @@ grub_ata_device_initialize (int port, in } grub_ata_wait (); - grub_dprintf ("ata", "Registers: %x %x %x %x\n", + grub_dprintf (modname, "Registers: %x %x %x %x\n", grub_ata_regget (dev, GRUB_ATA_REG_SECTORS), grub_ata_regget (dev, GRUB_ATA_REG_LBALOW), grub_ata_regget (dev, GRUB_ATA_REG_LBAMID), @@ -448,18 +450,18 @@ grub_ata_device_initialize (int port, in && grub_ata_regget (dev, GRUB_ATA_REG_LBAMID) == 0x14 && grub_ata_regget (dev, GRUB_ATA_REG_LBAHIGH) == 0xeb) { - grub_dprintf ("ata", "ATAPI signature detected\n"); + grub_dprintf (modname, "ATAPI signature detected\n"); } else if (grub_ata_regget (dev, GRUB_ATA_REG_SECTORS) == 0x01 && grub_ata_regget (dev, GRUB_ATA_REG_LBALOW) == 0x01 && grub_ata_regget (dev, GRUB_ATA_REG_LBAMID) == 0x00 && grub_ata_regget (dev, GRUB_ATA_REG_LBAHIGH) == 0x00) { - grub_dprintf ("ata", "ATA detected\n"); + grub_dprintf (modname, "ATA detected\n"); } else { - grub_dprintf ("ata", "incorrect signature\n"); + grub_dprintf (modname, "incorrect signature\n"); grub_free (dev); return 0; } @@ -534,7 +536,7 @@ grub_ata_pciinit (int bus, int device, i } } - grub_dprintf ("ata", + grub_dprintf (modname, "PCI dev (%d,%d,%d) compat=%d rega=0x%x regb=0x%x\n", bus, device, func, compat, rega, regb); @@ -905,7 +907,7 @@ grub_atapi_open (const char *name, struc } } - grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name); + grub_dprintf (modname, "opening ATAPI dev `%s'\n", name); if (! devfnd) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such ATAPI device"); Index: disk/host.c =================================================================== --- disk/host.c (Revision 1831) +++ disk/host.c (Arbeitskopie) @@ -24,6 +24,8 @@ #include #include +static const char[] modname = "host"; + int grub_disk_host_i_want_a_reference; static int @@ -37,11 +39,11 @@ grub_host_iterate (int (*hook) (const ch static grub_err_t grub_host_open (const char *name, grub_disk_t disk) { - if (grub_strcmp (name, "host")) + if (grub_strcmp (name, modname)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a host disk"); disk->total_sectors = 0; - disk->id = (unsigned long) "host"; + disk->id = (unsigned long) modname; disk->has_partitions = 0; disk->data = 0; @@ -75,7 +77,7 @@ grub_host_write (grub_disk_t disk __attr static struct grub_disk_dev grub_host_dev = { /* The only important line in this file :-) */ - .name = "host", + .name = modname, .id = GRUB_DISK_DEVICE_HOST_ID, .iterate = grub_host_iterate, .open = grub_host_open, Index: disk/raid.c =================================================================== --- disk/raid.c (Revision 1831) +++ disk/raid.c (Arbeitskopie) @@ -24,6 +24,8 @@ #include #include +static const char[] modname = modname; + /* Linked list of RAID arrays. */ static struct grub_raid_array *array_list; grub_raid5_recover_func_t grub_raid5_recover_func; @@ -130,7 +132,7 @@ grub_raid_open (const char *name, grub_d disk->id = array->number; disk->data = array; - grub_dprintf ("raid", "%s: total_devs=%d, disk_size=%lld\n", name, + grub_dprintf (modname, "%s: total_devs=%d, disk_size=%lld\n", name, array->total_devs, (unsigned long long) array->disk_size); switch (array->level) @@ -159,7 +161,7 @@ grub_raid_open (const char *name, grub_d break; } - grub_dprintf ("raid", "%s: level=%d, total_sectors=%lld\n", name, + grub_dprintf (modname, "%s: level=%d, total_sectors=%lld\n", name, array->level, (unsigned long long) disk->total_sectors); return 0; @@ -569,7 +571,7 @@ insert_array (grub_disk_t disk, struct g grub_sprintf (array->name, "md%d", array->number); - grub_dprintf ("raid", "Found array %s (%s)\n", array->name, + grub_dprintf (modname, "Found array %s (%s)\n", array->name, scanner_name); /* Add our new array to the list. */ @@ -596,7 +598,7 @@ grub_raid_scan_device (int head_only) struct grub_raid_array array; struct grub_raid *p; - grub_dprintf ("raid", "Scanning for RAID devices\n"); + grub_dprintf (modname, "Scanning for RAID devices\n"); disk = grub_disk_open (name); if (!disk) @@ -692,7 +694,7 @@ grub_raid_rescan (void) static struct grub_disk_dev grub_raid_dev = { - .name = "raid", + .name = modname, .id = GRUB_DISK_DEVICE_RAID_ID, .iterate = grub_raid_iterate, .open = grub_raid_open, Index: disk/efi/efidisk.c =================================================================== --- disk/efi/efidisk.c (Revision 1831) +++ disk/efi/efidisk.c (Arbeitskopie) @@ -27,6 +27,8 @@ #include #include +static const char[] modname = modname; + struct grub_efidisk_data { grub_efi_handle_t handle; @@ -441,7 +443,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = fd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "fd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (modname, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -449,7 +451,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = hd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "hd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (modname, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -457,7 +459,7 @@ grub_efidisk_iterate (int (*hook) (const for (d = cd_devices, count = 0; d; d = d->next, count++) { grub_sprintf (buf, "cd%d", count); - grub_dprintf ("efidisk", "iterating %s\n", buf); + grub_dprintf (modname, "iterating %s\n", buf); if (hook (buf)) return 1; } @@ -505,7 +507,7 @@ grub_efidisk_open (const char *name, str struct grub_efidisk_data *d = 0; grub_efi_block_io_media_t *m; - grub_dprintf ("efidisk", "opening %s\n", name); + grub_dprintf (modname, "opening %s\n", name); num = get_drive_number (name); if (num < 0) @@ -538,13 +540,13 @@ grub_efidisk_open (const char *name, str m = d->block_io->media; /* FIXME: Probably it is better to store the block size in the disk, and total sectors should be replaced with total blocks. */ - grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n", + grub_dprintf (modname, "m = %p, last block = %llx, block size = %x\n", m, (unsigned long long) m->last_block, m->block_size); disk->total_sectors = (m->last_block * (m->block_size >> GRUB_DISK_SECTOR_BITS)); disk->data = d; - grub_dprintf ("efidisk", "opening %s succeeded\n", name); + grub_dprintf (modname, "opening %s succeeded\n", name); return GRUB_ERR_NONE; } @@ -553,7 +555,7 @@ static void grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused))) { /* EFI disks do not allocate extra memory, so nothing to do here. */ - grub_dprintf ("efidisk", "closing %s\n", disk->name); + grub_dprintf (modname, "closing %s\n", disk->name); } static grub_err_t @@ -570,7 +572,7 @@ grub_efidisk_read (struct grub_disk *dis dio = d->disk_io; bio = d->block_io; - grub_dprintf ("efidisk", + grub_dprintf (modname, "reading 0x%lx sectors at the sector 0x%llx from %s\n", (unsigned long) size, (unsigned long long) sector, disk->name); @@ -598,7 +600,7 @@ grub_efidisk_write (struct grub_disk *di dio = d->disk_io; bio = d->block_io; - grub_dprintf ("efidisk", + grub_dprintf (modname, "writing 0x%lx sectors at the sector 0x%llx to %s\n", (unsigned long) size, (unsigned long long) sector, disk->name); @@ -614,7 +616,7 @@ grub_efidisk_write (struct grub_disk *di static struct grub_disk_dev grub_efidisk_dev = { - .name = "efidisk", + .name = modname, .id = GRUB_DISK_DEVICE_EFIDISK_ID, .iterate = grub_efidisk_iterate, .open = grub_efidisk_open, Index: disk/memdisk.c =================================================================== --- disk/memdisk.c (Revision 1831) +++ disk/memdisk.c (Arbeitskopie) @@ -25,19 +25,21 @@ #include #include +static const char[] modname = "memdisk"; + static char *memdisk_addr; static grub_off_t memdisk_size = 0; static int grub_memdisk_iterate (int (*hook) (const char *name)) { - return hook ("memdisk"); + return hook (modname); } static grub_err_t grub_memdisk_open (const char *name, grub_disk_t disk) { - if (grub_strcmp (name, "memdisk")) + if (grub_strcmp (name, modname)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a memdisk"); disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE; @@ -70,7 +72,7 @@ grub_memdisk_write (grub_disk_t disk __a static struct grub_disk_dev grub_memdisk_dev = { - .name = "memdisk", + .name = modname, .id = GRUB_DISK_DEVICE_MEMDISK_ID, .iterate = grub_memdisk_iterate, .open = grub_memdisk_open, @@ -90,12 +92,12 @@ GRUB_MOD_INIT(memdisk) char *memdisk_orig_addr; memdisk_orig_addr = (char *) header + sizeof (struct grub_module_header); - grub_dprintf ("memdisk", "Found memdisk image at %p\n", memdisk_orig_addr); + grub_dprintf (modname, "Found memdisk image at %p\n", memdisk_orig_addr); memdisk_size = header->size - sizeof (struct grub_module_header); memdisk_addr = grub_malloc (memdisk_size); - grub_dprintf ("memdisk", "Copying memdisk image to dynamic memory\n"); + grub_dprintf (modname, "Copying memdisk image to dynamic memory\n"); grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size); grub_disk_dev_register (&grub_memdisk_dev);