platform/upstream/syslinux.git
11 years ago4k_sector: Reduce size reducing a message
Frediano Ziglio [Fri, 8 Feb 2013 12:58:35 +0000 (12:58 +0000)]
4k_sector: Reduce size reducing a message

Easy way to reduce code but actually I found the message is
readable at the same way as previous.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years ago4k_sector: Save some bytes adding a function to set bx before read_sector
Frediano Ziglio [Fri, 8 Feb 2013 12:58:34 +0000 (12:58 +0000)]
4k_sector: Save some bytes adding a function to set bx before read_sector

Mostly of the time bx was set as phdr before calling read_sector
so add a specific function to set %bx and call read_sector
gaining 2 bytes

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years ago4k_sector: Recover 3 bytes avoid a call
Frediano Ziglio [Fri, 8 Feb 2013 12:58:33 +0000 (12:58 +0000)]
4k_sector: Recover 3 bytes avoid a call

after read_sector %edx:%eax are unused or incremented so increment
always at end gaining 3 bytes

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoversion: Welcome to the 5.02 release cycle syslinux-5.02-pre1
Matt Fleming [Thu, 7 Feb 2013 18:56:05 +0000 (18:56 +0000)]
version: Welcome to the 5.02 release cycle

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoelflink: Use CurrentDirName for initial PATH if valid
Matt Fleming [Thu, 7 Feb 2013 17:56:24 +0000 (17:56 +0000)]
elflink: Use CurrentDirName for initial PATH if valid

