remove all trailing whitespace
This commit is contained in:
parent
d2d4966571
commit
b39f9d20a9
222 changed files with 3286 additions and 3286 deletions
12
disk/ata.c
12
disk/ata.c
|
@ -357,7 +357,7 @@ grub_ata_device_initialize (int port, int device, int addr, int addr2)
|
|||
/* Try to detect if the port is in use by writing to it,
|
||||
waiting for a while and reading it again. If the value
|
||||
was preserved, there is a device connected. */
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);
|
||||
grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);
|
||||
grub_ata_wait ();
|
||||
grub_uint8_t sec = grub_ata_regget (dev, GRUB_ATA_REG_SECTORS);
|
||||
grub_dprintf ("ata", "sectors=0x%x\n", sec);
|
||||
|
@ -435,7 +435,7 @@ grub_ata_pciinit (int bus, int device, int func,
|
|||
bar2 = grub_pci_read (addr);
|
||||
|
||||
/* Check if the BARs describe an IO region. */
|
||||
if ((bar1 & 1) && (bar2 & 1))
|
||||
if ((bar1 & 1) && (bar2 & 1))
|
||||
{
|
||||
rega = bar1 & ~3;
|
||||
regb = bar2 & ~3;
|
||||
|
@ -682,7 +682,7 @@ grub_ata_open (const char *name, grub_disk_t disk)
|
|||
disk->total_sectors = dev->size;
|
||||
|
||||
disk->id = (unsigned long) dev;
|
||||
|
||||
|
||||
disk->has_partitions = 1;
|
||||
disk->data = dev;
|
||||
|
||||
|
@ -692,7 +692,7 @@ grub_ata_open (const char *name, grub_disk_t disk)
|
|||
static void
|
||||
grub_ata_close (grub_disk_t disk __attribute__((unused)))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
@ -841,7 +841,7 @@ static struct grub_scsi_dev grub_atapi_dev =
|
|||
.close = grub_atapi_close,
|
||||
.read = grub_atapi_read,
|
||||
.write = grub_atapi_write
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -854,7 +854,7 @@ GRUB_MOD_INIT(ata)
|
|||
grub_disk_firmware_fini ();
|
||||
grub_disk_firmware_fini = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* ATA initialization. */
|
||||
grub_ata_initialize ();
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ duplicate_device_path (const grub_efi_device_path_t *dp)
|
|||
{
|
||||
grub_efi_device_path_t *p;
|
||||
grub_size_t total_size = 0;
|
||||
|
||||
|
||||
for (p = (grub_efi_device_path_t *) dp;
|
||||
;
|
||||
p = GRUB_EFI_NEXT_DEVICE_PATH (p))
|
||||
|
@ -94,14 +94,14 @@ compare_device_paths (const grub_efi_device_path_t *dp1,
|
|||
if (! dp1 || ! dp2)
|
||||
/* Return non-zero. */
|
||||
return 1;
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
grub_efi_uint8_t type1, type2;
|
||||
grub_efi_uint8_t subtype1, subtype2;
|
||||
grub_efi_uint16_t len1, len2;
|
||||
int ret;
|
||||
|
||||
|
||||
type1 = GRUB_EFI_DEVICE_PATH_TYPE (dp1);
|
||||
type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
|
||||
|
||||
|
@ -110,7 +110,7 @@ compare_device_paths (const grub_efi_device_path_t *dp1,
|
|||
|
||||
subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp1);
|
||||
subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
|
||||
|
||||
|
||||
if (subtype1 != subtype2)
|
||||
return (int) subtype1 - (int) subtype2;
|
||||
|
||||
|
@ -141,7 +141,7 @@ make_devices (void)
|
|||
grub_efi_handle_t *handles;
|
||||
grub_efi_handle_t *handle;
|
||||
struct grub_efidisk_data *devices = 0;
|
||||
|
||||
|
||||
/* Find handles which support the disk io interface. */
|
||||
handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &disk_io_guid,
|
||||
0, &num_handles);
|
||||
|
@ -156,7 +156,7 @@ make_devices (void)
|
|||
struct grub_efidisk_data *d;
|
||||
grub_efi_block_io_t *bio;
|
||||
grub_efi_disk_io_t *dio;
|
||||
|
||||
|
||||
dp = grub_efi_get_device_path (*handle);
|
||||
if (! dp)
|
||||
continue;
|
||||
|
@ -165,7 +165,7 @@ make_devices (void)
|
|||
if (! ldp)
|
||||
/* This is empty. Why? */
|
||||
continue;
|
||||
|
||||
|
||||
bio = grub_efi_open_protocol (*handle, &block_io_guid,
|
||||
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
dio = grub_efi_open_protocol (*handle, &disk_io_guid,
|
||||
|
@ -173,7 +173,7 @@ make_devices (void)
|
|||
if (! bio || ! dio)
|
||||
/* This should not happen... Why? */
|
||||
continue;
|
||||
|
||||
|
||||
d = grub_malloc (sizeof (*d));
|
||||
if (! d)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ make_devices (void)
|
|||
}
|
||||
|
||||
grub_free (handles);
|
||||
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ find_parent_device (struct grub_efidisk_data *devices,
|
|||
{
|
||||
grub_efi_device_path_t *dp, *ldp;
|
||||
struct grub_efidisk_data *parent;
|
||||
|
||||
|
||||
dp = duplicate_device_path (d->device_path);
|
||||
if (! dp)
|
||||
return 0;
|
||||
|
@ -219,13 +219,13 @@ find_parent_device (struct grub_efidisk_data *devices,
|
|||
/* Ignore itself. */
|
||||
if (parent == d)
|
||||
continue;
|
||||
|
||||
|
||||
if (compare_device_paths (parent->device_path, dp) == 0)
|
||||
{
|
||||
/* Found. */
|
||||
if (! parent->last_device_path)
|
||||
parent = 0;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ iterate_child_devices (struct grub_efidisk_data *devices,
|
|||
int (*hook) (struct grub_efidisk_data *child))
|
||||
{
|
||||
struct grub_efidisk_data *p;
|
||||
|
||||
|
||||
for (p = devices; p; p = p->next)
|
||||
{
|
||||
grub_efi_device_path_t *dp, *ldp;
|
||||
|
@ -248,13 +248,13 @@ iterate_child_devices (struct grub_efidisk_data *devices,
|
|||
dp = duplicate_device_path (p->device_path);
|
||||
if (! dp)
|
||||
return 0;
|
||||
|
||||
|
||||
ldp = find_last_device_path (dp);
|
||||
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
||||
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
||||
ldp->length[0] = sizeof (*ldp);
|
||||
ldp->length[1] = 0;
|
||||
|
||||
|
||||
if (compare_device_paths (dp, d->device_path) == 0)
|
||||
if (hook (p))
|
||||
{
|
||||
|
@ -304,7 +304,7 @@ static void
|
|||
name_devices (struct grub_efidisk_data *devices)
|
||||
{
|
||||
struct grub_efidisk_data *d;
|
||||
|
||||
|
||||
/* First, identify devices by media device paths. */
|
||||
for (d = devices; d; d = d->next)
|
||||
{
|
||||
|
@ -313,11 +313,11 @@ name_devices (struct grub_efidisk_data *devices)
|
|||
dp = d->last_device_path;
|
||||
if (! dp)
|
||||
continue;
|
||||
|
||||
|
||||
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
|
||||
{
|
||||
int is_hard_drive = 0;
|
||||
|
||||
|
||||
switch (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp))
|
||||
{
|
||||
case GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE:
|
||||
|
@ -346,7 +346,7 @@ name_devices (struct grub_efidisk_data *devices)
|
|||
#endif
|
||||
add_device (&cd_devices, parent);
|
||||
}
|
||||
|
||||
|
||||
/* Mark the parent as used. */
|
||||
parent->last_device_path = 0;
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ name_devices (struct grub_efidisk_data *devices)
|
|||
{
|
||||
grub_efi_device_path_t *dp;
|
||||
grub_efi_block_io_media_t *m;
|
||||
|
||||
|
||||
dp = d->last_device_path;
|
||||
if (! dp)
|
||||
continue;
|
||||
|
@ -409,7 +409,7 @@ static void
|
|||
free_devices (struct grub_efidisk_data *devices)
|
||||
{
|
||||
struct grub_efidisk_data *p, *q;
|
||||
|
||||
|
||||
for (p = devices; p; p = q)
|
||||
{
|
||||
q = p->next;
|
||||
|
@ -422,11 +422,11 @@ static void
|
|||
enumerate_disks (void)
|
||||
{
|
||||
struct grub_efidisk_data *devices;
|
||||
|
||||
|
||||
devices = make_devices ();
|
||||
if (! devices)
|
||||
return;
|
||||
|
||||
|
||||
name_devices (devices);
|
||||
free_devices (devices);
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
struct grub_efidisk_data *d;
|
||||
char buf[16];
|
||||
int count;
|
||||
|
||||
|
||||
for (d = fd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "fd%d", count);
|
||||
|
@ -445,7 +445,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
if (hook (buf))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
for (d = hd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "hd%d", count);
|
||||
|
@ -453,7 +453,7 @@ grub_efidisk_iterate (int (*hook) (const char *name))
|
|||
if (hook (buf))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
for (d = cd_devices, count = 0; d; d = d->next, count++)
|
||||
{
|
||||
grub_sprintf (buf, "cd%d", count);
|
||||
|
@ -506,7 +506,7 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
|
|||
grub_efi_block_io_media_t *m;
|
||||
|
||||
grub_dprintf ("efidisk", "opening %s\n", name);
|
||||
|
||||
|
||||
num = get_drive_number (name);
|
||||
if (num < 0)
|
||||
return grub_errno;
|
||||
|
@ -565,7 +565,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
|
|||
grub_efi_disk_io_t *dio;
|
||||
grub_efi_block_io_t *bio;
|
||||
grub_efi_status_t status;
|
||||
|
||||
|
||||
d = disk->data;
|
||||
dio = d->disk_io;
|
||||
bio = d->block_io;
|
||||
|
@ -573,14 +573,14 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
|
|||
grub_dprintf ("efidisk",
|
||||
"reading 0x%lx sectors at the sector 0x%llx from %s\n",
|
||||
(unsigned long) size, (unsigned long long) sector, disk->name);
|
||||
|
||||
|
||||
status = efi_call_5 (dio->read, dio, bio->media->media_id,
|
||||
(grub_efi_uint64_t) sector << GRUB_DISK_SECTOR_BITS,
|
||||
(grub_efi_uintn_t) size << GRUB_DISK_SECTOR_BITS,
|
||||
buf);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "efidisk read error");
|
||||
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -593,22 +593,22 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
|
|||
grub_efi_disk_io_t *dio;
|
||||
grub_efi_block_io_t *bio;
|
||||
grub_efi_status_t status;
|
||||
|
||||
|
||||
d = disk->data;
|
||||
dio = d->disk_io;
|
||||
bio = d->block_io;
|
||||
|
||||
|
||||
grub_dprintf ("efidisk",
|
||||
"writing 0x%lx sectors at the sector 0x%llx to %s\n",
|
||||
(unsigned long) size, (unsigned long long) sector, disk->name);
|
||||
|
||||
|
||||
status = efi_call_5 (dio->write, dio, bio->media->media_id,
|
||||
(grub_efi_uint64_t) sector << GRUB_DISK_SECTOR_BITS,
|
||||
(grub_efi_uintn_t) size << GRUB_DISK_SECTOR_BITS,
|
||||
(void *) buf);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return grub_error (GRUB_ERR_WRITE_ERROR, "efidisk write error");
|
||||
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -646,13 +646,13 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|||
{
|
||||
struct grub_efidisk_data *d;
|
||||
char type;
|
||||
|
||||
|
||||
if (disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID)
|
||||
return 0;
|
||||
|
||||
|
||||
d = disk->data;
|
||||
type = disk->name[0];
|
||||
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 'f':
|
||||
|
@ -679,7 +679,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|||
grub_efi_hard_drive_device_path_t hd;
|
||||
|
||||
grub_memcpy (&hd, c->last_device_path, sizeof (hd));
|
||||
|
||||
|
||||
if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
|
||||
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
|
||||
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
|
||||
|
@ -692,14 +692,14 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|||
handle = c->handle;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
devices = make_devices ();
|
||||
iterate_child_devices (devices, d, find_partition);
|
||||
free_devices (devices);
|
||||
|
||||
|
||||
if (handle != 0)
|
||||
return handle;
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
if (disk->dev->id == GRUB_DISK_DEVICE_EFIDISK_ID)
|
||||
{
|
||||
struct grub_efidisk_data *d;
|
||||
|
||||
|
||||
d = disk->data;
|
||||
if (compare_device_paths (d->device_path, dup_dp) == 0)
|
||||
{
|
||||
|
@ -798,7 +798,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
/* Find a partition which matches the hard drive device path. */
|
||||
grub_memcpy (&hd, ldp, sizeof (hd));
|
||||
grub_partition_iterate (parent, find_partition);
|
||||
|
||||
|
||||
if (! partition_name)
|
||||
{
|
||||
grub_disk_close (parent);
|
||||
|
@ -824,11 +824,11 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
/* This should be an entire disk. */
|
||||
auto int find_disk (const char *name);
|
||||
char *device_name = 0;
|
||||
|
||||
|
||||
int find_disk (const char *name)
|
||||
{
|
||||
grub_disk_t disk;
|
||||
|
||||
|
||||
disk = grub_disk_open (name);
|
||||
if (! disk)
|
||||
return 1;
|
||||
|
@ -836,7 +836,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
if (disk->id == GRUB_DISK_DEVICE_EFIDISK_ID)
|
||||
{
|
||||
struct grub_efidisk_data *d;
|
||||
|
||||
|
||||
d = disk->data;
|
||||
if (compare_device_paths (d->device_path, dp) == 0)
|
||||
{
|
||||
|
@ -848,9 +848,9 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
|
||||
grub_disk_close (disk);
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
grub_efidisk_iterate (find_disk);
|
||||
return device_name;
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ search_fs_uuid (const char *key, unsigned long *count)
|
|||
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)
|
||||
{
|
||||
|
@ -62,16 +62,16 @@ search_fs_uuid (const char *key, unsigned long *count)
|
|||
grub_free (uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_device_iterate (iterate_device);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ grub_host_open (const char *name, grub_disk_t disk)
|
|||
|
||||
disk->total_sectors = 0;
|
||||
disk->id = (unsigned long) "host";
|
||||
|
||||
|
||||
disk->has_partitions = 0;
|
||||
disk->data = 0;
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ grub_biosdisk_get_drive (const char *name)
|
|||
|
||||
if ((name[0] != 'f' && name[0] != 'h') || name[1] != 'd')
|
||||
goto fail;
|
||||
|
||||
|
||||
drive = grub_strtoul (name + 2, 0, 10);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
|
||||
if (name[0] == 'h')
|
||||
drive += 0x80;
|
||||
|
||||
|
||||
return (int) drive ;
|
||||
|
||||
fail:
|
||||
|
@ -75,7 +75,7 @@ grub_biosdisk_iterate (int (*hook) (const char *name))
|
|||
grub_dprintf ("disk", "Read error when probing drive 0x%2x\n", drive);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (grub_biosdisk_call_hook (hook, drive))
|
||||
return 1;
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
disk->has_partitions = ((drive & 0x80) && (drive != cd_drive));
|
||||
disk->id = drive;
|
||||
|
||||
|
||||
data = (struct grub_biosdisk_data *) grub_malloc (sizeof (*data));
|
||||
if (! data)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
data->drive = drive;
|
||||
data->flags = 0;
|
||||
|
||||
|
@ -126,7 +126,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
{
|
||||
/* HDD */
|
||||
int version;
|
||||
|
||||
|
||||
version = grub_biosdisk_check_int13_extensions (drive);
|
||||
if (version)
|
||||
{
|
||||
|
@ -162,9 +162,9 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
{
|
||||
data->sectors = 63;
|
||||
data->heads = 255;
|
||||
data->cylinders
|
||||
= grub_divmod64 (total_sectors
|
||||
+ data->heads * data->sectors - 1,
|
||||
data->cylinders
|
||||
= grub_divmod64 (total_sectors
|
||||
+ data->heads * data->sectors - 1,
|
||||
data->heads * data->sectors, 0);
|
||||
}
|
||||
else
|
||||
|
@ -180,7 +180,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
|||
|
||||
disk->total_sectors = total_sectors;
|
||||
disk->data = data;
|
||||
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -202,11 +202,11 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
unsigned segment)
|
||||
{
|
||||
struct grub_biosdisk_data *data = disk->data;
|
||||
|
||||
|
||||
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
|
||||
{
|
||||
struct grub_biosdisk_dap *dap;
|
||||
|
||||
|
||||
dap = (struct grub_biosdisk_dap *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR
|
||||
+ (data->sectors
|
||||
<< GRUB_DISK_SECTOR_BITS));
|
||||
|
@ -246,7 +246,7 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
|
|||
{
|
||||
unsigned coff, hoff, soff;
|
||||
unsigned head;
|
||||
|
||||
|
||||
/* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
|
||||
the traditional CHS access. */
|
||||
if (sector >
|
||||
|
|
|
@ -251,7 +251,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
if (actual != actual)
|
||||
return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
|
||||
(long long) sector);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct grub_loopback
|
|||
struct grub_loopback *next;
|
||||
};
|
||||
|
||||
static struct grub_loopback *loopback_list;
|
||||
static struct grub_loopback *loopback_list;
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -54,17 +54,17 @@ delete_loopback (const char *name)
|
|||
prev = &dev->next, dev = dev->next)
|
||||
if (grub_strcmp (dev->devname, name) == 0)
|
||||
break;
|
||||
|
||||
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "Device not found");
|
||||
|
||||
|
||||
/* Remove the device from the list. */
|
||||
*prev = dev->next;
|
||||
|
||||
grub_free (dev->devname);
|
||||
grub_free (dev->filename);
|
||||
grub_free (dev);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -75,56 +75,56 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
|
|||
struct grub_arg_list *state = state = cmd->state;
|
||||
grub_file_t file;
|
||||
struct grub_loopback *newdev;
|
||||
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
|
||||
|
||||
|
||||
/* Check if `-d' was used. */
|
||||
if (state[0].set)
|
||||
return delete_loopback (args[0]);
|
||||
|
||||
|
||||
if (argc < 2)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
file = grub_file_open (args[1]);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
/* Close the file, the only reason for opening it is validation. */
|
||||
grub_file_close (file);
|
||||
|
||||
|
||||
/* First try to replace the old device. */
|
||||
for (newdev = loopback_list; newdev; newdev = newdev->next)
|
||||
if (grub_strcmp (newdev->devname, args[0]) == 0)
|
||||
break;
|
||||
|
||||
|
||||
if (newdev)
|
||||
{
|
||||
char *newname = grub_strdup (args[1]);
|
||||
if (! newname)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
grub_free (newdev->filename);
|
||||
newdev->filename = newname;
|
||||
|
||||
|
||||
/* Set has_partitions when `--partitions' was used. */
|
||||
newdev->has_partitions = state[1].set;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Unable to replace it, make a new entry. */
|
||||
newdev = grub_malloc (sizeof (struct grub_loopback));
|
||||
if (! newdev)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
newdev->devname = grub_strdup (args[0]);
|
||||
if (! newdev->devname)
|
||||
{
|
||||
grub_free (newdev);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
newdev->filename = grub_strdup (args[1]);
|
||||
if (! newdev->filename)
|
||||
{
|
||||
|
@ -132,14 +132,14 @@ grub_cmd_loopback (grub_extcmd_t cmd, int argc, char **args)
|
|||
grub_free (newdev);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -161,26 +161,26 @@ grub_loopback_open (const char *name, grub_disk_t disk)
|
|||
{
|
||||
grub_file_t file;
|
||||
struct grub_loopback *dev;
|
||||
|
||||
|
||||
for (dev = loopback_list; dev; dev = dev->next)
|
||||
if (grub_strcmp (dev->devname, name) == 0)
|
||||
break;
|
||||
|
||||
|
||||
if (! dev)
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't open device");
|
||||
|
||||
file = grub_file_open (dev->filename);
|
||||
if (! file)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
/* Use the filesize for the disk size, round up to a complete sector. */
|
||||
disk->total_sectors = ((file->size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
/ GRUB_DISK_SECTOR_SIZE);
|
||||
disk->id = (unsigned long) dev;
|
||||
|
||||
|
||||
disk->has_partitions = dev->has_partitions;
|
||||
disk->data = file;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void
|
|||
grub_loopback_close (grub_disk_t disk)
|
||||
{
|
||||
grub_file_t file = (grub_file_t) disk->data;
|
||||
|
||||
|
||||
grub_file_close (file);
|
||||
}
|
||||
|
||||
|
@ -198,13 +198,13 @@ grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
{
|
||||
grub_file_t file = (grub_file_t) disk->data;
|
||||
grub_off_t pos;
|
||||
|
||||
|
||||
grub_file_seek (file, sector << GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
|
||||
grub_file_read (file, buf, size << GRUB_DISK_SECTOR_BITS);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
|
||||
/* In case there is more data read than there is available, in case
|
||||
of files that are not a multiple of GRUB_DISK_SECTOR_SIZE, fill
|
||||
the rest with zeros. */
|
||||
|
@ -214,7 +214,7 @@ grub_loopback_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
grub_size_t amount = pos - file->size;
|
||||
grub_memset (buf + (size << GRUB_DISK_SECTOR_BITS) - amount, 0, amount);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
86
disk/lvm.c
86
disk/lvm.c
|
@ -101,7 +101,7 @@ grub_lvm_open (const char *name, grub_disk_t disk)
|
|||
disk->id = lv->number;
|
||||
disk->data = lv;
|
||||
disk->total_sectors = lv->size;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
|
||||
stripe += stripenr;
|
||||
pv = stripe->pv;
|
||||
|
||||
|
||||
seg_offset = ((grub_uint64_t) stripe->start
|
||||
* (grub_uint64_t) vg->extent_size) + pv->start;
|
||||
|
||||
|
@ -189,7 +189,7 @@ grub_lvm_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
else
|
||||
err = grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
||||
"Physical volume %s not found", pv->name);
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ grub_lvm_scan_device (const char *name)
|
|||
unsigned int i, j, vgname_len;
|
||||
struct grub_lvm_vg *vg;
|
||||
struct grub_lvm_pv *pv;
|
||||
|
||||
|
||||
disk = grub_disk_open (name);
|
||||
if (!disk)
|
||||
return 0;
|
||||
|
@ -231,7 +231,7 @@ grub_lvm_scan_device (const char *name)
|
|||
err = grub_disk_read (disk, i, 0, sizeof(buf), buf);
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
|
||||
if ((! grub_strncmp ((char *)lh->id, GRUB_LVM_LABEL_ID,
|
||||
sizeof (lh->id)))
|
||||
&& (! grub_strncmp ((char *)lh->type, GRUB_LVM_LVM2_LABEL,
|
||||
|
@ -242,7 +242,7 @@ grub_lvm_scan_device (const char *name)
|
|||
/* Return if we didn't find a label. */
|
||||
if (i == GRUB_LVM_LABEL_SCAN_SECTORS)
|
||||
goto fail;
|
||||
|
||||
|
||||
pvh = (struct grub_lvm_pv_header *) (buf + grub_le_to_cpu32(lh->offset_xl));
|
||||
|
||||
for (i = 0, j = 0; i < GRUB_LVM_ID_LEN; i++)
|
||||
|
@ -264,7 +264,7 @@ grub_lvm_scan_device (const char *name)
|
|||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"We don't support multiple LVM data areas");
|
||||
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -272,12 +272,12 @@ grub_lvm_scan_device (const char *name)
|
|||
mda_offset = grub_le_to_cpu64 (dlocn->offset);
|
||||
mda_size = grub_le_to_cpu64 (dlocn->size);
|
||||
dlocn++;
|
||||
|
||||
|
||||
if (dlocn->offset)
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"We don't support multiple LVM metadata areas");
|
||||
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -361,39 +361,39 @@ grub_lvm_scan_device (const char *name)
|
|||
if (p)
|
||||
{
|
||||
p += sizeof ("physical_volumes {") - 1;
|
||||
|
||||
|
||||
/* Add all the pvs to the volume group. */
|
||||
while (1)
|
||||
{
|
||||
int s;
|
||||
while (grub_isspace (*p))
|
||||
p++;
|
||||
|
||||
|
||||
if (*p == '}')
|
||||
break;
|
||||
|
||||
|
||||
pv = grub_malloc (sizeof (*pv));
|
||||
q = p;
|
||||
while (*q != ' ')
|
||||
q++;
|
||||
|
||||
|
||||
s = q - p;
|
||||
pv->name = grub_malloc (s + 1);
|
||||
grub_memcpy (pv->name, p, s);
|
||||
pv->name[s] = '\0';
|
||||
|
||||
|
||||
p = grub_strstr (p, "id = \"");
|
||||
if (p == NULL)
|
||||
goto pvs_fail;
|
||||
p += sizeof("id = \"") - 1;
|
||||
|
||||
|
||||
grub_memcpy (pv->id, p, GRUB_LVM_ID_STRLEN);
|
||||
pv->id[GRUB_LVM_ID_STRLEN] = '\0';
|
||||
|
||||
|
||||
pv->start = grub_lvm_getvalue (&p, "pe_start = ");
|
||||
if (p == NULL)
|
||||
goto pvs_fail;
|
||||
|
||||
|
||||
p = grub_strchr (p, '}');
|
||||
if (p == NULL)
|
||||
goto pvs_fail;
|
||||
|
@ -402,7 +402,7 @@ grub_lvm_scan_device (const char *name)
|
|||
pv->disk = NULL;
|
||||
pv->next = vg->pvs;
|
||||
vg->pvs = pv;
|
||||
|
||||
|
||||
continue;
|
||||
pvs_fail:
|
||||
grub_free (pv->name);
|
||||
|
@ -415,49 +415,49 @@ grub_lvm_scan_device (const char *name)
|
|||
if (p)
|
||||
{
|
||||
p += 18;
|
||||
|
||||
|
||||
/* And add all the lvs to the volume group. */
|
||||
while (1)
|
||||
{
|
||||
int s;
|
||||
struct grub_lvm_lv *lv;
|
||||
struct grub_lvm_segment *seg;
|
||||
|
||||
|
||||
while (grub_isspace (*p))
|
||||
p++;
|
||||
|
||||
|
||||
if (*p == '}')
|
||||
break;
|
||||
|
||||
|
||||
lv = grub_malloc (sizeof (*lv));
|
||||
|
||||
|
||||
q = p;
|
||||
while (*q != ' ')
|
||||
q++;
|
||||
|
||||
|
||||
s = q - p;
|
||||
lv->name = grub_malloc (vgname_len + 1 + s + 1);
|
||||
grub_memcpy (lv->name, vgname, vgname_len);
|
||||
lv->name[vgname_len] = '-';
|
||||
grub_memcpy (lv->name + vgname_len + 1, p, s);
|
||||
lv->name[vgname_len + 1 + s] = '\0';
|
||||
|
||||
|
||||
lv->size = 0;
|
||||
|
||||
|
||||
lv->segment_count = grub_lvm_getvalue (&p, "segment_count = ");
|
||||
if (p == NULL)
|
||||
goto lvs_fail;
|
||||
lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count);
|
||||
seg = lv->segments;
|
||||
|
||||
|
||||
for (i = 0; i < lv->segment_count; i++)
|
||||
{
|
||||
struct grub_lvm_stripe *stripe;
|
||||
|
||||
|
||||
p = grub_strstr (p, "segment");
|
||||
if (p == NULL)
|
||||
goto lvs_segment_fail;
|
||||
|
||||
|
||||
seg->start_extent = grub_lvm_getvalue (&p, "start_extent = ");
|
||||
if (p == NULL)
|
||||
goto lvs_segment_fail;
|
||||
|
@ -467,25 +467,25 @@ grub_lvm_scan_device (const char *name)
|
|||
seg->stripe_count = grub_lvm_getvalue (&p, "stripe_count = ");
|
||||
if (p == NULL)
|
||||
goto lvs_segment_fail;
|
||||
|
||||
|
||||
lv->size += seg->extent_count * vg->extent_size;
|
||||
|
||||
|
||||
if (seg->stripe_count != 1)
|
||||
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
|
||||
|
||||
|
||||
seg->stripes = grub_malloc (sizeof (*stripe)
|
||||
* seg->stripe_count);
|
||||
stripe = seg->stripes;
|
||||
|
||||
|
||||
p = grub_strstr (p, "stripes = [");
|
||||
if (p == NULL)
|
||||
goto lvs_segment_fail2;
|
||||
p += sizeof("stripes = [") - 1;
|
||||
|
||||
|
||||
for (j = 0; j < seg->stripe_count; j++)
|
||||
{
|
||||
char *pvname;
|
||||
|
||||
|
||||
p = grub_strchr (p, '"');
|
||||
if (p == NULL)
|
||||
continue;
|
||||
|
@ -494,14 +494,14 @@ grub_lvm_scan_device (const char *name)
|
|||
q++;
|
||||
|
||||
s = q - p;
|
||||
|
||||
|
||||
pvname = grub_malloc (s + 1);
|
||||
if (pvname == NULL)
|
||||
goto lvs_segment_fail2;
|
||||
|
||||
|
||||
grub_memcpy (pvname, p, s);
|
||||
pvname[s] = '\0';
|
||||
|
||||
|
||||
if (vg->pvs)
|
||||
for (pv = vg->pvs; pv; pv = pv->next)
|
||||
{
|
||||
|
@ -511,16 +511,16 @@ grub_lvm_scan_device (const char *name)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
grub_free(pvname);
|
||||
|
||||
|
||||
stripe->start = grub_lvm_getvalue (&p, ",");
|
||||
if (p == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
stripe++;
|
||||
}
|
||||
|
||||
|
||||
seg++;
|
||||
|
||||
continue;
|
||||
|
@ -535,7 +535,7 @@ grub_lvm_scan_device (const char *name)
|
|||
if (p == NULL)
|
||||
goto lvs_fail;
|
||||
p += 3;
|
||||
|
||||
|
||||
lv->number = lv_count++;
|
||||
lv->vg = vg;
|
||||
lv->next = vg->lvs;
|
||||
|
|
|
@ -104,7 +104,7 @@ GRUB_MOD_INIT(memdisk)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_module_iterate (hook);
|
||||
}
|
||||
|
||||
|
|
26
disk/raid.c
26
disk/raid.c
|
@ -77,7 +77,7 @@ static int
|
|||
grub_raid_iterate (int (*hook) (const char *name))
|
||||
{
|
||||
struct grub_raid_array *array;
|
||||
|
||||
|
||||
for (array = array_list; array != NULL; array = array->next)
|
||||
{
|
||||
if (grub_is_array_readable (array))
|
||||
|
@ -95,7 +95,7 @@ grub_raid_memberlist (grub_disk_t disk)
|
|||
struct grub_raid_array *array = disk->data;
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
unsigned int i;
|
||||
|
||||
|
||||
for (i = 0; i < array->total_devs; i++)
|
||||
if (array->device[i])
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ grub_raid_memberlist (grub_disk_t disk)
|
|||
tmp->next = list;
|
||||
list = tmp;
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
#endif
|
||||
|
@ -114,7 +114,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
|
|||
{
|
||||
struct grub_raid_array *array;
|
||||
unsigned n;
|
||||
|
||||
|
||||
for (array = array_list; array != NULL; array = array->next)
|
||||
{
|
||||
if (!grub_strcmp (array->name, name))
|
||||
|
@ -161,7 +161,7 @@ grub_raid_open (const char *name, grub_disk_t disk)
|
|||
|
||||
grub_dprintf ("raid", "%s: level=%d, total_sectors=%lld\n", name,
|
||||
array->level, (unsigned long long) disk->total_sectors);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
p = array->total_devs - n;
|
||||
|
||||
read_sector *= array->chunk_size;
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
grub_size_t read_size;
|
||||
|
@ -405,7 +405,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
buf += read_size << GRUB_DISK_SECTOR_BITS;
|
||||
size -= read_size;
|
||||
if (! size)
|
||||
|
@ -460,7 +460,7 @@ grub_raid_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
|||
const char *scanner_name)
|
||||
{
|
||||
struct grub_raid_array *array = 0, *p;
|
||||
|
||||
|
||||
/* See whether the device is part of an array we have already seen a
|
||||
device from. */
|
||||
for (p = array_list; p != NULL; p = p->next)
|
||||
|
@ -524,7 +524,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
|||
*array = *new_array;
|
||||
array->nr_devs = 0;
|
||||
grub_memset (&array->device, 0, sizeof (array->device));
|
||||
|
||||
|
||||
/* Check whether we don't have multiple arrays with the same number. */
|
||||
for (p = array_list; p != NULL; p = p->next)
|
||||
{
|
||||
|
@ -635,7 +635,7 @@ grub_raid_scan_device (int head_only)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
grub_device_iterate (&hook);
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@ free_array (void)
|
|||
{
|
||||
struct grub_raid_array *p;
|
||||
int i;
|
||||
|
||||
|
||||
p = array;
|
||||
array = array->next;
|
||||
|
||||
|
@ -664,7 +664,7 @@ free_array (void)
|
|||
|
||||
array_list = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_raid_register (grub_raid_t raid)
|
||||
{
|
||||
|
|
|
@ -301,7 +301,7 @@ grub_scsi_open (const char *name, grub_disk_t disk)
|
|||
<< GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
grub_dprintf ("scsi", "capacity=%llu, blksize=%d\n",
|
||||
(unsigned long long) disk->total_sectors,
|
||||
(unsigned long long) disk->total_sectors,
|
||||
scsi->blocksize);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
|
|
@ -267,7 +267,7 @@ grub_usbms_transfer (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
|||
"can't read from USB Mass Storage device");
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
err = grub_usb_bulk_write (dev->dev, dev->in->endp_addr & 15, size, buf);
|
||||
grub_dprintf ("usb", "write: %d %d\n", err, GRUB_USB_ERR_STALL);
|
||||
|
@ -379,7 +379,7 @@ static struct grub_scsi_dev grub_usbms_dev =
|
|||
.close = grub_usbms_close,
|
||||
.read = grub_usbms_read,
|
||||
.write = grub_usbms_write
|
||||
};
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(usbms)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue