2009-05-13 Pavel Roskin <proski@gnu.org>
* fs/cpio.c: Use the same name "struct head" for tar and cpio to facilitate code reuse. (grub_cpio_mount): Use "struct head", not a char buffer. This fixes a warning reported by gcc 4.4.
This commit is contained in:
parent
238e871fff
commit
faec96afc8
2 changed files with 19 additions and 14 deletions
|
@ -1,5 +1,10 @@
|
||||||
2009-05-13 Pavel Roskin <proski@gnu.org>
|
2009-05-13 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* fs/cpio.c: Use the same name "struct head" for tar and cpio to
|
||||||
|
facilitate code reuse.
|
||||||
|
(grub_cpio_mount): Use "struct head", not a char buffer. This
|
||||||
|
fixes a warning reported by gcc 4.4.
|
||||||
|
|
||||||
* kernel/disk.c (grub_disk_read): Use void pointer for the
|
* kernel/disk.c (grub_disk_read): Use void pointer for the
|
||||||
buffer.
|
buffer.
|
||||||
(grub_disk_write): Use const void pointer for the buffer.
|
(grub_disk_write): Use const void pointer for the buffer.
|
||||||
|
|
26
fs/cpio.c
26
fs/cpio.c
|
@ -23,9 +23,10 @@
|
||||||
#include <grub/disk.h>
|
#include <grub/disk.h>
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
|
||||||
|
#ifndef MODE_USTAR
|
||||||
|
/* cpio support */
|
||||||
#define MAGIC_BCPIO 070707
|
#define MAGIC_BCPIO 070707
|
||||||
|
struct head
|
||||||
struct HEAD_BCPIO
|
|
||||||
{
|
{
|
||||||
grub_uint16_t magic;
|
grub_uint16_t magic;
|
||||||
grub_uint16_t dev;
|
grub_uint16_t dev;
|
||||||
|
@ -41,10 +42,10 @@ struct HEAD_BCPIO
|
||||||
grub_uint16_t filesize_1;
|
grub_uint16_t filesize_1;
|
||||||
grub_uint16_t filesize_2;
|
grub_uint16_t filesize_2;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
#else
|
||||||
|
/* tar support */
|
||||||
#define MAGIC_USTAR "ustar"
|
#define MAGIC_USTAR "ustar"
|
||||||
|
struct head
|
||||||
struct HEAD_USTAR
|
|
||||||
{
|
{
|
||||||
char name[100];
|
char name[100];
|
||||||
char mode[8];
|
char mode[8];
|
||||||
|
@ -63,8 +64,7 @@ struct HEAD_USTAR
|
||||||
char devminor[8];
|
char devminor[8];
|
||||||
char prefix[155];
|
char prefix[155];
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
#endif
|
||||||
#define HEAD_LENG sizeof(struct HEAD_USTAR)
|
|
||||||
|
|
||||||
struct grub_cpio_data
|
struct grub_cpio_data
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
|
||||||
grub_uint32_t * ofs)
|
grub_uint32_t * ofs)
|
||||||
{
|
{
|
||||||
#ifndef MODE_USTAR
|
#ifndef MODE_USTAR
|
||||||
struct HEAD_BCPIO hd;
|
struct head hd;
|
||||||
|
|
||||||
if (grub_disk_read
|
if (grub_disk_read
|
||||||
(data->disk, 0, data->hofs, sizeof (hd), &hd))
|
(data->disk, 0, data->hofs, sizeof (hd), &hd))
|
||||||
|
@ -117,7 +117,7 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
|
||||||
if (data->size & 1)
|
if (data->size & 1)
|
||||||
(*ofs)++;
|
(*ofs)++;
|
||||||
#else
|
#else
|
||||||
struct HEAD_USTAR hd;
|
struct head hd;
|
||||||
|
|
||||||
if (grub_disk_read
|
if (grub_disk_read
|
||||||
(data->disk, 0, data->hofs, sizeof (hd), &hd))
|
(data->disk, 0, data->hofs, sizeof (hd), &hd))
|
||||||
|
@ -146,16 +146,16 @@ grub_cpio_find_file (struct grub_cpio_data *data, char **name,
|
||||||
static struct grub_cpio_data *
|
static struct grub_cpio_data *
|
||||||
grub_cpio_mount (grub_disk_t disk)
|
grub_cpio_mount (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
char hd[HEAD_LENG];
|
struct head hd;
|
||||||
struct grub_cpio_data *data;
|
struct grub_cpio_data *data;
|
||||||
|
|
||||||
if (grub_disk_read (disk, 0, 0, sizeof (hd), hd))
|
if (grub_disk_read (disk, 0, 0, sizeof (hd), &hd))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
#ifndef MODE_USTAR
|
#ifndef MODE_USTAR
|
||||||
if (((struct HEAD_BCPIO *) hd)->magic != MAGIC_BCPIO)
|
if (hd.magic != MAGIC_BCPIO)
|
||||||
#else
|
#else
|
||||||
if (grub_memcmp (((struct HEAD_USTAR *) hd)->magic, MAGIC_USTAR,
|
if (grub_memcmp (hd.magic, MAGIC_USTAR,
|
||||||
sizeof (MAGIC_USTAR) - 1))
|
sizeof (MAGIC_USTAR) - 1))
|
||||||
#endif
|
#endif
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Reference in a new issue