commit c250a42263c8 ("elflink: Set PATH to the directory containing
ldlinux.c32") made the mistake of thinking that CurrentDirName doesn't
contain useful data for PXELINUX, it may do. If a user specifies a
Path Prefix (DHCP option 210) we enter load_env32() with that path as
the current working directory. If that path is thrown away instead of
being used for PATH we may fail to load a config file as specified
with Configuration File Option (DHCP option 209).

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agorun_command: Use load_kernel() which understands labels
Matt Fleming [Thu, 7 Feb 2013 12:59:35 +0000 (12:59 +0000)]
run_command: Use load_kernel() which understands labels

load_kernel() understands how to handle labels from config files
whereas create_args_and_load() assumes that the cmdline is a COM32
file. Callers of syslinux_run_command() may want to pass labels, so
use a function that allows that.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Append BOOT_IMAGE= to kernel cmdline
Matt Fleming [Thu, 7 Feb 2013 11:28:58 +0000 (11:28 +0000)]
ldlinux: Append BOOT_IMAGE= to kernel cmdline

Some users rely on the syntax of the kernel cmdline from 4.xx and this
is currently different in 5.xx. Fix things to match the 4.xx syntax.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoload_linux: bail if no place for the real mode portion is found
H. Peter Anvin [Mon, 4 Feb 2013 19:38:07 +0000 (11:38 -0800)]
load_linux: bail if no place for the real mode portion is found

Bail in the case of no space for the real mode code.  This can happen
mostly for zImage kernels when the conventional memory ceiling is too
low.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoload_linux: additional cleanups and corner case fixing
H. Peter Anvin [Mon, 4 Feb 2013 19:35:39 +0000 (11:35 -0800)]
load_linux: additional cleanups and corner case fixing

Handle the case with a zero-length passed in initramfs for ancient
protocols, since we bothered handling it correctly for newer
protocols.

Move the setting of the command line pointer to the place where the
command line is actually placed, for clarity.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoload_linux: the command line pointer depends on real_mode_base
H. Peter Anvin [Mon, 4 Feb 2013 19:23:20 +0000 (11:23 -0800)]
load_linux: the command line pointer depends on real_mode_base

The command line pointer depends on real_mode_base, so we can't set it
up until we know where the real mode code will actually land.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoload_linux: boot protocol < 2.00 could still have a command line
H. Peter Anvin [Mon, 4 Feb 2013 19:07:11 +0000 (11:07 -0800)]
load_linux: boot protocol < 2.00 could still have a command line

The command line existed before the 2.00 boot protocol, it was the
initrd which was the new addition to that version.  Therefore, allow
the command line to be set even for the ancient kernels.

This is necessary to specify a command line for memtest86+.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoldlinux: Correct the attribute bit for foreground bright syslinux-5.01
Matt Fleming [Fri, 25 Jan 2013 14:32:38 +0000 (14:32 +0000)]
ldlinux: Correct the attribute bit for foreground bright

The foreground bright bit number is bit 3.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Convert all UsingVGA uses with display_mask_vga()
Matt Fleming [Fri, 25 Jan 2013 14:30:33 +0000 (14:30 +0000)]
ldlinux: Convert all UsingVGA uses with display_mask_vga()

Introduce display_mask_vga() which does the necessary converting of
UsingVGA into a mask to be AND'd with DisplayMask.

Also, apply TextAttribute when clearing the screen after we've seen a
form feed.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoelflink: Set PATH to the directory containing ldlinux.c32 syslinux-5.01-pre5
Matt Fleming [Fri, 25 Jan 2013 11:12:52 +0000 (11:12 +0000)]
elflink: Set PATH to the directory containing ldlinux.c32

On ISOLINUX and PXELINUX, CurrentDirName doesn't contain anything
useful when we enter load_env32(). commit 10bb72d1528b ("PATH: Use
installation directory for 'PATH'") didn't handle the case where we
don't have an installation path, or don't find ldlinux.c32 there. If
we find ldlinux.c32 in one of 'search_directories' use that directory
as the PATH string.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoNEWS: Add entries for 5.01
Matt Fleming [Thu, 24 Jan 2013 17:39:33 +0000 (17:39 +0000)]
NEWS: Add entries for 5.01

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoMerge branch 'doc-elflink-for-mfleming' of git://github.com/geneC/syslinux into elflink
Matt Fleming [Thu, 24 Jan 2013 17:23:45 +0000 (17:23 +0000)]
Merge branch 'doc-elflink-for-mfleming' of git://github.com/geneC/syslinux into elflink

Pull AsciiDoc-based documentation from Gene Cumm,

* 'doc-elflink-for-mfleming' of git://github.com/geneC/syslinux:
  txt/Makefile: make directories
  txt/: Remove COMBOOT as of 5.00; spelling; add PATH
  NEWS: add txt/
  Makefile: add txt/
  txt/: Add new AsciiDoc formatted documentation

11 years agoMerge branch 'for-upstream' of git://git.zytor.com/users/pcacjr/syslinux into elflink
Matt Fleming [Thu, 24 Jan 2013 17:22:57 +0000 (17:22 +0000)]
Merge branch 'for-upstream' of git://git.zytor.com/users/pcacjr/syslinux into elflink

Pull XFS changes from Paulo Alcantara,

 "feel free to pull my for-upstream branch on zytor. it contains the
  cache for directory blocks on XFS, ldlinux.c32 installation support
  for XFS and one trivial fix for shortform-directory lookup."

* 'for-upstream' of git://git.zytor.com/users/pcacjr/syslinux:
  extlinux: Also install ldlinux.c32 file on XFS
  xfs: Flush cache of directory blocks once done with readdir()
  xfs: Remove unnecessary free()'s
  xfs: Fix bug when listing shortform directory entries
  xfs: Add cache for directory blocks
  xfs: Make xfs_dir2_entry_name_cmp() inline
  xfs: Avoid useless malloc()'s and free()'s
  xfs: Make it more verbose on debug
  xfs: Improve error and debug printing
  xfs: Do some refactoring

11 years agoldlinux: Fix serial output and delete eprintf()
Matt Fleming [Thu, 24 Jan 2013 16:47:44 +0000 (16:47 +0000)]
ldlinux: Fix serial output and delete eprintf()

Tagging __syslinux_get_serial_info() with __constructor is pretty
useless when the global variables it uses, such as SerialPort, etc,
are assigned *after* the constructor has run. This constructor made
sense when config parsing was done by the core, but parsing is now
performed by ldlinux. We need to explicitly invoke the function to
initialise __syslinux_serial_console_info once we've parsed any config
files.

eprintf.c was introduced in commit 086d698c642f ("ldlinux: Add
eprintf() to print to VGA and serial") because printf() output wasn't
appearing on the serial console. It turns out that the above
__constructor confusion was the real bug.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Don't update UsingVGA when we just want the value
Matt Fleming [Thu, 24 Jan 2013 13:24:41 +0000 (13:24 +0000)]
ldlinux: Don't update UsingVGA when we just want the value

There was a bug introduced when this code was copied from the old 4.x
assembly implementation, we don't need to update UsingVGA everytime we
read a character, we only need its value when comparing it against the
DisplayMask.

This bug caused every other character to be displayed when only
writing to the text console, as well as other nasties such as making
syslinux_force_text_mode() think it's in VGA mode even when it's in
text mode.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Dynamically allocate cmdline buffer to avoid overflow
Matt Fleming [Thu, 24 Jan 2013 11:52:32 +0000 (11:52 +0000)]
ldlinux: Dynamically allocate cmdline buffer to avoid overflow

Also, because we no longer pass the allocated buffer to __intcall()
and friends we can use malloc() instead of lmalloc(), leaving precious
low memory for other users.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Clear screen on ASCII 12 (form feed) in DISPLAY file
Matt Fleming [Thu, 24 Jan 2013 11:07:08 +0000 (11:07 +0000)]
ldlinux: Clear screen on ASCII 12 (form feed) in DISPLAY file

The ansi code won't handle \f the way we want, so we need to
explicitly clear the screen and reset the cursor position, like the
old 4.x code.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Replace cur_module with module_current() syslinux-5.01-pre4
Matt Fleming [Wed, 23 Jan 2013 14:46:08 +0000 (14:46 +0000)]
module: Replace cur_module with module_current()

It's easy for cur_module and prev_module to get out of sync with
reality (the actual module that is running), so add module_current()
which returns the module at the head of the module_list, i.e. the
module that was loaded most recently. Better still, by using the list
we don't have to do any kind of stacking of module pointers ourselves.

This fixes a bug where cur_module contained a stale pointer (the
module had actually been unloaded) but the pointer value had since
been reallocated for a new module in spawn_load(), meaning that the
following check,

    if (!strcmp(cur_module->name, module->name))

was always going to be true, even though *no* module was actually
loaded at this point as we were reloading ldlinux.c32 from
start_ldlinux(). This could have been fixed with a NULL-assignment
after module_unload(), but using the modules_head list to detect the
current module is much cleaner.

Note that the core module loaded in load_env32() is always on the
list, therefore module_current() will always return a valid pointer.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agohdt: Move ~162K byte data object from the stack to the bss
Matt Fleming [Wed, 23 Jan 2013 13:24:36 +0000 (13:24 +0000)]
hdt: Move ~162K byte data object from the stack to the bss

A struct s_hardware is far too large to be placed onto the stack and
was causing us run past the end of the allocated stack and overwrite
the diskcache, which resulted in apparent file system corruption.

Move this hefty object into the bss.

Cc: Erwan Velu <erwanaliasr1@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Check for NULL ctors and dtors
Matt Fleming [Wed, 23 Jan 2013 13:40:24 +0000 (13:40 +0000)]
module: Check for NULL ctors and dtors

Don't dereference a NULL ctor/dtor as that can cause us to crash.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Check the return value of malloc()
Matt Fleming [Thu, 17 Jan 2013 14:50:29 +0000 (14:50 +0000)]
module: Check the return value of malloc()

Instead of blindly writing through a possible-NULL pointer, check the
return value of malloc().

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoinit: Leave mem_init() to fs_init()
Matt Fleming [Thu, 17 Jan 2013 13:15:56 +0000 (13:15 +0000)]
init: Leave mem_init() to fs_init()

Remove the superfluous call from init().

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agorealloc: Set the HEAP when splitting a block
Matt Fleming [Wed, 23 Jan 2013 10:55:14 +0000 (10:55 +0000)]
realloc: Set the HEAP when splitting a block

Failure to do so means we may put a free block in some random location
because ARENA_HEAP_GET() can return something invalid when used to
find the correct free list in __free_block().

This bug manifested as running out of available free memory.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoextlinux: Also install ldlinux.c32 file on XFS
Paulo Alcantara [Tue, 22 Jan 2013 19:12:51 +0000 (17:12 -0200)]
extlinux: Also install ldlinux.c32 file on XFS

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Flush cache of directory blocks once done with readdir()
Paulo Alcantara [Tue, 22 Jan 2013 04:13:47 +0000 (02:13 -0200)]
xfs: Flush cache of directory blocks once done with readdir()

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Remove unnecessary free()'s
Paulo Alcantara [Tue, 22 Jan 2013 03:54:09 +0000 (01:54 -0200)]
xfs: Remove unnecessary free()'s

Those freed memories are all now cached and need to get flushed at some
point.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Fix bug when listing shortform directory entries
Paulo Alcantara [Tue, 22 Jan 2013 03:19:36 +0000 (01:19 -0200)]
xfs: Fix bug when listing shortform directory entries

The xfs_fmt_local_readdir() function should call xfs_readdir_dir2_local()
instead.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Add cache for directory blocks
Paulo Alcantara [Tue, 22 Jan 2013 01:37:16 +0000 (23:37 -0200)]
xfs: Add cache for directory blocks

This cache will avoid lots of malloc() and free() calls for getting an
allocated area for directory blocks whenever listing and finding
directory entries.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Make xfs_dir2_entry_name_cmp() inline
Paulo Alcantara [Mon, 21 Jan 2013 19:42:59 +0000 (17:42 -0200)]
xfs: Make xfs_dir2_entry_name_cmp() inline

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Avoid useless malloc()'s and free()'s
Paulo Alcantara [Mon, 21 Jan 2013 19:38:10 +0000 (17:38 -0200)]
xfs: Avoid useless malloc()'s and free()'s

This patch speeds up the process of retrieving and comparing entry names
while looking up inodes.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Make it more verbose on debug
Paulo Alcantara [Mon, 21 Jan 2013 18:21:51 +0000 (16:21 -0200)]
xfs: Make it more verbose on debug

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Improve error and debug printing
Paulo Alcantara [Mon, 21 Jan 2013 18:03:00 +0000 (16:03 -0200)]
xfs: Improve error and debug printing

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoxfs: Do some refactoring
Paulo Alcantara [Mon, 21 Jan 2013 17:56:48 +0000 (15:56 -0200)]
xfs: Do some refactoring

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
11 years agoMerge branch 'com32lib_spotless_for_mfleming' of git://github.com/geneC/syslinux...
Matt Fleming [Mon, 21 Jan 2013 14:53:41 +0000 (14:53 +0000)]
Merge branch 'com32lib_spotless_for_mfleming' of git://github.com/geneC/syslinux into elflink

Pull clean up patch from Gene Cumm,

* 'com32lib_spotless_for_mfleming' of git://github.com/geneC/syslinux:
  com32/lib: delete *.c32 on key target

11 years agopxe: Add PXELINUX-specific symbols to symbol whitelist
Matt Fleming [Mon, 21 Jan 2013 14:16:12 +0000 (14:16 +0000)]
pxe: Add PXELINUX-specific symbols to symbol whitelist

We need to allow PXELINUX to link with required symbols at runtime
otherwise, when executing prdhcp.c32, the user will be presented with
the following message,

  Error: An undefined symbol was referenced

Add pxe_call, dns_resolv and unload_pxe to the symbol whitelist.

Reported-by: Gene Cumm <gene.cumm@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agocom32/lib: delete *.c32 on key target
Gene Cumm [Sun, 20 Jan 2013 12:58:39 +0000 (07:58 -0500)]
com32/lib: delete *.c32 on key target

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
11 years agocore/lzo: move LZO back to uncompressed section
H. Peter Anvin [Fri, 18 Jan 2013 04:38:42 +0000 (20:38 -0800)]
core/lzo: move LZO back to uncompressed section

The LZO decompressor really can't live in the compressed part of the
core, for some odd reason.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agotxt/Makefile: make directories
Gene Cumm [Thu, 17 Jan 2013 04:49:32 +0000 (23:49 -0500)]
txt/Makefile: make directories

11 years agotxt/: Remove COMBOOT as of 5.00; spelling; add PATH
Gene Cumm [Tue, 15 Jan 2013 02:38:02 +0000 (21:38 -0500)]
txt/: Remove COMBOOT as of 5.00; spelling; add PATH

Also changing markup for AsciiDoc

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
11 years agoNEWS: add txt/
Gene Cumm [Fri, 7 Dec 2012 04:43:57 +0000 (23:43 -0500)]
NEWS: add txt/

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
11 years agoMakefile: add txt/
Gene Cumm [Fri, 7 Dec 2012 04:43:41 +0000 (23:43 -0500)]
Makefile: add txt/

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
11 years agotxt/: Add new AsciiDoc formatted documentation
Gene Cumm [Fri, 7 Dec 2012 04:43:01 +0000 (23:43 -0500)]
txt/: Add new AsciiDoc formatted documentation

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
11 years agoelf: remove long-since-obsolete shallow module machinery
H. Peter Anvin [Fri, 18 Jan 2013 00:52:20 +0000 (16:52 -0800)]
elf: remove long-since-obsolete shallow module machinery

Meant to handle symbols exported from the core, but we just
pregenerate the dynamic section instead.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agocore: switch LZO decompressor to "fast safe" version
H. Peter Anvin [Fri, 18 Jan 2013 00:16:31 +0000 (16:16 -0800)]
core: switch LZO decompressor to "fast safe" version

Switch LZO decompressor to the "fast safe" version (and bump LZO
source to version 2.06).  This allows us to use that decompressor for
module compression later without carrying another decompressor.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agocore/fs: remove some stale functions, inode refcount debug
H. Peter Anvin [Fri, 18 Jan 2013 00:02:46 +0000 (16:02 -0800)]
core/fs: remove some stale functions, inode refcount debug

Remove some stale (16-bit compatibility) functions in fs.c.

Add some debugging for inode refcounts.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agobios.h: add missing dependent #include
H. Peter Anvin [Thu, 17 Jan 2013 22:18:07 +0000 (14:18 -0800)]
bios.h: add missing dependent #include

io_delay() defined in bios.h depends on outb() defined in <sys/io.h>.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoRename libcom32gpl.c32 to libgpl.c32
H. Peter Anvin [Thu, 17 Jan 2013 18:59:18 +0000 (10:59 -0800)]
Rename libcom32gpl.c32 to libgpl.c32

Conform to 8.3 filenames for essential files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoRename libutil_com.c32 to libutil.c32
H. Peter Anvin [Thu, 17 Jan 2013 18:57:17 +0000 (10:57 -0800)]
Rename libutil_com.c32 to libutil.c32

Conform to 8.3 filenames for essential files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoAlways strip all the modules
H. Peter Anvin [Thu, 17 Jan 2013 18:54:40 +0000 (10:54 -0800)]
Always strip all the modules

Always strip the modules; they are too big unstripped.  Specifically,
we generate unstripped *.elf files, and then convert them to
stripped *.c32 files.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agodos: obtain the executable pathname, cleanups
H. Peter Anvin [Thu, 17 Jan 2013 17:34:59 +0000 (09:34 -0800)]
dos: obtain the executable pathname, cleanups

DOS actually does provide the fully qualified pathname to the
executable, which would be useful to make ldlinux.c32 data rather than
live inside the executable itself -- it has gotten too large.

Also, move some DOS internals -- inline functions only used inside the
dos directory -- out of libinstaller.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
11 years agoldlinux: Perform chdir() before parsing config syslinux-5.01-pre3
Matt Fleming [Wed, 16 Jan 2013 11:14:59 +0000 (11:14 +0000)]
ldlinux: Perform chdir() before parsing config

The old 4.x behaviour for handling CONFIG directives of the form,

    CONFIG foo.cfg /bar

was to lookup the absolute pathname of foo.cfg, then chdir to /bar and
finally to parse foo.cfg. The 5.x behaviour reversed the chdir and
parsing steps. This meant if foo.cfg's contents were simply,

    INCLUDE say.txt

4.x would include /bar/say.txt and 5.x would include
/boot/syslinux/say.txt (assuming the current working directory was
/boot/syslinux).

What's even worse is that because of the way 'config_cwd' is used in
5.x we'd actually perform the chdir() operation after the first
INCLUDE in foo.cfg, e.g.

   INCLUDE say.txt
   INCLUDE say.txt

would include /boot/syslinux/say.txt and /bar/say.txt, respectively.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Check return value of malloc()
Matt Fleming [Tue, 15 Jan 2013 14:57:45 +0000 (14:57 +0000)]
module: Check return value of malloc()

And return NULL after printing an appropriate error message if the
call failed.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Strip whitespace from LABEL directive
Matt Fleming [Tue, 15 Jan 2013 13:03:51 +0000 (13:03 +0000)]
ldlinux: Strip whitespace from LABEL directive

Any LABEL directive arguments shouldn't include whitespace
characters. If whitespace characters are needed use MENU LABEL.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoPXELINUX: Fix IPAPPEND to include BOOTIF and SYSUUID syslinux-5.01-pre2
Matt Fleming [Mon, 14 Jan 2013 12:16:38 +0000 (12:16 +0000)]
PXELINUX: Fix IPAPPEND to include BOOTIF and SYSUUID

commit 14531c47bc95 ("core: Delete code that is duplicated in
ldlinux") erroneously deleted the BOOTIFStr and SYSUUIDStr entries
from the PXELINUX-version of IPAppends, meaning that IPAPPEND 3 and
IPAPPEND 4 didn't append the corresponding strings to the command
line.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoisolinux: Update LBA in getlinsec loop
Matt Fleming [Thu, 10 Jan 2013 21:33:32 +0000 (21:33 +0000)]
isolinux: Update LBA in getlinsec loop

We need to increment the Logical Block Address in eax by the number of
sectors we passed to getlinsec after every invocation, otherwise we'll
start with the same sector everytime.

This bug was discovered when booting an isohybrid image, which failed
to boot after printing the following error,

    "Image checksum error, sorry..."

because the isolinux.bin was bigger than 32K, and thus invoked the
getlinsec loop that reads the file in chunks.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Allow .c32 files to execute themselves
Matt Fleming [Thu, 10 Jan 2013 13:39:50 +0000 (13:39 +0000)]
module: Allow .c32 files to execute themselves

Historically, .c32 files had to explicitly link against ldlinux.c32 in
order to use its exported symbols. This lead to the undesirable
situation during module dependency resolution where loading,
e.g. menu.c32, would cause ldlinux.c32 to be reloaded, thus
re-executing its main() function and dropping the user at a prompt
instead of executing menu.c32.

commit 1357b7e62706 ("elflink: Don't reload the current EXEC_MODULE
module") was the solution to this problem, since you don't need to
reload a module to link against it's symbols. Unfortunately, while
this commit was intended to stop ldlinux.c32 being reloaded, it also
broke the use case where a .c32 wants to load itself, e.g. when
vesamenu.c32 wants to execute vesamenu.c32 with a different config.

Luckily, modules no longer need to include ldlinux.c32 in their
dependency list, since ldlinux.c32 is *always* loaded and any symbols
can be automatically resolved. Which means that the check in
spawn_load() can be deleted.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoextlinux: Fix installation subdirectory patching
Matt Fleming [Thu, 10 Jan 2013 11:47:33 +0000 (11:47 +0000)]
extlinux: Fix installation subdirectory patching

Commit a126f17f663c ("EXTLINUX: Initial XFS filesystem support") broke
the code that inserts the installation subdirectory into the Extended
Patch Area (EPA). The EPA entry is used to set the initial working
directory on boot.

This caused boot failures for users that chose an install directory
other than /boot/syslinux (technically, it failed for any path not in
'search_directories' in load_env32()) due to ldlinux.c32 failing to
load because the initial working directory was not set correctly.

Cc: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoextlinux: Make sure ldlinux.sys file is installed
Paulo Alcantara [Mon, 7 Jan 2013 08:14:47 +0000 (06:14 -0200)]
extlinux: Make sure ldlinux.sys file is installed

Due to delayed allocation feature on XFS filesystems, a write is not
guaranteed to flushed out to the underlying file system after crash or
something else - so we need to make sure that ldlinux.sys is installed
correctly in the mounted filesystem.

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomenugen: Make it compatible with Py3k
Paulo Alcantara [Sun, 6 Jan 2013 20:36:17 +0000 (18:36 -0200)]
menugen: Make it compatible with Py3k

Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agocore/kaboom.c: Export __bad_SEG()
Matt Fleming [Tue, 8 Jan 2013 15:37:38 +0000 (15:37 +0000)]
core/kaboom.c: Export __bad_SEG()

We need to add __bad_SEG() to the symbol export whitelist, otherwise
ldlinux.c32 will fail to load if compiled with -DDEBUG=1 due to not
being able to resolve __bad_SEG().

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoversion: Bump minor number and year syslinux-5.01-pre1
Matt Fleming [Tue, 8 Jan 2013 12:12:32 +0000 (12:12 +0000)]
version: Bump minor number and year

Welcome to the 5.01 development cycle and 2013.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Dynamically alloc memory for kernel and initrd filenames
Matt Fleming [Fri, 4 Jan 2013 19:16:39 +0000 (19:16 +0000)]
ldlinux: Dynamically alloc memory for kernel and initrd filenames

Absolutely no bounds checking is performed when copying filenames to
'cmdline_buf' and 'initrd_name' which means that sufficiently long
strings will scribble over the stack. At best, the files will simply
fail to load because the name is garbled.

Allocate space for the cmdline at runtime to avoid these overflow
problems.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Don't delete ldlinux.c32 with 'make clean'
Matt Fleming [Fri, 4 Jan 2013 11:33:21 +0000 (11:33 +0000)]
ldlinux: Don't delete ldlinux.c32 with 'make clean'

The documented command sequence for distributions wishing to package a
Syslinux release is,

 make clean
 make installer

Unfortunately, becaues ldlinux.c32 is deleted by 'make clean' the
installer target fails like so,

make[1]: *** No rule to make target `../com32/elflink/ldlinux/ldlinux.c32', needed by `ldlinuxc32_bin.c'.  Stop.
make: *** [installer] Error 2

Follow the example set by core/Makefile for ldlinux.sys, etc and add
any build files that are required by the installers to
$(BTARGET). $(BTARGET) only gets deleted when running 'make spotless'.

Reported-by: László Házy <hazy_l@yahoo.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoelflink: set the sonames of shared libraries
H. Peter Anvin [Thu, 3 Jan 2013 17:29:51 +0000 (09:29 -0800)]
elflink: set the sonames of shared libraries

Set the sonames of shared libraries to the filename, so we don't end
up with full pathnames embedded in the files.

11 years agoDelete 16-bit COMBOOT support syslinux-5.00
Matt Fleming [Thu, 6 Dec 2012 10:13:41 +0000 (10:13 +0000)]
Delete 16-bit COMBOOT support

16-bit COMBOOT files are no longer supported by Syslinux in 5.00 so
delete all references and change any 32-bit COMBOOT image references
to mention ELF instead.

Some of the COMBOOT stuff is still used internally so we can't nuke
core/comboot.inc yet, but that will disappear in a future release.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoSymbol export whitelist
Matt Fleming [Tue, 4 Dec 2012 21:17:47 +0000 (21:17 +0000)]
Symbol export whitelist

Before modules were dynamically loaded the boundary between GPL and
non-GPL code was implicit because of the separate link domains for
each module. With dynamic modules we need an explicit whitelist of
core symbols that non-GPL code can link against at runtime without
needing to be re-licensed under the GPL.

Mark such symbols with __export, so that it is explicitly clear which
symbols in the core can be linked against by non-GPL code.

Reduce the visibility of symbols in both the core and ldlinux.c32 with
-fvisibility=hidden. __export changes the visibility to 'default'.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agocore: Fix 'NoHalt'
Matt Fleming [Wed, 5 Dec 2012 09:20:38 +0000 (09:20 +0000)]
core: Fix 'NoHalt'

Use the same variable in idle.c and ldlinux.c32.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agocom32: Delete unused malloc.c and friends
Matt Fleming [Wed, 5 Dec 2012 13:28:38 +0000 (13:28 +0000)]
com32: Delete unused malloc.c and friends

The memory alloc files haven't been referenced since commit
880f67714ec0 ("elflink: remove the malloc.c/free.c/realloc.c/zalloc.c
from com32"). They live in the core now.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoReduce the number of global variables
Matt Fleming [Tue, 4 Dec 2012 22:00:13 +0000 (22:00 +0000)]
Reduce the number of global variables

In preparation for strictly limiting the list of variables that are
exported (global) in the core, delete any unused variables, rewrite
variable declarations in C that are not referenced by asm and delete
files that are no longer included in other asm files.

Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agocomboot: Mark API functions obsolete
Matt Fleming [Tue, 4 Dec 2012 21:51:46 +0000 (21:51 +0000)]
comboot: Mark API functions obsolete

Starting with Syslinux 5.00 the COMBOOT API is obsolete and should not
be used by any modules. It is still used internally for some things,
such as the ADV code in ldlinux.c32, but that will change in the
future.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agodoc: Further explanation for the PATH directive and lookup rules
Matt Fleming [Tue, 4 Dec 2012 13:42:24 +0000 (13:42 +0000)]
doc: Further explanation for the PATH directive and lookup rules

The PATH directive can be quite confusing when coupled with the fact
that the current working directory is always searched first when
opening files.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoRevert "menu: Inherit parent menu title"
Matt Fleming [Tue, 4 Dec 2012 12:13:48 +0000 (12:13 +0000)]
Revert "menu: Inherit parent menu title"

This reverts commit 6387f043f7f870e4f0b402dae0b921d99eb82c39.

We got reports of this change causing regressions. The reverted commit
only goes half way to providing proper parent menu title inheritance,
and breaks other configs where the menu label or submenu tagname are
used for the title.

Reported-by: Ady <ady-sf@hotmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Use get_msg_file() for F-keys
Matt Fleming [Tue, 4 Dec 2012 12:02:39 +0000 (12:02 +0000)]
ldlinux: Use get_msg_file() for F-keys

The file that we display with the F-keys may contain background or
foreground color codes and so needs to be interpreted by
get_msg_file() instead of just printing the color codes as ascii to
the screen with cat_file().

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Remove default bold attribute typo
Matt Fleming [Tue, 4 Dec 2012 11:56:04 +0000 (11:56 +0000)]
ldlinux: Remove default bold attribute typo

commit 82cbb1bd4133 ("ldlinux: Move DISPLAY file handling out of the
core") introduced a typo where the foreground color was always bold
when displaying a DISPLAY file.

Reported-by: Ady <ady-sf@hotmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoCLI: Don't always start the CLI at column 0
Matt Fleming [Tue, 4 Dec 2012 11:50:19 +0000 (11:50 +0000)]
CLI: Don't always start the CLI at column 0

If we print files with no newline then it looks better if the CLI
prompt is printed immediately after the file content, rather than
erasing the line and printing prompt at column 0.

This mainly affects files with one line of text and no newline
character.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Move DISPLAY file handling out of the core syslinux-5.00-pre13
Matt Fleming [Mon, 3 Dec 2012 13:30:36 +0000 (13:30 +0000)]
ldlinux: Move DISPLAY file handling out of the core

The code that handles the DISPLAY directive was writing directly to
the BIOS VGA page with __intcall(0x10). This caused corruption
problems on the screen because the ansi library code was also writing
to the screen.

The correct way to fix this is to always use the ansi library code
(via printf()) instead of going behind its back and using separate
code paths to write to the screen.

Reported-by: Ady <ady-sf@hotmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agostdio: Fix unhexchar() for hex digits > 9
Matt Fleming [Mon, 3 Dec 2012 13:27:11 +0000 (13:27 +0000)]
stdio: Fix unhexchar() for hex digits > 9

There was a typographical error in commit 9f51b69d7c050 ("core:
Reimplement lots asm code in C") which re-wrote the asm implementation
of unhexchar() in C. We should be adding 10, not subtracting to get
the equivalent decimal integer. Also be explicit about the sign of
'data' and 'num'.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoMerge branch 'searchdir_leak-5' of git://git.zytor.com/users/sha0/syslinux into elfli...
Matt Fleming [Fri, 30 Nov 2012 13:40:32 +0000 (13:40 +0000)]
Merge branch 'searchdir_leak-5' of git://git.zytor.com/users/sha0/syslinux into elflink-searchdir-leak

Pull a change that fixes a resource leak from Shao Miller,

* 'searchdir_leak-5' of git://git.zytor.com/users/sha0/syslinux:
  fs: Fix searchdir resource leak

11 years agoPATH: Use installation directory for 'PATH'
Matt Fleming [Fri, 30 Nov 2012 09:50:53 +0000 (09:50 +0000)]
PATH: Use installation directory for 'PATH'

Files in the installation directory should be able to be executed
(along with their dependencies) from any directory in the file
hierarchy. Using the installation directory as the default value for
'PATH' is the most sensible way to do this.

The PATH config directive still allows other directories to be
appended to the 'PATH' variable, which is useful when there are other
directories containing modules.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Don't try reloading ldlinux.c32 unless it's likely to succeed
Matt Fleming [Thu, 29 Nov 2012 22:52:42 +0000 (22:52 +0000)]
ldlinux: Don't try reloading ldlinux.c32 unless it's likely to succeed

If we can't access ldlinux.c32 with findpath(), reloading it isn't
going to work so don't unload it or any of the other modules. Instead
return control to the caller.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Fix incorrect list_entry() use
Matt Fleming [Thu, 29 Nov 2012 22:40:46 +0000 (22:40 +0000)]
module: Fix incorrect list_entry() use

Correct the bogus use of list_entry() that was introduced in commit
8f1c64acf9c6 ("module: Stop silently failing to load dependency
modules").

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agofs: Fix searchdir resource leak
Shao Miller [Fri, 2 Nov 2012 15:59:10 +0000 (11:59 -0400)]
fs: Fix searchdir resource leak

This is a significant rewrite of the generic lookup logic inside
core/fs/fs.c's searchdir function.  Previously, there was a
memory leak if a path involved multiple directories.  After a
sufficiently large number of invocations, this could be observed.

Reported-by: Ady <ady-sf@hotmail.com>
Signed-off-by: Shao Miller <sha0.miller@gmail.com>
11 years agoCLI: Delete 'temp_cmdline' and put 'cmdline' on the stack
Matt Fleming [Thu, 29 Nov 2012 16:55:33 +0000 (16:55 +0000)]
CLI: Delete 'temp_cmdline' and put 'cmdline' on the stack

We don't need to preserve the contents of 'cmdline' across calls to
edit_cmdline(). In fact, doing so causes things like the TAB key to
not function properly because the previous command is used as a prefix
to print_labels(), as though the user had typed it explicitly before
hitting TAB.

Delete 'temp_cmdline' because it no longer serves a purpose.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Stop silently failing to load dependency modules syslinux-5.00-pre12
Matt Fleming [Thu, 29 Nov 2012 11:35:28 +0000 (11:35 +0000)]
module: Stop silently failing to load dependency modules

We should be checking the return value of spawn_load() when loading a
module's dependencies and printing some kind of an error message if
they fail to load (for instance if the file is missing) and returning
an error to the caller.

Track the most recently loaded module in 'head' before we begin
loading dependencies. That way we can unload any dependencies in the
error path that were successfully loaded.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Complain to user on failure to perform file operations
Matt Fleming [Thu, 29 Nov 2012 09:34:18 +0000 (09:34 +0000)]
ldlinux: Complain to user on failure to perform file operations

If we fail to chdir or to execute a COM32 file we should inform the
user so that they can debug the problem. We don't currently print
anything if the user tries to execute a regular file, such as a config
file, as an COM32 image.

We also shouldn't be returning the exit value of the module from
spawn_load(), because we have no way of doing anything useful with it,
and just because a main() function returns -1 doesn't mean it failed
to run. Modules need to take care of printing any error messages
themselves.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Append '/' to PATH strings if missing
Matt Fleming [Thu, 29 Nov 2012 09:06:41 +0000 (09:06 +0000)]
module: Append '/' to PATH strings if missing

We shouldn't be appending a filename to any path string that isn't
terminated by a '/', otherwise we end up searching for files like
'/isolinuxpwd.c32'

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoldlinux: Only append missing filename extensions
Matt Fleming [Thu, 29 Nov 2012 08:47:15 +0000 (08:47 +0000)]
ldlinux: Only append missing filename extensions

Don't append an extension like ".c32" if the command already has one!
This bug lead to "config.c32" being executed as "config.c32.c32" with
the below config snippet,

    LABEL config
        COM32 config.c32 /configs/isolinux.cfg

Reported-by: Ady <ady-sf@hotmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoMerge branch 'coverity' into elflink syslinux-5.00-pre11
Matt Fleming [Tue, 27 Nov 2012 21:13:45 +0000 (21:13 +0000)]
Merge branch 'coverity' into elflink

11 years agocore/elflink: Fix off-by-one error
Matt Fleming [Tue, 27 Nov 2012 20:12:58 +0000 (20:12 +0000)]
core/elflink: Fix off-by-one error

We need to remember to allocate space for the terminating NULL in
create_args_and_load() otherwise we will write a NUL-byte past the
bounds of 'argv[]' to some random part of the stack.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Fix off-by-one error in findpath()
Matt Fleming [Tue, 27 Nov 2012 16:25:37 +0000 (16:25 +0000)]
module: Fix off-by-one error in findpath()

We need to make sure that 'path' still has enough space to write the
trailing NUL-byte. Without this patch it's possible to write a
NUL-byte past the end of the on-stack buffer.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agomodule: Fix memory leak in spawn_load()
Matt Fleming [Tue, 27 Nov 2012 16:19:17 +0000 (16:19 +0000)]
module: Fix memory leak in spawn_load()

If for some reason we fail to load a module then we need to free the
memory allocated to that module.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agopxe: Don't leak inode on timeout
Matt Fleming [Tue, 27 Nov 2012 16:11:26 +0000 (16:11 +0000)]
pxe: Don't leak inode on timeout

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoscreensize: Dereference pointers when checking cols/rows
Matt Fleming [Tue, 27 Nov 2012 16:03:36 +0000 (16:03 +0000)]
screensize: Dereference pointers when checking cols/rows

Dereference 'rows' and 'cols' to check whether the data they point to
is zero, which would indicate the screen size is bogus, instead of
checking if they point to NULL.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agohdt-cli: Correct malloc() size argument
Matt Fleming [Fri, 16 Nov 2012 14:23:45 +0000 (14:23 +0000)]
hdt-cli: Correct malloc() size argument

We need to be allocating sizeof(char *) (4) not sizeof(char) (1) for
'new_argv'.

Cc: Erwan Velu <erwanaliasr1@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
11 years agoMerge branch 'xfs-for-hpa' of git://zytor.com/users/pcacjr/syslinux into merge/elflin...
Matt Fleming [Tue, 27 Nov 2012 18:38:18 +0000 (18:38 +0000)]
Merge branch 'xfs-for-hpa' of git://zytor.com/users/pcacjr/syslinux into merge/elflink/xfs

Pull XFS filesystem driver from Paulo Alcantara,

* 'xfs-for-hpa' of git://zytor.com/users/pcacjr/syslinux: (60 commits)
  xfs: Fix the way we check di_mode of an inode
  xfs: Cleanup previous commit
  xfs: Add xfs_readlink()
  xfs: Cleanup and remove some trailing whitespaces
  xfs: Add XFS_DINODE_FMT_BTREE support in xfs_next_extent()
  xfs: Cleanup and remove some trailing whitespaces
  xfs: Rework xfs_dir2_get_right_blk()
  xfs: cleanup unused structure
  xfs: Remove some trailing whitespaces
  xfs: Add full B+tree search support in xfs_dir2_node_find_entry()
  xfs: Add xfs_fmt_btree_find_entry()
  xfs: Fix memory leak in xfs_dir2_node_find_entry() function
  xfs: Cleanup xfs_readdir_dir2_leaf() function
  xfs: Implement xfs_readdir_dir2_node() function
  EXTLINUX: Add sanity check for XFS filesystems
  xfs: Add xfs_fmt_local_readdir() function
  xfs: Add xfs_fmt_local_find_entry() function
  xfs: Move readdir functions to another source file
  xfs: Remove trailing whitespace in xfs_dir2_isleaf() function
  xfs: Move dir2 functions to another source file
  ...

Conflicts:
extlinux/main.c

11 years agoldlinux: Reset the console whenever we execute a module
Matt Fleming [Tue, 27 Nov 2012 15:01:12 +0000 (15:01 +0000)]
ldlinux: Reset the console whenever we execute a module

Each module expects the console to start in text mode and will make
explicit calls to openconsole() when another console is required,
e.g. in vesamenu.c32. This mimics the behaviour found in 4.0x.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>