=== modified file 'ChangeLog' --- ChangeLog 2010-09-13 20:18:03 +0000 +++ ChangeLog 2010-09-13 21:59:22 +0000 @@ -1,5 +1,16 @@ 2010-09-13 Vladimir Serbinenko + * include/grub/disk.h (grub_disk): Remove has_partitions. + All users updated. + * disk/loopback.c (grub_loopback): Remove has_partitions. + All users updated. + (options): Remove partitions. All users updated. + * util/grub-fstest.c (fstest): Don't pass "-p" to loopback. + * util/i386/pc/grub-setup.c (setup): copy partition table only when + actual partition table is found. + +2010-09-13 Vladimir Serbinenko + Remove readability checks (too many false negatives). * util/grub-install.in: Remove readability checks. === modified file 'grub-core/disk/ata.c' --- grub-core/disk/ata.c 2010-07-10 00:59:33 +0000 +++ grub-core/disk/ata.c 2010-09-13 21:59:22 +0000 @@ -723,7 +723,6 @@ disk->id = (unsigned long) dev; - disk->has_partitions = 1; disk->data = dev; return 0; === modified file 'grub-core/disk/efi/efidisk.c' --- grub-core/disk/efi/efidisk.c 2010-02-16 12:13:02 +0000 +++ grub-core/disk/efi/efidisk.c 2010-09-13 21:59:22 +0000 @@ -514,16 +514,12 @@ switch (name[0]) { case 'f': - disk->has_partitions = 0; d = get_device (fd_devices, num); break; case 'c': - /* FIXME: a CDROM should have partitions, but not implemented yet. */ - disk->has_partitions = 0; d = get_device (cd_devices, num); break; case 'h': - disk->has_partitions = 1; d = get_device (hd_devices, num); break; default: === modified file 'grub-core/disk/host.c' --- grub-core/disk/host.c 2009-06-10 21:04:23 +0000 +++ grub-core/disk/host.c 2010-09-13 21:59:22 +0000 @@ -43,7 +43,6 @@ disk->total_sectors = 0; disk->id = (unsigned long) "host"; - disk->has_partitions = 0; disk->data = 0; return GRUB_ERR_NONE; === modified file 'grub-core/disk/i386/pc/biosdisk.c' --- grub-core/disk/i386/pc/biosdisk.c 2010-09-06 07:35:35 +0000 +++ grub-core/disk/i386/pc/biosdisk.c 2010-09-13 21:59:22 +0000 @@ -327,7 +327,6 @@ if (drive < 0) return grub_errno; - disk->has_partitions = 1; disk->id = drive; data = (struct grub_biosdisk_data *) grub_zalloc (sizeof (*data)); === modified file 'grub-core/disk/ieee1275/nand.c' --- grub-core/disk/ieee1275/nand.c 2010-01-03 22:05:07 +0000 +++ grub-core/disk/ieee1275/nand.c 2010-09-13 21:59:22 +0000 @@ -113,7 +113,6 @@ disk->id = dev_ihandle; - disk->has_partitions = 0; disk->data = data; return 0; === modified file 'grub-core/disk/ieee1275/ofdisk.c' --- grub-core/disk/ieee1275/ofdisk.c 2010-09-13 17:17:29 +0000 +++ grub-core/disk/ieee1275/ofdisk.c 2010-09-13 21:59:22 +0000 @@ -256,8 +256,6 @@ disk->data = op->devpath; } - /* XXX: Read this, somehow. */ - disk->has_partitions = 1; return 0; } === modified file 'grub-core/disk/loopback.c' --- grub-core/disk/loopback.c 2010-09-05 15:01:16 +0000 +++ grub-core/disk/loopback.c 2010-09-13 21:59:22 +0000 @@ -29,7 +29,6 @@ { char *devname; grub_file_t file; - int has_partitions; struct grub_loopback *next; }; @@ -38,7 +37,6 @@ static const struct grub_arg_option options[] = { {"delete", 'd', 0, N_("Delete the loopback device entry."), 0, 0}, - {"partitions", 'p', 0, N_("Simulate a hard drive with partitions."), 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -106,9 +104,6 @@ grub_file_close (newdev->file); newdev->file = file; - /* Set has_partitions when `--partitions' was used. */ - newdev->has_partitions = state[1].set; - return 0; } @@ -126,9 +121,6 @@ newdev->file = file; - /* Set has_partitions when `--partitions' was used. */ - newdev->has_partitions = state[1].set; - /* Add the new entry to the list. */ newdev->next = loopback_list; loopback_list = newdev; @@ -174,7 +166,6 @@ disk->total_sectors = GRUB_DISK_SIZE_UNKNOWN; disk->id = (unsigned long) dev; - disk->has_partitions = dev->has_partitions; disk->data = dev->file; return 0; === modified file 'grub-core/disk/lvm.c' --- grub-core/disk/lvm.c 2010-09-05 21:20:13 +0000 +++ grub-core/disk/lvm.c 2010-09-13 21:59:22 +0000 @@ -150,7 +150,6 @@ if (! lv) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown LVM device %s", name); - disk->has_partitions = 0; disk->id = lv->number; disk->data = lv; disk->total_sectors = lv->size; @@ -280,7 +279,11 @@ disk = grub_disk_open (name); if (!disk) - return 0; + { + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + grub_errno = GRUB_ERR_NONE; + return 0; + } /* Search for label. */ for (i = 0; i < GRUB_LVM_LABEL_SCAN_SECTORS; i++) @@ -725,6 +728,8 @@ grub_free (metadatabuf); fail: grub_disk_close (disk); + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + grub_errno = GRUB_ERR_NONE; return 0; } === modified file 'grub-core/disk/memdisk.c' --- grub-core/disk/memdisk.c 2010-02-07 22:49:49 +0000 +++ grub-core/disk/memdisk.c 2010-09-13 21:59:22 +0000 @@ -41,7 +41,6 @@ disk->total_sectors = memdisk_size / GRUB_DISK_SECTOR_SIZE; disk->id = (unsigned long) "mdsk"; - disk->has_partitions = 0; return GRUB_ERR_NONE; } === modified file 'grub-core/disk/raid.c' --- grub-core/disk/raid.c 2010-08-02 14:51:23 +0000 +++ grub-core/disk/raid.c 2010-09-13 21:59:22 +0000 @@ -126,7 +126,6 @@ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s", name); - disk->has_partitions = 1; disk->id = array->number; disk->data = array; === modified file 'grub-core/disk/scsi.c' --- grub-core/disk/scsi.c 2010-07-16 23:52:41 +0000 +++ grub-core/disk/scsi.c 2010-09-13 21:59:22 +0000 @@ -431,12 +431,6 @@ "unknown SCSI device"); } - if (scsi->devtype == grub_scsi_devtype_cdrom) - disk->has_partitions = 0; - else - disk->has_partitions = 1; - - /* According to USB MS tests specification, issue Test Unit Ready * until OK */ maxtime = grub_get_time_ms () + 5000; /* It is safer value */ === modified file 'grub-core/fs/i386/pc/pxe.c' --- grub-core/fs/i386/pc/pxe.c 2010-09-04 16:28:42 +0000 +++ grub-core/fs/i386/pc/pxe.c 2010-09-13 21:59:22 +0000 @@ -176,7 +176,6 @@ disk->total_sectors = 0; disk->id = (unsigned long) data; - disk->has_partitions = 0; disk->data = data; return GRUB_ERR_NONE; === modified file 'grub-core/kern/device.c' --- grub-core/kern/device.c 2010-03-31 20:03:48 +0000 +++ grub-core/kern/device.c 2010-09-13 21:59:22 +0000 @@ -103,7 +103,7 @@ return 0; } - if (dev->disk && dev->disk->has_partitions) + if (dev->disk) { struct part_ent *p; int ret = 0; === modified file 'grub-core/kern/disk.c' --- grub-core/kern/disk.c 2010-02-07 00:48:38 +0000 +++ grub-core/kern/disk.c 2010-09-13 21:59:22 +0000 @@ -281,12 +281,6 @@ goto fail; } - if (p && ! disk->has_partitions) - { - grub_error (GRUB_ERR_BAD_DEVICE, "no partition on this disk"); - goto fail; - } - disk->dev = dev; if (p) === modified file 'grub-core/kern/emu/hostdisk.c' --- grub-core/kern/emu/hostdisk.c 2010-09-13 11:09:58 +0000 +++ grub-core/kern/emu/hostdisk.c 2010-09-13 21:59:22 +0000 @@ -221,7 +221,6 @@ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no mapping exists for `%s'", name); - disk->has_partitions = 1; disk->id = drive; disk->data = data = xmalloc (sizeof (struct grub_util_biosdisk_data)); data->dev = NULL; === modified file 'grub-core/normal/completion.c' --- grub-core/normal/completion.c 2010-09-13 12:26:55 +0000 +++ grub-core/normal/completion.c 2010-09-13 21:59:22 +0000 @@ -160,14 +160,23 @@ if (dev) { - if (dev->disk && dev->disk->has_partitions) + char tmp[grub_strlen (devname) + sizeof (",")]; + + grub_memcpy (tmp, devname, grub_strlen (devname)); + + if (grub_strcmp (devname, current_word) == 0) { - if (add_completion (devname, ",", GRUB_COMPLETION_TYPE_DEVICE)) + if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_PARTITION)) return 1; + + if (dev->disk) + if (grub_partition_iterate (dev->disk, iterate_partition)) + return 1; } else { - if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_DEVICE)) + grub_memcpy (tmp + grub_strlen (devname), "", sizeof ("")); + if (add_completion (tmp, "", GRUB_COMPLETION_TYPE_DEVICE)) return 1; } } @@ -200,7 +209,7 @@ if (dev) { - if (dev->disk && dev->disk->has_partitions) + if (dev->disk) { if (grub_partition_iterate (dev->disk, iterate_partition)) { === modified file 'grub-core/normal/misc.c' --- grub-core/normal/misc.c 2010-09-12 18:18:50 +0000 +++ grub-core/normal/misc.c 2010-09-13 21:59:22 +0000 @@ -108,10 +108,8 @@ grub_errno = GRUB_ERR_NONE; } } - else if (! dev->disk->has_partitions || dev->disk->partition) - grub_printf ("%s", _("Unknown filesystem")); else - grub_printf ("%s", _("Partition table")); + grub_printf ("%s", _("Not a known filesystem")); if (dev->disk->partition) grub_printf (_(" - Partition start at %u"), === modified file 'include/grub/disk.h' --- include/grub/disk.h 2010-09-11 14:58:06 +0000 +++ include/grub/disk.h 2010-09-13 21:59:22 +0000 @@ -99,9 +99,6 @@ /* The total number of sectors. */ grub_uint64_t total_sectors; - /* If partitions can be stored. */ - int has_partitions; - /* The id used by the disk cache manager. */ unsigned long id; === modified file 'util/grub-fstest.c' --- util/grub-fstest.c 2010-09-05 11:05:36 +0000 +++ util/grub-fstest.c 2010-09-13 21:59:22 +0000 @@ -259,13 +259,11 @@ { char *host_file; char *loop_name; - char *argv[3]; int i; - argv[0] = "-p"; - for (i = 0; i < num_disks; i++) { + char *argv[2]; loop_name = grub_xasprintf ("loop%d", i); if (!loop_name) grub_util_error (grub_errmsg); @@ -274,10 +272,10 @@ if (!host_file) grub_util_error (grub_errmsg); - argv[1] = loop_name; - argv[2] = host_file; + argv[0] = loop_name; + argv[1] = host_file; - if (execute_command ("loopback", 3, argv)) + if (execute_command ("loopback", 2, argv)) grub_util_error ("loopback command fails"); grub_free (loop_name); @@ -312,15 +310,16 @@ execute_command ("blocklist", n, args); grub_printf ("\n"); } - - argv[0] = "-d"; - + for (i = 0; i < num_disks; i++) { + char *argv[2]; + loop_name = grub_xasprintf ("loop%d", i); if (!loop_name) grub_util_error (grub_errmsg); + argv[0] = "-d"; argv[1] = loop_name; execute_command ("loopback", 2, argv); === modified file 'util/i386/pc/grub-setup.c' --- util/i386/pc/grub-setup.c 2010-09-11 15:21:48 +0000 +++ util/i386/pc/grub-setup.c 2010-09-13 21:59:22 +0000 @@ -252,14 +252,6 @@ tmp_img + GRUB_BOOT_MACHINE_BPB_START, GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START); - /* Copy the possible partition table. */ - if (dest_dev->disk->has_partitions) - memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, - tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, - GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC); - - free (tmp_img); - /* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ @@ -300,12 +292,6 @@ grub_util_info ("dos partition is %d, bsd partition is %d", dos_part, bsd_part); - if (! dest_dev->disk->has_partitions) - { - grub_util_warn (_("Attempting to install GRUB to a partitionless disk. This is a BAD idea.")); - goto unable_to_embed; - } - if (dest_dev->disk->partition) { grub_util_warn (_("Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.")); @@ -345,6 +331,14 @@ goto unable_to_embed; } + /* Copy the partition table. */ + if (dest_partmap) + memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC); + + free (tmp_img); + if (strcmp (dest_partmap, "msdos") == 0) grub_partition_iterate (dest_dev->disk, find_usable_region_msdos); else if (strcmp (dest_partmap, "gpt") == 0)