[syslinux] config_cwd can be killed?

Phil Pokorny ppokorny at penguincomputing.com
Sun Mar 5 17:17:17 PST 2017


I asked before about config_cwd and after some more digging, it looks
like it could be removed...

Specifically, the documentation
http://www.syslinux.org/wiki/index.php?title=Config#CONFIG says:

----------
* CONFIG config_file [new_WD]

Load a new configuration file. The new configuration file is read, the
Working Directory is optionally changed (if specified via an optional
second parameter), and then the new configuration file is parsed.

If new_WD is not specified, then the Current Working Directory is
maintained, unchanged.

The Working Directory may be different from the path to the config file.
----------

But looking at the actual code, it doesn't *read* so much as just
*open* the config file.

So presumably, the open() implementations (by filesystem type?) would
look for the config file with a relative filename in the old current
directory and not the new current directory.

Is that a useful or necessary feature?

Is Matt Fleming (author of the original code) still lurking on this
list to explain?

Or could IMAGE_TYPE_CONFIG set the directory before processing the config file.

Both menu.c32 and ldlinux.EXT have parse_configs() functions that they
send the argc/argv list they receive.  Both functions handle multiple
arguments as multiple config files to be processed (with either
parse_one_config() or parse_main_config()).  The documentation
(http://www.syslinux.org/wiki/index.php?title=Menu#Alternative_configuration_file)
shows examples of this for the menu.c32 case.

But this highlights that we have two different config file parsers
with different behavior.  I haven't looked closely to completely
confirm but, menu.c32 probably doesn't handle INCLUDE directives and
LDLINUX doesn't support the "~" shorthand for config file names.

What about if the CONFIG (LDLINUX)  and MENU.c32 (and gfxboot.c32?)
modules looked for arguments like "cwd=path/to/dir" (cwd relative and
possibly including .. to drop parent directories?) or
"cwd=/abs/path/to/dir" to change directories at that point in the
parsing of the config files.  (Similar to the way initrd=filename is
special for KERNEL types)  Then we wouldn't need this config_cwd
private buffer and we could delete it and save some bytes of memory
and simplify code.

Phil P.

-- 
Philip Pokorny, RHCE
Chief Technology Officer
PENGUIN COMPUTING, Inc
www.penguincomputing.com

Changing the world through technical innovation


More information about the Syslinux mailing list