Compare commits

...
Author SHA1 Message Date
Andrei Borzenkov e897f83635 Merge branch 'master' into andrey/ext4_inline_data
Conflicts:
	grub-core/fs/ext2.c
2016-07-11 07:23:13 +03:00
Andrei Borzenkov b524fa27f5 net: translate pxe prefix to tftp when checking for self-load
Commit ba218c1 missed legacy pxe and pxe: prefixes which are
translated to tftp, so comparison failed.
2016-05-03 19:23:31 +03:00
Andrei Borzenkov e045af148a net: reset net->stall in grub_net_seek_real
If we open new connection, we need to reset stall indication, otherwise
nothing will ever be polled (low level code rely on this field being
zero when establishing connection).
2016-04-30 09:15:36 +03:00
Stefan Fritsch 13f7ead3a1 http: reset EOF indication in http_seek
Otherwise next read will stop polling too early due to stale EOF
indicator, returning incomplete data to caller.
2016-04-30 09:13:34 +03:00
Mike Gilbert 7a5b301e3a build: Use AC_HEADER_MAJOR to find device macros
Depending on the OS/libc, device macros are defined in different
headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may
change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html
2016-04-24 08:12:42 +03:00
Michael Chang abf9beb7d6 http: fix superfluous null line in range request header
At least the apache sever is very unhappy with that extra null line and will
take more than ten seconds in responding to each range request, which slows
down a lot the entire http file transfer process or even time out.
2016-04-09 07:08:13 +03:00
Andrei Borzenkov f4d35d49e3 configure: set -fno-pie together with -fno-PIE
OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate
already, but that is not enough - it does not turn off -fpie.

Actually check for -fPIE is not precise enough. __PIE__ is set for both
-fpie and -fPIE but with different values. As far as I can tell, both
options were introduced at the same time, so both should always be supported.

This fixes compilation on OpenBSD 5.9 which otherwise created insanely big
lzma_decompress.img.

Reported, suggested and tested by: Jiri B <jirib@devio.us>
2016-03-22 20:12:22 +03:00
Andrei Borzenkov 6714d7ecff bootp: check that interface is not NULL in configure_by_dhcp_ack
grub_net_add_addr may fail with OOM and we use returned interface
later without any checks.
2016-03-20 10:32:33 +03:00
Andrei Borzenkov 5b8ddf6e03 bootp: fix memory leak in grub_cmd_dhcpopt 2016-03-19 09:39:30 +03:00
Aaron Luft 76eac44af3 Remove the variable oldname which is attempting to free stack space.
Historically this variable hold previous value of filename that
had to be freed if allocated previously. Currently this branch
is entered only if filename was not allocated previously so it
became redundant. It did not cause real problems because grub_free
was not called, but code is confusing and causes compilation error
in some cases.
2016-03-15 22:04:38 +03:00
Andrei Borzenkov ee83919e93 Makefile.util.def: add $LIBINTL to grub-macbless flags
Fixes compilation on OpenBSD 5.9.

