NTFS: Fragmented $MFT file was not handled

NTFS $MFT file may be fragmented by itself (and actually is in most
cases).  However, such a situation was not handled.  This patch adds
support for a fragmented $MFT file.

Signed-off-by: Andy Alex <andy at r-tt.com>
Fixed-by: Ady <ady-sf@hotmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
bios: Use int 0x16, ah=0x02 to probe for shift flags

At least one USB keyboard BIOS has been reported to not properly
handle the keyboard flags in memory.  See if actually using INT 16h
works better.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
kbd: Make getting the keyboard shift state a firmware method

Getting the keyboard shift state is a firmware method.  It is
unfortunately unclear if it is even possible on EFI.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
kbd: Use the extended keyboard state query for bios_shiftflags()

Mixing extended and non-extended keyboard functions can be a bad idea.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Centralize shift_is_held(), make it work to force the command line

Holding down shift is supposed to force a command line unless noescape
is provided; make it behave that way.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
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>