btrfs: Move ldlinux.sys to Boot Area B

ldlinux.sys is frequently too big to fit into Boot Area A (64K).  Per
a recent ruling by Chris Mason, we have a 768K Boot Area B at offset
256K, so use that to store ldlinux.sys.  In theory we could split it
up and make it slightly larger, however, ldlinux.sys is loaded below
the 640K mark so it has to be smaller than that size anyway.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
btrfs: fix typo in definition of BTRFS_ADV_OFFSET

Correct the macros used in BTRFS_ADV_OFFSET.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
ldlinux: Allow a held shift key to override UI as well as DEFAULT

For compatibility with 4.xx, make a held shift escape to override UI
as well as DEFAULT.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
btrfs: Fix stack smash with node size > 4K

Newer btrfs has a node size of more than 4K.  Make sure we have a
buffer big enough to hold a node -- instead of allocating it on the
stack, allocate it at startup time.

While changing this code, remove a completely unnecessary arbitrary
64-bit divide.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
btrfs: Remove static variables

Remove the use of static variables and replace them with per-instance
allocations that can be found from the fs_info structure.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
cache, btrfs: Provide a general cached read routine

btrfs_read() was really just a function to read data linearly while
using the metadata cache.  Move it to cache.c and rename it
cache_read() so other filesystems can make use of it as well.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
ntfs: fix incorrect file->offset usage in ntfs_readdir

file->offset is used to store position in index root between
ntfs_readdir calls.  Previously, pointer to buffer was stored in this
field. However this buffer is reallocated and read each ntfs_readdir
call so the pointer may become incorrect.  Now offset in index root
rather than pointer is stored in this field.

[ hpa: applied patch manually as it arrived whitespace-corrupted ]

Signed-off-by: Andy Alex <andy at r-tt.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
installer: Add UFS1/2 support for Extlinux installer

It's needed to enumerate both UFS1 and UFS2 as they have different magic numbers
and super block offsets.

Neither UFS1 nor UFS2 move files around, therefore, ldlinux.sys can be
installed as a regular file.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/fs: Add support to Unix File system 1/2.

It's already loading modules successfully, booting Linux, and both
UFS version 1 and 2 seem to be working correctly.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
adv: Remove double defintion

__syslinux_adv_* symbols are now part of the core, so don't export
them again elsewhere.  This broke all uses of the ADV, including
--once.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Make symbols defined in linker script HIDDEN

This makes symbols defined in com32.ld and syslinux.ld HIDDEN, to
avoid collisions.  Additional linker scripts should have this done, too.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
sysdump: Remove README that was for memdump, not sysdump

Sysdump was forked from memdump, but the README was never fixed.  It
should be updated, but until then, delete it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
memdump: Remove old obsolete COM16 binary

memdump was a com16 binary.  If still useful, it should be replaced
with a com32 library using libupload, but it has largely been replaced
by sysdump anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32: Fixing lua's dependencies

Lua shall be one of the latest module to build as it requires some other
components to be built before.

Prior this patch, it was impossible to make a parallel build when "j"
was greater than 26.

This patch fix the ordering and allow a "make -j"  of com32 directory.
Revert "ldlinux: Allow a held shift key to override UI as well as DEFAULT"

This reverts commit 7e7139788c8ac6ffbf474976ad4d1727e0677b9f.

Requested by Ady <ady-sf@hotmail.com> who also requested the original
patch:

After some tests with MENU SHIFTKEY with different versions of
Syslinux, I came to the conclusion that, at least for now, it would
be better to undo commit 7e7139788c8ac6ffbf474976ad4d1727e0677b9f:

 "ldlinux: Allow a held shift key to override UI as well as DEFAULT"
committed on Thu, 22 May 2014.

Although the aforementioned commit makes the current 6.03 branch
behave as version 4.xx, my tests show that the behavior is
effectively inadequate and inconsistent.

Although I had been previously nagging you in irc about maintaining
backward compatibility of the "force-prompt" keys, I have to ask you
to undo the aforementioned commit before the final release of 6.03
stable. The behavior of Syslinux 6.03 without this particular commit
will slightly "break" with the prior "force-prompt" behavior as seen
in 4.xx when using [vesa]menu.c32, but it will be more consistent and
clean.

Without this commit, the user can still avoid the automatic launch of
the default label by the same means (the "escape" "shift" keys),
which is the most important characteristic of MENU SHIFTKEY.

Please consider this request before the release of 6.03 stable.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxe: Re-add support for embedded DHCP options

Fix the support for embedded DHCP options.  Although we were
diligently saving them away, we never actually parsed them.

This fixes embedded options for BIOS only -- for EFI we need to modify
the encoding scheme so that it can fit inside an EFI PECOFF image.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxe: Add support for embedded options in EFI

For EFI, rather than mucking with the PECOFF or ELF headers (we have
both!) just use a fixed-size buffer embedded in the image with a large
magic number that can be scanned for safely.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxelinux-options: Fix data corruption bug

Fix bug where the data would invariably be incorrectly written.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
isohybrid: fix overflow on 32 bit system

When call isohybrid with option '-u', it overflows on a 32 bits host. It
seeks to 512 bytes before the end of the image to install gpt header. If
the size of image is larger than LONG_MAX, it overflows fseek() and
cause error:

isohybrid: image-x86-64-20140505110100.iso: seek error - 8: Invalid argument

Replace fseek with fseeko to fix this issue.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
isohybrid: define _FILE_OFFSET_BITS in the file itself

On general principles, define _FILE_OFFSET_BITS in the file itself
(even though it is also in the Makefile.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>