Reported by Jiri B <jirib@devio.us>
2016-03-13 08:11:58 +03:00
Robert Marshall 3c3e96d044 Failed config now returns exit code (#1252311)
Grub would notify the user if the new config was invalid, however, it
did not exit properly with exit code 1. Added the proper exit code.

Resolves: rhbz#1252311
2016-03-11 17:24:56 +01:00
Michael Chang 15aee573d2 xen_file: Fix invalid payload size 2016-03-11 10:26:51 +01:00
Vladimir Serbinenko 7f2a856fae multiboot2: Remove useless GRUB_PACKED
Reported by: Daniel Kiper
2016-03-10 21:16:10 +01:00
Andrei Borzenkov 9545a8fd04 20_linux_xen: fix test for GRUB_DEVICE
Same fix as in 082bc9f.
2016-03-06 08:54:19 +03:00
Mike Gilbert 082bc9f77b 10_linux: Fix grouping of tests for GRUB_DEVICE
Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to
mixing of || and && operators. Add some parens to help with that.
2016-03-06 08:51:07 +03:00
Andrei Borzenkov d017ea8ede NEWS update 2016-02-28 21:52:08 +03:00
Andrey Borzenkov d4af83fc60 ext4 inline data support 2013-12-18 19:53:19 +01:00
17 changed files with 282 additions and 58 deletions

No files matched your search

+1 -1
View File
@@ -416,7 +416,7 @@ program = {
ldadd = libgrubgcry.a; ldadd = libgrubgcry.a;
ldadd = libgrubkern.a; ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a; ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
}; };
data = { data = {
+11
View File
@@ -18,6 +18,7 @@ New in 2.02:
* ZFS features support. * ZFS features support.
* ZFS LZ4 support. * ZFS LZ4 support.
* XFS V5 format support. * XFS V5 format support.
* LVM RAID1 support.
* New/improved terminal and video support: * New/improved terminal and video support:
* Monochrome text (matching `hercules' in GRUB Legacy). * Monochrome text (matching `hercules' in GRUB Legacy).
@@ -49,6 +50,7 @@ New in 2.02:
* Improve TFTP robustness. * Improve TFTP robustness.
* Parse `nd' disk names in GRUB Legacy configuration files. * Parse `nd' disk names in GRUB Legacy configuration files.
* Issue separate DNS queries for IPv4 and IPv6. * Issue separate DNS queries for IPv4 and IPv6.
* Support IPv6 Router Advertisement to configure default router.
* Coreboot improvements: * Coreboot improvements:
* CBFS support both in on-disk images (loopback) and flash. * CBFS support both in on-disk images (loopback) and flash.
@@ -96,6 +98,8 @@ New in 2.02:
EFI Stall. If everything fails, use hardcoded frequency 800MHz. EFI Stall. If everything fails, use hardcoded frequency 800MHz.
* Support Hyper-V Gen2 platforms which lack PIT for TSC calibration. * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration.
* Map UEFI Persistent Memory to E820 persistent memory. * Map UEFI Persistent Memory to E820 persistent memory.
* New Xen loader on ARM64.
* Respect alignment requirement for block device IO buffers on EFI.
* Security: * Security:
* Add optional facility to enforce that all files read by the core image * Add optional facility to enforce that all files read by the core image
@@ -134,6 +138,11 @@ New in 2.02:
menu entry immediately. menu entry immediately.
* New `file' command and grub-file utility to check file types. * New `file' command and grub-file utility to check file types.
* New syslinux configuration file parser. * New syslinux configuration file parser.
* Set menu entry class to primary OS name returned by os-prober to display
OS specific icon.
* On Linux x86 detect EFI word size in grub-install and automatically select
correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel
4.0 or higher.
* Build system: * Build system:
* Remove all uses of nested functions; GRUB no longer requires an * Remove all uses of nested functions; GRUB no longer requires an
@@ -160,6 +169,8 @@ New in 2.02:
* emu libusb support removed (was broken and unmaintained). * emu libusb support removed (was broken and unmaintained).
* powerpc64le compile support. * powerpc64le compile support.
* Use fixed timestamp when generating GRUB image for reproducible builds. * Use fixed timestamp when generating GRUB image for reproducible builds.
* Verify at build time that modules contain only supported relocations and their
structure matches what boot-time module loader expects.
* Revision control moved to git. * Revision control moved to git.
+4 -3
View File
@@ -388,7 +388,8 @@ fi
# Check for functions and headers. # Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign getextmntent) AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
AC_HEADER_MAJOR
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
#include <sys/param.h> #include <sys/param.h>
@@ -1185,9 +1186,9 @@ CFLAGS="$TARGET_CFLAGS"
# Position independent executable. # Position independent executable.
grub_CHECK_PIE grub_CHECK_PIE
[# Need that, because some distributions ship compilers that include [# Need that, because some distributions ship compilers that include
# `-fPIE' in the default specs. # `-fPIE' or '-fpie' in the default specs.
if [ x"$pie_possible" = xyes ]; then if [ x"$pie_possible" = xyes ]; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
fi] fi]
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
+215 -36
View File
@@ -89,6 +89,9 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
/* Superblock filesystem feature flags (back-incompatible) /* Superblock filesystem feature flags (back-incompatible)
* A filesystem with any of these enabled should not be attempted to be read * A filesystem with any of these enabled should not be attempted to be read
* by a driver that does not understand them, since they usually indicate * by a driver that does not understand them, since they usually indicate
@@ -102,6 +105,11 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
#define EXT4_FEATURE_INCOMPAT_BG_USE_META_CSUM 0x2000 /* use crc32c for bg */
#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3-lvl htree */
#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
/* The set of back-incompatible features this driver DOES support. Add (OR) /* The set of back-incompatible features this driver DOES support. Add (OR)
* flags here as the related features are implemented into the driver. */ * flags here as the related features are implemented into the driver. */
@@ -109,7 +117,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
| EXT4_FEATURE_INCOMPAT_EXTENTS \ | EXT4_FEATURE_INCOMPAT_EXTENTS \
| EXT4_FEATURE_INCOMPAT_FLEX_BG \ | EXT4_FEATURE_INCOMPAT_FLEX_BG \
| EXT2_FEATURE_INCOMPAT_META_BG \ | EXT2_FEATURE_INCOMPAT_META_BG \
| EXT4_FEATURE_INCOMPAT_64BIT) | EXT4_FEATURE_INCOMPAT_64BIT \
| EXT4_FEATURE_INCOMPAT_INLINE_DATA)
/* List of rationales for the ignored "incompatible" features: /* List of rationales for the ignored "incompatible" features:
* needs_recovery: Not really back-incompatible - was added as such to forbid * needs_recovery: Not really back-incompatible - was added as such to forbid
* ext2 drivers from mounting an ext3 volume with a dirty * ext2 drivers from mounting an ext3 volume with a dirty
@@ -316,12 +325,40 @@ struct grub_ext4_extent_idx
grub_uint16_t unused; grub_uint16_t unused;
}; };
#define EXT4_XATTR_MAGIC 0xEA020000
#define EXT4_XATTR_INDEX_SYSTEM 7
#define EXT4_XATTR_SYSTEM_DATA "data"
#define EXT4_INLINE_DOTDOT_SIZE 4
struct grub_ext4_xattr_entry
{
grub_uint8_t name_len; /* length of name */
grub_uint8_t name_index; /* attribute name index */
grub_uint16_t value_offs; /* offset in disk block of value */
grub_uint32_t value_block; /* disk block attribute is stored on */
grub_uint32_t value_size; /* size of attribute value */
grub_uint32_t hash; /* hash value of name and value */
char name[0]; /* attribute name */
} GRUB_PACKED;
#define EXT4_XATTR_LEN(name_len) \
(ALIGN_UP((name_len) + sizeof(struct grub_ext4_xattr_entry), 4))
#define EXT4_XATTR_NEXT(entry) \
((struct grub_ext4_xattr_entry *)( \
(char *)(entry) + EXT4_XATTR_LEN((entry)->name_len)))
#define IS_LAST_ENTRY(entry) (grub_get_unaligned32 (entry) == 0)
struct grub_fshelp_node struct grub_fshelp_node
{ {
struct grub_ext2_data *data; struct grub_ext2_data *data;
struct grub_ext2_inode inode; struct grub_ext2_inode inode;
int ino; grub_uint32_t ino;
int inode_read; int inode_read;
grub_disk_addr_t inode_base; /* Inode filesystem block */
grub_off_t inode_offs; /* Inode offset in filesystem block */
grub_off_t inline_offs; /* Offset of inline data from start of inode */
grub_size_t inline_size; /* Size of inline data */
}; };
/* Information about a "mounted" ext2 filesystem. */ /* Information about a "mounted" ext2 filesystem. */
@@ -367,6 +404,66 @@ group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
is_power_of(group, 3)); is_power_of(group, 3));
} }
/* Inline data is stored using inline extended attributes. Attributes consist
of entry and value. Entries start after inode proper, following 4 bytes
magic header. Each entry is 4 bytes aligned, end of list is marked with
4 bytes zero. Values are stored after entries.
Inline data is stored as system attribute with name "data". First part of
data is kept in space reserved for block pointers, so it is valid for value
size to be zero. Offset is apparently non-zero even in this case.
*/
inline static void
grub_ext2_find_inline_data (struct grub_fshelp_node *node, grub_size_t isize,
struct grub_ext2_inode *inode)
{
grub_size_t extra;
grub_uint8_t *ihdr;
struct grub_ext4_xattr_entry *entry;
grub_uint8_t *iend = (grub_uint8_t *) inode + isize - sizeof (grub_uint32_t);
node->inline_offs = 0;
if (isize < EXT2_GOOD_OLD_INODE_SIZE + sizeof (grub_uint16_t))
return;
extra = grub_le_to_cpu16 (*((grub_uint16_t *) inode
+ (EXT2_GOOD_OLD_INODE_SIZE / 2)));
if (EXT2_GOOD_OLD_INODE_SIZE + extra + 4 > isize)
return;
ihdr = ((grub_uint8_t *) inode
+ EXT2_GOOD_OLD_INODE_SIZE + extra);
if (grub_get_unaligned32 (ihdr)
!= grub_cpu_to_le32_compile_time (EXT4_XATTR_MAGIC))
return;
entry = (struct grub_ext4_xattr_entry *) (ihdr + 4);
for (; (grub_uint8_t *) entry < iend && !IS_LAST_ENTRY(entry);
entry = EXT4_XATTR_NEXT(entry))
{
grub_size_t value_size;
grub_off_t value_offs;
if (entry->value_block)
continue;
if (entry->name_index != EXT4_XATTR_INDEX_SYSTEM)
continue;
if (entry->name_len != sizeof (EXT4_XATTR_SYSTEM_DATA) - 1)
continue;
if (grub_memcmp (entry->name, EXT4_XATTR_SYSTEM_DATA, sizeof (EXT4_XATTR_SYSTEM_DATA) - 1))
continue;
value_size = grub_le_to_cpu32 (entry->value_size);
value_offs = grub_le_to_cpu16 (entry->value_offs);
/* extra is additional size of base inode. Extended attributes start
after base inode, offset is calculated from the end of extended
attributes header.
*/
if (EXT2_GOOD_OLD_INODE_SIZE + extra + 4 + value_offs + value_size > isize)
continue;
node->inline_offs = EXT2_GOOD_OLD_INODE_SIZE + extra + 4 + value_offs;
node->inline_size = value_size;
return;
}
}
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of /* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */ the mounted filesystem DATA. */
inline static grub_err_t inline static grub_err_t
@@ -568,6 +665,52 @@ grub_ext2_read_file (grub_fshelp_node_t node,
grub_disk_read_hook_t read_hook, void *read_hook_data, grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf)
{ {
/* Does inode have inine data? */
if (node->inline_offs)
{
grub_size_t cp_len;
grub_off_t cp_pos;
grub_ssize_t total = 0;
if (pos < 60)
{
cp_pos = node->inode_offs + ((char *)&node->inode.blocks - (char *)&node->inode) + pos;
cp_len = 60 - pos;
if (cp_len > len)
cp_len = len;
node->data->disk->read_hook = read_hook;
node->data->disk->read_hook_data = read_hook_data;
grub_disk_read (node->data->disk, node->inode_base, cp_pos,
cp_len, buf);
node->data->disk->read_hook = 0;
if (grub_errno)
return -1;
pos += cp_len;
buf += cp_len;
len -= cp_len;
total = cp_len;
}
if (len)
{
pos -= 60;
if (pos >= node->inline_size)
return 0;
if (pos + len > node->inline_size)
len = node->inline_size - pos;
cp_pos = node->inode_offs + node->inline_offs + pos;
node->data->disk->read_hook = read_hook;
node->data->disk->read_hook_data = read_hook_data;
grub_disk_read (node->data->disk, node->inode_base, cp_pos,
len, buf);
node->data->disk->read_hook = 0;
if (!grub_errno)
total += len;
}
return total;
}
return grub_fshelp_read_file (node->data->disk, node, return grub_fshelp_read_file (node->data->disk, node,
read_hook, read_hook_data, read_hook, read_hook_data,
pos, len, buf, grub_ext2_read_block, pos, len, buf, grub_ext2_read_block,
@@ -578,17 +721,28 @@ grub_ext2_read_file (grub_fshelp_node_t node,
} }
/* Read the inode INO for the file described by DATA into INODE. */ /* Read the inode NODE->INO for the file described by NODE->DATA into NODE->INODE. */
static grub_err_t static grub_err_t
grub_ext2_read_inode (struct grub_ext2_data *data, grub_ext2_read_inode (struct grub_fshelp_node *node)
int ino, struct grub_ext2_inode *inode)
{ {
struct grub_ext2_data *data = node->data;
grub_uint32_t ino = node->ino;
struct grub_ext2_block_group blkgrp; struct grub_ext2_block_group blkgrp;
struct grub_ext2_sblock *sblock = &data->sblock; struct grub_ext2_sblock *sblock = &data->sblock;
int inodes_per_block; int inodes_per_block;
unsigned int blkno; unsigned int blkno;
unsigned int blkoff; unsigned int blkoff;
grub_disk_addr_t base; grub_disk_addr_t base;
struct grub_ext2_inode *full_inode;
grub_size_t full_isize;
if (node->inode_read)
return 0;
full_isize = EXT2_INODE_SIZE (data);
full_inode = grub_malloc (full_isize);
if (!full_inode)
return 0;
/* It is easier to calculate if the first inode is 0. */ /* It is easier to calculate if the first inode is 0. */
ino--; ino--;
@@ -597,9 +751,12 @@ grub_ext2_read_inode (struct grub_ext2_data *data,
ino / grub_le_to_cpu32 (sblock->inodes_per_group), ino / grub_le_to_cpu32 (sblock->inodes_per_group),
&blkgrp); &blkgrp);
if (grub_errno) if (grub_errno)
{
grub_free (full_inode);
return grub_errno; return grub_errno;
}
inodes_per_block = EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data); inodes_per_block = EXT2_BLOCK_SIZE (data) / full_isize;
blkno = (ino % grub_le_to_cpu32 (sblock->inodes_per_group)) blkno = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
/ inodes_per_block; / inodes_per_block;
blkoff = (ino % grub_le_to_cpu32 (sblock->inodes_per_group)) blkoff = (ino % grub_le_to_cpu32 (sblock->inodes_per_group))
@@ -611,12 +768,19 @@ grub_ext2_read_inode (struct grub_ext2_data *data,
<< 32); << 32);
/* Read the inode. */ /* Read the inode. */
if (grub_disk_read (data->disk, node->inode_base = (base + blkno) << LOG2_EXT2_BLOCK_SIZE (data);
((base + blkno) << LOG2_EXT2_BLOCK_SIZE (data)), node->inode_offs = full_isize * blkoff;
EXT2_INODE_SIZE (data) * blkoff, if (grub_disk_read (data->disk, node->inode_base, node->inode_offs,
sizeof (struct grub_ext2_inode), inode)) full_isize, full_inode))
{
grub_free (full_inode);
return grub_errno; return grub_errno;
}
grub_memcpy (&node->inode, full_inode, sizeof (struct grub_ext2_inode));
node->inode_read = 1;
grub_ext2_find_inline_data (node, full_isize, full_inode);
grub_free (full_inode);
return 0; return 0;
} }
@@ -677,11 +841,9 @@ grub_ext2_mount (grub_disk_t disk)
data->diropen.data = data; data->diropen.data = data;
data->diropen.ino = 2; data->diropen.ino = 2;
data->diropen.inode_read = 1;
data->inode = &data->diropen.inode; data->inode = &data->diropen.inode;
grub_ext2_read_inode (data, 2, data->inode); grub_ext2_read_inode (&data->diropen);
if (grub_errno) if (grub_errno)
goto fail; goto fail;
@@ -701,12 +863,9 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
char *symlink; char *symlink;
struct grub_fshelp_node *diro = node; struct grub_fshelp_node *diro = node;
if (! diro->inode_read) grub_ext2_read_inode (diro);
{
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
if (grub_errno) if (grub_errno)
return 0; return 0;
}
symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1); symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1);
if (! symlink) if (! symlink)
@@ -742,11 +901,42 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
unsigned int fpos = 0; unsigned int fpos = 0;
struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir;
if (! diro->inode_read) grub_ext2_read_inode (diro);
{
grub_ext2_read_inode (diro->data, diro->ino, &diro->inode);
if (grub_errno) if (grub_errno)
return 0; return 0;
/* Inline directory has only parent inode number and no explicit entries
for . or ..; simulate them */
if (diro->inline_offs)
{
struct grub_fshelp_node *dot, *dotdot;
grub_uint32_t inum;
dot = grub_malloc (sizeof (struct grub_fshelp_node));
if (!dot)
return 0;
dot->inode_read = 0;
dot->ino = dir->ino;
dot->data = diro->data;
if (hook (".", FILETYPE_DIRECTORY, dot, hook_data))
return 1;
/* First 4 bytes of inline directory data is parent inode number */
grub_ext2_read_file (diro, 0, 0, 0, EXT4_INLINE_DOTDOT_SIZE, (char *) &inum);
if (grub_errno)
return 0;
dotdot = grub_malloc (sizeof (struct grub_fshelp_node));
if (!dotdot)
return 0;
dotdot->inode_read = 0;
dotdot->ino = grub_le_to_cpu32 (inum);
dotdot->data = diro->data;
if (hook ("..", FILETYPE_DIRECTORY, dotdot, hook_data))
return 1;
fpos = EXT4_INLINE_DOTDOT_SIZE;
} }
/* Search the file. */ /* Search the file. */
@@ -797,17 +987,13 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir,
{ {
/* The filetype can not be read from the dirent, read /* The filetype can not be read from the dirent, read
the inode to get more information. */ the inode to get more information. */
grub_ext2_read_inode (diro->data, grub_ext2_read_inode (fdiro);
grub_le_to_cpu32 (dirent.inode),
&fdiro->inode);
if (grub_errno) if (grub_errno)
{ {
grub_free (fdiro); grub_free (fdiro);
return 0; return 0;
} }
fdiro->inode_read = 1;
if ((grub_le_to_cpu16 (fdiro->inode.mode) if ((grub_le_to_cpu16 (fdiro->inode.mode)
& FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY) & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY)
type = GRUB_FSHELP_DIR; type = GRUB_FSHELP_DIR;
@@ -852,14 +1038,11 @@ grub_ext2_open (struct grub_file *file, const char *name)
if (err) if (err)
goto fail; goto fail;
if (! fdiro->inode_read) err = grub_ext2_read_inode (fdiro);
{
err = grub_ext2_read_inode (data, fdiro->ino, &fdiro->inode);
if (err) if (err)
goto fail; goto fail;
}
grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode)); grub_memcpy (&data->diropen, fdiro, sizeof (struct grub_fshelp_node));
grub_free (fdiro); grub_free (fdiro);
file->size = grub_le_to_cpu32 (data->inode->size); file->size = grub_le_to_cpu32 (data->inode->size);
@@ -918,13 +1101,9 @@ grub_ext2_dir_iter (const char *filename, enum grub_fshelp_filetype filetype,
struct grub_dirhook_info info; struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info)); grub_memset (&info, 0, sizeof (info));
if (! node->inode_read) grub_ext2_read_inode (node);
{
grub_ext2_read_inode (ctx->data, node->ino, &node->inode);
if (!grub_errno)
node->inode_read = 1;
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
}
if (node->inode_read) if (node->inode_read)
{ {
info.mtimeset = 1; info.mtimeset = 1;
+2 -6
View File
@@ -750,19 +750,15 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
if (dir->data->joliet && !ctx.filename) if (dir->data->joliet && !ctx.filename)
{ {
char *oldname, *semicolon; char *semicolon;
oldname = name;
ctx.filename = grub_iso9660_convert_string ctx.filename = grub_iso9660_convert_string
((grub_uint8_t *) oldname, dirent.namelen >> 1); ((grub_uint8_t *) name, dirent.namelen >> 1);
semicolon = grub_strrchr (ctx.filename, ';'); semicolon = grub_strrchr (ctx.filename, ';');
if (semicolon) if (semicolon)
*semicolon = '\0'; *semicolon = '\0';
if (ctx.filename_alloc)
grub_free (oldname);
ctx.filename_alloc = 1; ctx.filename_alloc = 1;
} }
+2 -2
View File
@@ -55,11 +55,11 @@ grub_xen_file (grub_file_t file)
grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n",
(unsigned long long) (lh.setup_sects + 1) * 512 (unsigned long long) (lh.setup_sects + 1) * 512
+ lh.payload_offset, + lh.payload_offset,
(unsigned long long) lh.payload_length - 4); (unsigned long long) lh.payload_length);
off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512 off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512
+ lh.payload_offset, + lh.payload_offset,
lh.payload_length - 4); lh.payload_length);
if (!off_file) if (!off_file)
goto fail; goto fail;
+11 -4
View File
@@ -157,6 +157,9 @@ grub_net_configure_by_dhcp_ack (const char *name,
hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags); inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
if (!inter)
return 0;
#if 0 #if 0
/* This is likely based on misunderstanding. gateway_ip refers to /* This is likely based on misunderstanding. gateway_ip refers to
address of BOOTP relay and should not be used after BOOTP transaction address of BOOTP relay and should not be used after BOOTP transaction
@@ -368,6 +371,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (grub_strcmp (args[3], "string") == 0) if (grub_strcmp (args[3], "string") == 0)
{ {
grub_err_t err = GRUB_ERR_NONE;
char *val = grub_malloc (taglength + 1); char *val = grub_malloc (taglength + 1);
if (!val) if (!val)
return grub_errno; return grub_errno;
@@ -376,8 +380,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (args[0][0] == '-' && args[0][1] == 0) if (args[0][0] == '-' && args[0][1] == 0)
grub_printf ("%s\n", val); grub_printf ("%s\n", val);
else else
return grub_env_set (args[0], val); err = grub_env_set (args[0], val);
return GRUB_ERR_NONE; grub_free (val);
return err;
} }
if (grub_strcmp (args[3], "number") == 0) if (grub_strcmp (args[3], "number") == 0)
@@ -399,6 +404,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (grub_strcmp (args[3], "hex") == 0) if (grub_strcmp (args[3], "hex") == 0)
{ {
grub_err_t err = GRUB_ERR_NONE;
char *val = grub_malloc (2 * taglength + 1); char *val = grub_malloc (2 * taglength + 1);
int i; int i;
if (!val) if (!val)
@@ -412,8 +418,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (args[0][0] == '-' && args[0][1] == 0) if (args[0][0] == '-' && args[0][1] == 0)
grub_printf ("%s\n", val); grub_printf ("%s\n", val);
else else
return grub_env_set (args[0], val); err = grub_env_set (args[0], val);
return GRUB_ERR_NONE; grub_free (val);
return err;
} }
return grub_error (GRUB_ERR_BAD_ARGUMENT, return grub_error (GRUB_ERR_BAD_ARGUMENT,
+2 -2
View File
@@ -381,9 +381,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
ptr = nb->tail; ptr = nb->tail;
grub_snprintf ((char *) ptr, grub_snprintf ((char *) ptr,
sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-" sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-"
"\r\n"
"\r\n"), "\r\n"),
"Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n\r\n", "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n",
offset); offset);
grub_netbuff_put (nb, grub_strlen ((char *) ptr)); grub_netbuff_put (nb, grub_strlen ((char *) ptr));
} }
@@ -450,6 +449,7 @@ http_seek (struct grub_file *file, grub_off_t off)
} }
file->device->net->stall = 0; file->device->net->stall = 0;
file->device->net->eof = 0;
file->device->net->offset = off; file->device->net->offset = off;
data = grub_zalloc (sizeof (*data)); data = grub_zalloc (sizeof (*data));
+10
View File
@@ -1346,6 +1346,15 @@ grub_net_open_real (const char *name)
continue; continue;
} }
if (grub_strncmp (prefdev, "pxe", sizeof ("pxe") - 1) == 0 &&
(!prefdev[sizeof ("pxe") - 1] || (prefdev[sizeof("pxe") - 1] == ':')))
{
grub_free (prefdev);
prefdev = grub_strdup ("tftp");
if (!prefdev)
continue;
}
comma = grub_strchr (prefdev, ','); comma = grub_strchr (prefdev, ',');
if (comma) if (comma)
*comma = '\0'; *comma = '\0';
@@ -1672,6 +1681,7 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset)
file->device->net->packs.last = NULL; file->device->net->packs.last = NULL;
file->device->net->offset = 0; file->device->net->offset = 0;
file->device->net->eof = 0; file->device->net->eof = 0;
file->device->net->stall = 0;
err = file->device->net->protocol->open (file, file->device->net->name); err = file->device->net->protocol->open (file, file->device->net->name);
if (err) if (err)
return err; return err;
+6
View File
@@ -40,6 +40,12 @@
#include <limits.h> #include <limits.h>
#endif #endif
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#include <libdevmapper.h> #include <libdevmapper.h>
#include <grub/types.h> #include <grub/types.h>
+5
View File
@@ -24,6 +24,11 @@
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#ifdef HAVE_DEVICE_MAPPER #ifdef HAVE_DEVICE_MAPPER
# include <libdevmapper.h> # include <libdevmapper.h>
+6
View File
@@ -35,6 +35,12 @@
#include <limits.h> #include <limits.h>
#endif #endif
#if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif
#include <grub/types.h> #include <grub/types.h>
#include <sys/ioctl.h> /* ioctl */ #include <sys/ioctl.h> /* ioctl */
#include <sys/mount.h> #include <sys/mount.h>
+3 -1
View File
@@ -51,8 +51,10 @@
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#if defined(HAVE_SYS_MKDEV_H) #if defined(MAJOR_IN_MKDEV)
#include <sys/mkdev.h> #include <sys/mkdev.h>
#elif defined(MAJOR_IN_SYSMACROS)
#include <sys/sysmacros.h>
#endif #endif
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
+1 -1
View File
@@ -176,7 +176,7 @@ struct multiboot_mmap_entry
#define MULTIBOOT_MEMORY_BADRAM 5 #define MULTIBOOT_MEMORY_BADRAM 5
multiboot_uint32_t type; multiboot_uint32_t type;
multiboot_uint32_t zero; multiboot_uint32_t zero;
} GRUB_PACKED; };
typedef struct multiboot_mmap_entry multiboot_memory_map_t; typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag struct multiboot_tag
+1
View File
@@ -273,6 +273,7 @@ Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with and /etc/grub.d/* files or please file a bug report with
%s file attached." "${grub_cfg}.new" >&2 %s file attached." "${grub_cfg}.new" >&2
echo >&2 echo >&2
exit 1
else else
# none of the children aborted with error, install the new grub.cfg # none of the children aborted with error, install the new grub.cfg
mv -f ${grub_cfg}.new ${grub_cfg} mv -f ${grub_cfg}.new ${grub_cfg}
+1 -1
View File
@@ -47,7 +47,7 @@ esac
# and mounting btrfs requires user space scanning, so force UUID in this case. # and mounting btrfs requires user space scanning, so force UUID in this case.
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
LINUX_ROOT_DEVICE=${GRUB_DEVICE} LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
+1 -1
View File
@@ -47,7 +47,7 @@ esac
# and mounting btrfs requires user space scanning, so force UUID in this case. # and mounting btrfs requires user space scanning, so force UUID in this case.
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
|| test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
LINUX_ROOT_DEVICE=${GRUB_DEVICE} LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}