merge mainline into emu-mod
This commit is contained in:
commit
19a9fb834b
459 changed files with 26481 additions and 7640 deletions
72
disk/ata.c
72
disk/ata.c
|
@ -26,8 +26,8 @@
|
|||
#include <grub/scsi.h>
|
||||
|
||||
/* At the moment, only two IDE ports are supported. */
|
||||
static const int grub_ata_ioaddress[] = { 0x1f0, 0x170 };
|
||||
static const int grub_ata_ioaddress2[] = { 0x3f6, 0x376 };
|
||||
static const grub_port_t grub_ata_ioaddress[] = { 0x1f0, 0x170 };
|
||||
static const grub_port_t grub_ata_ioaddress2[] = { 0x3f6, 0x376 };
|
||||
|
||||
static struct grub_ata_device *grub_ata_devices;
|
||||
|
||||
|
@ -281,7 +281,7 @@ grub_ata_identify (struct grub_ata_device *dev)
|
|||
else
|
||||
/* Other Error. */
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"device can not be identified");
|
||||
"device cannot be identified");
|
||||
}
|
||||
|
||||
grub_ata_pio_read (dev, info, GRUB_DISK_SECTOR_SIZE);
|
||||
|
@ -347,8 +347,8 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
|
|||
/* Setup the device information. */
|
||||
dev->port = port;
|
||||
dev->device = device;
|
||||
dev->ioaddress = addr;
|
||||
dev->ioaddress2 = addr2;
|
||||
dev->ioaddress = addr + GRUB_MACHINE_PCI_IO_BASE;
|
||||
dev->ioaddress2 = addr2 + GRUB_MACHINE_PCI_IO_BASE;
|
||||
dev->next = NULL;
|
||||
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4);
|
||||
|
@ -389,7 +389,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
|
|||
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_ata_pciinit (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid __attribute__((unused)))
|
||||
grub_pci_id_t pciid)
|
||||
{
|
||||
static int compat_use[2] = { 0 };
|
||||
grub_pci_address_t addr;
|
||||
|
@ -400,19 +400,34 @@ grub_ata_pciinit (grub_pci_device_t dev,
|
|||
int regb;
|
||||
int i;
|
||||
static int controller = 0;
|
||||
int cs5536 = 0;
|
||||
int nports = 2;
|
||||
|
||||
/* Read class. */
|
||||
addr = grub_pci_make_address (dev, 2);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
/* AMD CS5536 Southbridge. */
|
||||
if (pciid == 0x208f1022)
|
||||
{
|
||||
cs5536 = 1;
|
||||
nports = 1;
|
||||
}
|
||||
|
||||
/* Check if this class ID matches that of a PCI IDE Controller. */
|
||||
if (class >> 16 != 0x0101)
|
||||
if (!cs5536 && (class >> 16 != 0x0101))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
for (i = 0; i < nports; i++)
|
||||
{
|
||||
/* Set to 0 when the channel operated in compatibility mode. */
|
||||
int compat = (class >> (8 + 2 * i)) & 1;
|
||||
int compat;
|
||||
|
||||
/* We don't support non-compatibility mode for CS5536. */
|
||||
if (cs5536)
|
||||
compat = 0;
|
||||
else
|
||||
compat = (class >> (8 + 2 * i)) & 1;
|
||||
|
||||
rega = 0;
|
||||
regb = 0;
|
||||
|
@ -429,9 +444,12 @@ grub_ata_pciinit (grub_pci_device_t dev,
|
|||
{
|
||||
/* Read the BARs, which either contain a mmapped IO address
|
||||
or the IO port address. */
|
||||
addr = grub_pci_make_address (dev, 4 + 2 * i);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
|
||||
+ sizeof (grub_uint64_t) * i);
|
||||
bar1 = grub_pci_read (addr);
|
||||
addr = grub_pci_make_address (dev, 5 + 2 * i);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESSES
|
||||
+ sizeof (grub_uint64_t) * i
|
||||
+ sizeof (grub_uint32_t));
|
||||
bar2 = grub_pci_read (addr);
|
||||
|
||||
/* Check if the BARs describe an IO region. */
|
||||
|
@ -485,7 +503,6 @@ grub_ata_initialize (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
grub_ata_setlba (struct grub_ata_device *dev, grub_disk_addr_t sector,
|
||||
grub_size_t size)
|
||||
|
@ -520,7 +537,7 @@ grub_ata_setaddress (struct grub_ata_device *dev,
|
|||
|| cylinder > dev->cylinders
|
||||
|| head > dev->heads)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
"sector %d can not be addressed "
|
||||
"sector %d cannot be addressed "
|
||||
"using CHS addressing", sector);
|
||||
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_DISK, (dev->device << 4) | head);
|
||||
|
@ -648,12 +665,14 @@ grub_ata_iterate (int (*hook) (const char *name))
|
|||
|
||||
for (dev = grub_ata_devices; dev; dev = dev->next)
|
||||
{
|
||||
char devname[5];
|
||||
grub_sprintf (devname, "ata%d", dev->port * 2 + dev->device);
|
||||
char devname[10];
|
||||
|
||||
if (dev->atapi)
|
||||
continue;
|
||||
|
||||
grub_snprintf (devname, sizeof (devname),
|
||||
"ata%d", dev->port * 2 + dev->device);
|
||||
|
||||
if (hook (devname))
|
||||
return 1;
|
||||
}
|
||||
|
@ -668,14 +687,15 @@ grub_ata_open (const char *name, grub_disk_t disk)
|
|||
|
||||
for (dev = grub_ata_devices; dev; dev = dev->next)
|
||||
{
|
||||
char devname[5];
|
||||
grub_sprintf (devname, "ata%d", dev->port * 2 + dev->device);
|
||||
char devname[10];
|
||||
grub_snprintf (devname, sizeof (devname),
|
||||
"ata%d", dev->port * 2 + dev->device);
|
||||
if (grub_strcmp (name, devname) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
|
||||
if (dev->atapi)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not an ATA harddisk");
|
||||
|
@ -735,8 +755,9 @@ grub_atapi_iterate (int (*hook) (const char *name, int luns))
|
|||
|
||||
for (dev = grub_ata_devices; dev; dev = dev->next)
|
||||
{
|
||||
char devname[7];
|
||||
grub_sprintf (devname, "ata%d", dev->port * 2 + dev->device);
|
||||
char devname[10];
|
||||
grub_snprintf (devname, sizeof (devname),
|
||||
"ata%d", dev->port * 2 + dev->device);
|
||||
|
||||
if (! dev->atapi)
|
||||
continue;
|
||||
|
@ -775,7 +796,7 @@ grub_atapi_read (struct grub_scsi *scsi,
|
|||
|
||||
/* Count of last transfer may be uneven. */
|
||||
if (! (0 < cnt && cnt <= size - nread && (! (cnt & 1) || cnt == size - nread)))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Invalid ATAPI transfer count");
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "invalid ATAPI transfer count");
|
||||
|
||||
/* Read the data. */
|
||||
grub_ata_pio_read (dev, buf + nread, cnt);
|
||||
|
@ -808,8 +829,9 @@ grub_atapi_open (const char *name, struct grub_scsi *scsi)
|
|||
|
||||
for (dev = grub_ata_devices; dev; dev = dev->next)
|
||||
{
|
||||
char devname[7];
|
||||
grub_sprintf (devname, "ata%d", dev->port * 2 + dev->device);
|
||||
char devname[10];
|
||||
grub_snprintf (devname, sizeof (devname),
|
||||
"ata%d", dev->port * 2 + dev->device);
|
||||
|
||||
if (!grub_strcmp (devname, name))
|
||||
{
|
||||
|
@ -821,7 +843,7 @@ grub_atapi_open (const char *name, struct grub_scsi *scsi)
|
|||
grub_dprintf ("ata", "opening ATAPI dev `%s'\n", name);
|
||||
|
||||
if (! devfnd)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "No such ATAPI device");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such ATAPI device");
|
||||
|
||||
scsi->data = devfnd;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ grub_ata_pass_through (grub_disk_t disk,
|
|||
{
|
||||
if (disk->dev->id != GRUB_DISK_DEVICE_ATA_ID)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"Device not accessed via ata.mod");
|
||||
"device not accessed via ata.mod");
|
||||
|
||||
struct grub_ata_device *dev = (struct grub_ata_device *) disk->data;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* dmraid_nvidia.c - module to handle Nvidia fakeraid. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -107,7 +107,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
|
|||
|
||||
if (sb.version != NV_VERSION)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unknown version: %d.%d", sb.version);
|
||||
"unknown version: %d.%d", sb.version);
|
||||
|
||||
switch (sb.array.raid_level)
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
|
|||
|
||||
default:
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unsupported RAID level: %d", sb.array.raid_level);
|
||||
"unsupported RAID level: %d", sb.array.raid_level);
|
||||
}
|
||||
|
||||
array->number = 0;
|
||||
|
|
|
@ -440,7 +440,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
|
||||
for (d = fd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "fd%d", count);
|
||||
grub_snprintf (buf, sizeof (buf), "fd%d", count);
|
||||
grub_dprintf ("efidisk", "iterating %s\n", buf);
|
||||
if (hook (buf))
|
||||
return 1;
|
||||
|
@ -448,7 +448,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
|
||||
for (d = hd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "hd%d", count);
|
||||
grub_snprintf (buf, sizeof (buf), "hd%d", count);
|
||||
grub_dprintf ("efidisk", "iterating %s\n", buf);
|
||||
if (hook (buf))
|
||||
return 1;
|
||||
|
@ -456,7 +456,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
|
||||
for (d = cd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "cd%d", count);
|
||||
grub_snprintf (buf, sizeof (buf), "cd%d", count);
|
||||
grub_dprintf ("efidisk", "iterating %s\n", buf);
|
||||
if (hook (buf))
|
||||
return 1;
|
||||
|
@ -805,18 +805,10 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
device_name = grub_malloc (grub_strlen (parent->name) + 1
|
||||
+ grub_strlen (partition_name) + 1);
|
||||
if (! device_name)
|
||||
{
|
||||
grub_free (partition_name);
|
||||
grub_disk_close (parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_sprintf (device_name, "%s,%s", parent->name, partition_name);
|
||||
device_name = grub_xasprintf ("%s,%s", parent->name, partition_name);
|
||||
grub_free (partition_name);
|
||||
grub_disk_close (parent);
|
||||
|
||||
return device_name;
|
||||
}
|
||||
else
|
||||
|
|
136
disk/fs_file.c
136
disk/fs_file.c
|
@ -1,136 +0,0 @@
|
|||
/* fs_file.c - Access partition by a file it contains. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
static grub_device_t
|
||||
search_fs_file (const char *key, unsigned long *count)
|
||||
{
|
||||
char *filename = NULL;
|
||||
grub_device_t ret = NULL;
|
||||
*count = 0;
|
||||
|
||||
auto int iterate_device (const char *name);
|
||||
int iterate_device (const char *name)
|
||||
{
|
||||
int len;
|
||||
grub_file_t file;
|
||||
|
||||
(*count)++;
|
||||
|
||||
len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
|
||||
filename = grub_realloc (filename, len);
|
||||
if (! filename)
|
||||
return 1;
|
||||
|
||||
grub_sprintf (filename, "(%s)%s", name, key);
|
||||
file = grub_file_open (filename);
|
||||
if (file)
|
||||
{
|
||||
grub_file_close (file);
|
||||
ret = grub_device_open (name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_device_iterate (iterate_device);
|
||||
grub_free (filename);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_file_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
grub_device_t dev;
|
||||
|
||||
if (grub_strncmp (name, "FILE=", sizeof ("FILE=") - 1))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a FILE virtual volume");
|
||||
|
||||
dev = search_fs_file (name + sizeof ("FILE=") - 1, &disk->id);
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file found");
|
||||
|
||||
disk->total_sectors = dev->disk->total_sectors;
|
||||
disk->has_partitions = 0;
|
||||
if (dev->disk->partition)
|
||||
{
|
||||
disk->partition = grub_malloc (sizeof (*disk->partition));
|
||||
if (disk->partition)
|
||||
grub_memcpy (disk->partition, dev->disk->partition,
|
||||
sizeof (*disk->partition));
|
||||
}
|
||||
else
|
||||
disk->partition = NULL;
|
||||
|
||||
disk->data = dev;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_fs_file_close (grub_disk_t disk)
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
grub_device_close (parent);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_file_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
return parent->disk->dev->read (parent->disk, sector, size, buf);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_file_write (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, const char *buf)
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
return parent->disk->dev->write (parent->disk, sector, size, buf);
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_fs_file_dev = {
|
||||
.name = "fs_file",
|
||||
.id = GRUB_DISK_DEVICE_FILE_ID,
|
||||
.open = grub_fs_file_open,
|
||||
.close = grub_fs_file_close,
|
||||
.read = grub_fs_file_read,
|
||||
.write = grub_fs_file_write,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT (fs_file)
|
||||
{
|
||||
grub_disk_dev_register (&grub_fs_file_dev);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (fs_file)
|
||||
{
|
||||
grub_disk_dev_unregister (&grub_fs_file_dev);
|
||||
}
|
149
disk/fs_uuid.c
149
disk/fs_uuid.c
|
@ -1,149 +0,0 @@
|
|||
/* fs_uuid.c - Access disks by their filesystem UUID. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#include <grub/fs.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
static grub_device_t
|
||||
search_fs_uuid (const char *key, unsigned long *count)
|
||||
{
|
||||
*count = 0;
|
||||
grub_device_t ret = NULL;
|
||||
|
||||
auto int iterate_device (const char *name);
|
||||
int iterate_device (const char *name)
|
||||
{
|
||||
grub_device_t dev;
|
||||
|
||||
dev = grub_device_open (name);
|
||||
if (dev)
|
||||
{
|
||||
grub_fs_t fs;
|
||||
|
||||
fs = grub_fs_probe (dev);
|
||||
if (fs && fs->uuid)
|
||||
{
|
||||
char *uuid;
|
||||
|
||||
(fs->uuid) (dev, &uuid);
|
||||
if (grub_errno == GRUB_ERR_NONE && uuid)
|
||||
{
|
||||
(*count)++;
|
||||
|
||||
if (grub_strcasecmp (uuid, key) == 0)
|
||||
{
|
||||
ret = dev;
|
||||
grub_free (uuid);
|
||||
return 1;
|
||||
}
|
||||
grub_free (uuid);
|
||||
}
|
||||
}
|
||||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_device_iterate (iterate_device);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_uuid_open (const char *name, grub_disk_t disk)
|
||||
{
|
||||
grub_device_t dev;
|
||||
|
||||
if (grub_strncmp (name, "UUID=", sizeof ("UUID=")-1))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a UUID virtual volume");
|
||||
|
||||
dev = search_fs_uuid (name + sizeof ("UUID=") - 1, &disk->id);
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching UUID found");
|
||||
|
||||
disk->total_sectors = dev->disk->total_sectors;
|
||||
disk->has_partitions = 0;
|
||||
if (dev->disk->partition)
|
||||
{
|
||||
disk->partition = grub_malloc (sizeof (*disk->partition));
|
||||
if (disk->partition)
|
||||
grub_memcpy (disk->partition, dev->disk->partition,
|
||||
sizeof (*disk->partition));
|
||||
}
|
||||
else
|
||||
disk->partition = NULL;
|
||||
|
||||
disk->data = dev;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_fs_uuid_close (grub_disk_t disk __attribute((unused)))
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
grub_device_close (parent);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_uuid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf)
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
return parent->disk->dev->read (parent->disk, sector, size, buf);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_fs_uuid_write (grub_disk_t disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, const char *buf)
|
||||
{
|
||||
grub_device_t parent = disk->data;
|
||||
return parent->disk->dev->write (parent->disk, sector, size, buf);
|
||||
}
|
||||
|
||||
static struct grub_disk_dev grub_fs_uuid_dev =
|
||||
{
|
||||
.name = "fs_uuid",
|
||||
.id = GRUB_DISK_DEVICE_UUID_ID,
|
||||
.open = grub_fs_uuid_open,
|
||||
.close = grub_fs_uuid_close,
|
||||
.read = grub_fs_uuid_read,
|
||||
.write = grub_fs_uuid_write,
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(fs_uuid)
|
||||
{
|
||||
grub_disk_dev_register (&grub_fs_uuid_dev);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(fs_uuid)
|
||||
{
|
||||
grub_disk_dev_unregister (&grub_fs_uuid_dev);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -56,7 +56,8 @@ grub_biosdisk_call_hook (int (*hook) (const char *name), int drive)
|
|||
{
|
||||
char name[10];
|
||||
|
||||
grub_sprintf (name, (drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
|
||||
grub_snprintf (name, sizeof (name),
|
||||
(drive & 0x80) ? "hd%d" : "fd%d", drive & (~0x80));
|
||||
return hook (name);
|
||||
}
|
||||
|
||||
|
@ -222,7 +223,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
if (cmd)
|
||||
return grub_error (GRUB_ERR_WRITE_ERROR, "can\'t write to cdrom");
|
||||
|
||||
dap->blocks = (dap->blocks + 3) >> 2;
|
||||
dap->blocks = ALIGN_UP (dap->blocks, 4) >> 2;
|
||||
dap->block >>= 2;
|
||||
|
||||
for (i = 0; i < GRUB_BIOSDISK_CDROM_RETRY_COUNT; i++)
|
||||
|
@ -306,8 +307,17 @@ grub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
while (size)
|
||||
{
|
||||
grub_size_t len;
|
||||
grub_size_t cdoff = 0;
|
||||
|
||||
len = get_safe_sectors (sector, data->sectors);
|
||||
|
||||
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
|
||||
{
|
||||
cdoff = (sector & 3) << GRUB_DISK_SECTOR_BITS;
|
||||
len = ALIGN_UP (sector + len, 4) - (sector & ~3);
|
||||
sector &= ~3;
|
||||
}
|
||||
|
||||
if (len > size)
|
||||
len = size;
|
||||
|
||||
|
@ -315,7 +325,7 @@ grub_biosdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
GRUB_MEMORY_MACHINE_SCRATCH_SEG))
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (buf, (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR,
|
||||
grub_memcpy (buf, (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + cdoff),
|
||||
len << GRUB_DISK_SECTOR_BITS);
|
||||
buf += len << GRUB_DISK_SECTOR_BITS;
|
||||
sector += len;
|
||||
|
@ -331,6 +341,9 @@ grub_biosdisk_write (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
{
|
||||
struct grub_biosdisk_data *data = disk->data;
|
||||
|
||||
if (data->flags & GRUB_BIOSDISK_FLAG_CDROM)
|
||||
return grub_error (GRUB_ERR_IO, "can't write to CDROM");
|
||||
|
||||
while (size)
|
||||
{
|
||||
grub_size_t len;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* nand.c - NAND flash disk access. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -67,7 +67,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|||
} args;
|
||||
|
||||
if (! grub_strstr (name, "nand"))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Not a nand device");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a NAND device");
|
||||
|
||||
data = grub_malloc (sizeof (*data));
|
||||
if (! data)
|
||||
|
@ -76,7 +76,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|||
grub_ieee1275_open (name, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get block size");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't get disk size");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
args.result = 1;
|
||||
|
||||
if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Read error");
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "read error");
|
||||
|
||||
ofs = 0;
|
||||
size -= len;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* ofdisk.c - Open Firmware disk access. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2004,2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2004,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -118,7 +118,7 @@ grub_ofdisk_iterate (int (*hook) (const char *name))
|
|||
static char *
|
||||
compute_dev_path (const char *name)
|
||||
{
|
||||
char *devpath = grub_malloc (grub_strlen (name) + 2);
|
||||
char *devpath = grub_malloc (grub_strlen (name) + 3);
|
||||
char *p, c;
|
||||
|
||||
if (!devpath)
|
||||
|
@ -175,7 +175,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
grub_ieee1275_open (op->devpath, &dev_ihandle);
|
||||
if (! dev_ihandle)
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -184,20 +184,20 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
if (grub_ieee1275_finddevice (op->devpath, &dev))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read device properties");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (grub_ieee1275_get_property (dev, "device_type", prop, sizeof (prop),
|
||||
&actual))
|
||||
{
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read the device type");
|
||||
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't read the device type");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (grub_strcmp (prop, "block"))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "Not a block device");
|
||||
grub_error (GRUB_ERR_BAD_DEVICE, "not a block device");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -244,12 +244,12 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
(int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
|
||||
if (status < 0)
|
||||
return grub_error (GRUB_ERR_READ_ERROR,
|
||||
"Seek error, can't seek block %llu",
|
||||
"seek error, can't seek block %llu",
|
||||
(long long) sector);
|
||||
grub_ieee1275_read ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
|
||||
buf, size * 512UL, &actual);
|
||||
if (actual != actual)
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
|
||||
if (actual != (grub_ssize_t) (size * 512UL))
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "read error on block: %llu",
|
||||
(long long) sector);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
struct grub_loopback
|
||||
{
|
||||
|
@ -36,8 +37,8 @@ static struct grub_loopback *loopback_list;
|
|||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
{"delete", 'd', 0, "delete the loopback device entry", 0, 0},
|
||||
{"partitions", 'p', 0, "simulate a hard drive with partitions", 0, 0},
|
||||
{"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}
|
||||
};
|
||||
|
||||
|
@ -56,7 +57,7 @@ delete_loopback (const char *name)
|
|||
break;
|
||||
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "Device not found");
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "device not found");
|
||||
|
||||
/* Remove the device from the list. */
|
||||
*prev = dev->next;
|
||||
|
@ -167,7 +168,7 @@ grub_loopback_open (const char *name, grub_disk_t disk)
|
|||
break;
|
||||
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
|
||||
|
||||
file = grub_file_open (dev->filename);
|
||||
if (! file)
|
||||
|
@ -245,8 +246,8 @@ GRUB_MOD_INIT(loopback)
|
|||
{
|
||||
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
|
||||
GRUB_COMMAND_FLAG_BOTH,
|
||||
"loopback [-d|-p] DEVICENAME FILE",
|
||||
"Make a device of a file.", options);
|
||||
N_("[-d|-p] DEVICENAME FILE."),
|
||||
N_("Make a device of a file."), options);
|
||||
grub_disk_dev_register (&grub_loopback_dev);
|
||||
}
|
||||
|
||||
|
|
10
disk/lvm.c
10
disk/lvm.c
|
@ -1,7 +1,7 @@
|
|||
/* lvm.c - module to read Logical Volumes. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -95,7 +95,7 @@ grub_lvm_open (const char *name, grub_disk_t disk)
|
|||
}
|
||||
|
||||
if (! lv)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown LVM device %s", name);
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown LVM device %s", name);
|
||||
|
||||
disk->has_partitions = 0;
|
||||
disk->id = lv->number;
|
||||
|
@ -188,7 +188,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
size << GRUB_DISK_SECTOR_BITS, buf);
|
||||
else
|
||||
err = grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"Physical volume %s not found", pv->name);
|
||||
"physical volume %s not found", pv->name);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ grub_lvm_scan_device (const char *name)
|
|||
if (dlocn->offset)
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"We don't support multiple LVM data areas");
|
||||
"we don't support multiple LVM data areas");
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ grub_lvm_scan_device (const char *name)
|
|||
|| (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION))
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unknown LVM metadata header");
|
||||
"unknown LVM metadata header");
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
|
|||
/* FIXME: Also support version 1.0. */
|
||||
if (sb.major_version != 0 || sb.minor_version != 90)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unsupported RAID version: %d.%d",
|
||||
"unsupported RAID version: %d.%d",
|
||||
sb.major_version, sb.minor_version);
|
||||
|
||||
/* FIXME: Check the checksum. */
|
||||
|
@ -193,7 +193,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array)
|
|||
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
|
||||
sb.level != 5 && sb.level != 6 && sb.level != 10)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unsupported RAID level: %d", sb.level);
|
||||
"unsupported RAID level: %d", sb.level);
|
||||
|
||||
array->number = sb.md_minor;
|
||||
array->level = sb.level;
|
||||
|
|
10
disk/raid.c
10
disk/raid.c
|
@ -1,7 +1,7 @@
|
|||
/* raid.c - module to read RAID arrays. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -123,7 +123,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
|
|||
}
|
||||
|
||||
if (!array)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown RAID device %s",
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown RAID device %s",
|
||||
name);
|
||||
|
||||
disk->has_partitions = 1;
|
||||
|
@ -265,7 +265,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
}
|
||||
else
|
||||
err = grub_error (GRUB_ERR_READ_ERROR,
|
||||
"disk missing.");
|
||||
"disk missing");
|
||||
|
||||
k++;
|
||||
if (k == array->total_devs)
|
||||
|
@ -556,7 +556,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
|||
}
|
||||
}
|
||||
|
||||
array->name = grub_malloc (13);
|
||||
array->name = grub_xasprintf ("md%d", array->number);
|
||||
if (! array->name)
|
||||
{
|
||||
grub_free (array->uuid);
|
||||
|
@ -565,8 +565,6 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_sprintf (array->name, "md%d", array->number);
|
||||
|
||||
grub_dprintf ("raid", "Found array %s (%s)\n", array->name,
|
||||
scanner_name);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* raid6_recover.c - module to recover from faulty RAID6 arrays. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -157,7 +157,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
|
|||
|
||||
if (! array->device[q])
|
||||
{
|
||||
grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore");
|
||||
grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore");
|
||||
goto quit;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
|
|||
|
||||
if ((! array->device[p]) || (! array->device[q]))
|
||||
{
|
||||
grub_error (GRUB_ERR_READ_ERROR, "Not enough disk to restore");
|
||||
grub_error (GRUB_ERR_READ_ERROR, "not enough disk to restore");
|
||||
goto quit;
|
||||
}
|
||||
|
||||
|
|
13
disk/scsi.c
13
disk/scsi.c
|
@ -1,7 +1,7 @@
|
|||
/* scsi.c - scsi support. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -197,7 +197,6 @@ grub_scsi_iterate (int (*hook) (const char *name))
|
|||
|
||||
int scsi_iterate (const char *name, int luns)
|
||||
{
|
||||
char sname[40];
|
||||
int i;
|
||||
|
||||
/* In case of a single LUN, just return `usbX'. */
|
||||
|
@ -208,9 +207,13 @@ grub_scsi_iterate (int (*hook) (const char *name))
|
|||
distinguish it. */
|
||||
for (i = 0; i < luns; i++)
|
||||
{
|
||||
grub_sprintf (sname, "%s%c", name, 'a' + i);
|
||||
char *sname;
|
||||
sname = grub_xasprintf ("%s%c", name, 'a' + i);
|
||||
if (!sname)
|
||||
return 1;
|
||||
if (hook (sname))
|
||||
return 1;
|
||||
grub_free (sname);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -337,14 +340,14 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS;
|
||||
if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0))
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unsupported SCSI block size");
|
||||
"unsupported SCSI block size");
|
||||
|
||||
grub_uint32_t sector_mod = 0;
|
||||
sector = grub_divmod64 (sector, spb, §or_mod);
|
||||
|
||||
if (! (sector_mod == 0 && size % spb == 0))
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"Unaligned SCSI read not supported");
|
||||
"unaligned SCSI read not supported");
|
||||
|
||||
size /= spb;
|
||||
}
|
||||
|
|
10
disk/usbms.c
10
disk/usbms.c
|
@ -200,11 +200,15 @@ grub_usbms_iterate (int (*hook) (const char *name, int luns))
|
|||
|
||||
for (p = grub_usbms_dev_list; p; p = p->next)
|
||||
{
|
||||
char devname[20];
|
||||
grub_sprintf (devname, "usb%d", cnt);
|
||||
char *devname;
|
||||
devname = grub_xasprintf ("usb%d", cnt);
|
||||
|
||||
if (hook (devname, p->luns))
|
||||
return 1;
|
||||
{
|
||||
grub_free (devname);
|
||||
return 1;
|
||||
}
|
||||
grub_free (devname);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue