]> git.ozlabs.org Git - petitboot/log
petitboot
10 years agoui/ncurses: Allow boot editor sysinfo updates
Jeremy Kerr [Tue, 19 Nov 2013 05:08:35 +0000 (16:08 +1100)]
ui/ncurses: Allow boot editor sysinfo updates

We may start a boot editor (via 'New') before we have the sysinfo. To
allow this, we redraw the device select.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add widgetset_set_window
Jeremy Kerr [Wed, 20 Nov 2013 03:18:35 +0000 (14:18 +1100)]
ui/ncurses: Add widgetset_set_window

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add widget_select_drop_options
Jeremy Kerr [Wed, 20 Nov 2013 03:17:31 +0000 (14:17 +1100)]
ui/ncurses: Add widget_select_drop_options

We want to be able to re-set the options in a select widget.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Implement intra-field scrolling
Jeremy Kerr [Tue, 19 Nov 2013 03:20:30 +0000 (14:20 +1100)]
ui/ncurses: Implement intra-field scrolling

Now that we can calculate the focus within a field, ensure that the
focussed-element remains scrolled.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses/widgets: Add widget focus offset query
Jeremy Kerr [Tue, 19 Nov 2013 03:18:28 +0000 (14:18 +1100)]
ui/ncurses/widgets: Add widget focus offset query

When we have widgets that are larger than the screen, we'd like to
scroll to the currently-focussed component of that widget.

This change introduces a widget_focus_y function, which returns the y
offset of the field's focus.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Draw boot editor into a scrollable pad
Jeremy Kerr [Tue, 19 Nov 2013 00:52:49 +0000 (11:52 +1100)]
ui/ncurses: Draw boot editor into a scrollable pad

Like the config editor, draw the boot editor into a pad instead of
directly into the sub window. This means that long device lists will be
handled correctly.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Make boot editor paths relative to device
Jeremy Kerr [Sun, 17 Nov 2013 09:54:46 +0000 (20:54 +1100)]
ui/ncurses: Make boot editor paths relative to device

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add device selector to boot editor
Jeremy Kerr [Sun, 17 Nov 2013 08:36:55 +0000 (19:36 +1100)]
ui/ncurses: Add device selector to boot editor

Rather than expecting users to enter full (prefixed) mount paths, add a
select widget to pick a device, and we automatically add the prefix when
the form is submitted.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses/widgets: Add n_options check to widget_select_get_value
Jeremy Kerr [Sun, 17 Nov 2013 08:35:49 +0000 (19:35 +1100)]
ui/ncurses/widgets: Add n_options check to widget_select_get_value

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Split boot editor layout
Jeremy Kerr [Sun, 17 Nov 2013 05:30:47 +0000 (16:30 +1100)]
ui/ncurses: Split boot editor layout

We want to make the boot editor dynamic later, so split the widget
layout from the widget creation.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Make boot editor API consistent with config & sysinfo screens
Jeremy Kerr [Sun, 17 Nov 2013 03:04:08 +0000 (14:04 +1100)]
ui/ncurses: Make boot editor API consistent with config & sysinfo screens

The boot-editor API is a little more exposed than it needs to be: the
boot_editor struct does not need to be available to other files, and the
init function and on_exit functions differ from those provided for the
config and sysinfo screens.

This change unifies the boot_editor API with those for the other
screens.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: remove boot_editor_attr_field
Jeremy Kerr [Fri, 15 Nov 2013 07:34:07 +0000 (18:34 +1100)]
ui/ncurses: remove boot_editor_attr_field

The widgetset code handles these attributes now.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add block devices to system info screen
Jeremy Kerr [Fri, 15 Nov 2013 04:56:39 +0000 (15:56 +1100)]
ui/ncurses: Add block devices to system info screen

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: populate sysinfo with block devices
Jeremy Kerr [Fri, 15 Nov 2013 04:23:54 +0000 (15:23 +1100)]
discover: populate sysinfo with block devices

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoprotocol: Add block device information to system info
Jeremy Kerr [Fri, 15 Nov 2013 04:13:41 +0000 (15:13 +1100)]
protocol: Add block device information to system info

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Use pxeconffile for udhcpc option name
Jeremy Kerr [Tue, 19 Nov 2013 04:25:43 +0000 (15:25 +1100)]
discover: Use pxeconffile for udhcpc option name

The patch that went upstream for udhcpc's option 209 handling uses the
option name 'pxeconffile' rather than 'conffile', and it was added as a
non-default option:

  http://git.busybox.net/busybox/commit/?id=d3092c99ae90f

This change uses the new name, and explicilty requests this option.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils/pb-console: Exit after running getty in detached state
Jeremy Kerr [Fri, 22 Nov 2013 01:36:58 +0000 (09:36 +0800)]
utils/pb-console: Exit after running getty in detached state

... otherwise we'll try and bring the UI up on the current tty too.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Fix pad size check
Jeremy Kerr [Tue, 19 Nov 2013 02:23:10 +0000 (13:23 +1100)]
ui/ncurses: Fix pad size check

We need the y-coord, not x.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Don't mess with prog_mode in cui_boot
Jeremy Kerr [Fri, 15 Nov 2013 01:57:13 +0000 (12:57 +1100)]
ui/ncurses: Don't mess with prog_mode in cui_boot

The discover_client_boot call is asynchronous, so setting and resetting
prog_mode doesn't gain us anything.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoautomake: Fixups for maintainer-clean
Geoff Levand [Mon, 18 Nov 2013 22:58:48 +0000 (14:58 -0800)]
automake: Fixups for maintainer-clean

Signed-off-by: Geoff Levand <geoff@infradead.org>
10 years agolib/system: Don't leak in pb_mkdir_recursive
Jeremy Kerr [Thu, 14 Nov 2013 05:18:59 +0000 (16:18 +1100)]
lib/system: Don't leak in pb_mkdir_recursive

If the mkdir fails, we'll exit without freeing str.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Use mkstemp rather than tempnam
Jeremy Kerr [Thu, 14 Nov 2013 03:54:34 +0000 (14:54 +1100)]
discover: Use mkstemp rather than tempnam

We're getting warnings from some compilers about tempnam being unsafe.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils/pb-console: reset after UI exit
Jeremy Kerr [Fri, 25 Oct 2013 01:58:00 +0000 (09:58 +0800)]
utils/pb-console: reset after UI exit

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses/menu: Allow space to select menu items
Jeremy Kerr [Fri, 8 Nov 2013 02:03:30 +0000 (10:03 +0800)]
ui/ncurses/menu: Allow space to select menu items

To keep consistent with buttons, which also accept space.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add descriptive text for configuration editor
Jeremy Kerr [Wed, 6 Nov 2013 06:05:57 +0000 (14:05 +0800)]
ui/ncurses: Add descriptive text for configuration editor

This change adds:
 - 'seconds' to the timeout text entry
 - examples to the ip/mask, gateway and DNS text entries

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses/nc-config: Draw config form into a scrollable pad
Jeremy Kerr [Fri, 25 Oct 2013 08:06:50 +0000 (16:06 +0800)]
ui/ncurses/nc-config: Draw config form into a scrollable pad

Currently, when the config form is larger than the screen size, the form
fails to draw.

This change draws the config screen onto a pad instead, which we can
scroll.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agonui/ncurses: Allow config screen updates
Jeremy Kerr [Fri, 25 Oct 2013 01:19:35 +0000 (09:19 +0800)]
nui/ncurses: Allow config screen updates

We may receive configuration (or sysinfo) data after the configuration
screen has been displayed. Implement config_screen_update and redraw the
widgetset when new config data arrives.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add help for the DNS option
Jeremy Kerr [Thu, 24 Oct 2013 08:57:38 +0000 (16:57 +0800)]
ui/ncurses: Add help for the DNS option

It's not obvious why it's there when we're configuring DHCP.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Populate configuration interface with current defaults
Jeremy Kerr [Thu, 24 Oct 2013 08:51:44 +0000 (16:51 +0800)]
ui/ncurses: Populate configuration interface with current defaults

Sets the default values of configuration widgets to the values found in
t he current config.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Parse configuration form & send to server
Jeremy Kerr [Thu, 24 Oct 2013 06:02:49 +0000 (14:02 +0800)]
ui/ncurses: Parse configuration form & send to server

This change implements the configuration save action, when the user
submits the nc-config form.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add network configuration
Jeremy Kerr [Thu, 24 Oct 2013 03:05:34 +0000 (11:05 +0800)]
ui/ncurses: Add network configuration

Add network configuration parameters. This requires a somewhat-dynamic
layout, as the fields shown depend on earlier configuration.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add basic config editor
Jeremy Kerr [Mon, 21 Oct 2013 10:59:12 +0000 (18:59 +0800)]
ui/ncurses: Add basic config editor

This change adds a simple configuration editor to the ncurses UI.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Receive config messages
Jeremy Kerr [Fri, 18 Oct 2013 03:45:03 +0000 (11:45 +0800)]
ui/ncurses: Receive config messages

We just store the config in the cui for now.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use nc-widgets for boot editor
Jeremy Kerr [Mon, 21 Oct 2013 10:55:06 +0000 (18:55 +0800)]
ui/ncurses: Use nc-widgets for boot editor

Now that we have a simple widget set available, use this for the boot
editor.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add simple ncurses form widget set
Jeremy Kerr [Mon, 21 Oct 2013 06:09:43 +0000 (14:09 +0800)]
ui/ncurses: Add simple ncurses form widget set

We're doing a lot of the same stuff with forms, and we'll to implement a
lot of fields with the upcoming configuration interface.

This change introduces a simple ncurses widget set.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add sysinfo screen
Jeremy Kerr [Thu, 17 Oct 2013 05:52:42 +0000 (13:52 +0800)]
ui/ncurses: Add sysinfo screen

Add a simple screen for displaying the struct system_info. We add this
to the main menu as a selectable option, and separate it from the boot
option list with an unselectable blank entry.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses/scr: Add definition for frame offset
Jeremy Kerr [Thu, 17 Oct 2013 05:48:35 +0000 (13:48 +0800)]
ui/ncurses/scr: Add definition for frame offset

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: nc-menu.h needs assert.h
Jeremy Kerr [Thu, 17 Oct 2013 05:47:24 +0000 (13:47 +0800)]
ui/ncurses: nc-menu.h needs assert.h

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/common: Don't talloc_free sysinfo and status explicitly
Jeremy Kerr [Thu, 17 Oct 2013 04:03:51 +0000 (12:03 +0800)]
ui/common: Don't talloc_free sysinfo and status explicitly

Currently, we talloc_free() the sysinfo and status messages in the
discover client, right after performing the ui's callback.

However, the client may wish to keep a reference to this information
beyond the callback invocation. This change introduces a per-message
talloc context, which these structures are allocated under. This allows
the callbacks to talloc_steal() anything they wish to keep a reference
to.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Add nc_scr_{un,}post()
Jeremy Kerr [Wed, 16 Oct 2013 03:30:29 +0000 (11:30 +0800)]
ui/ncurses: Add nc_scr_{un,}post()

We may have nc_scrs that aren't interested in post/unpost information,
so create helper functions that allow a NULL callback.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Move general nc init code to cui module
Jeremy Kerr [Tue, 15 Oct 2013 07:51:49 +0000 (15:51 +0800)]
ui/ncurses: Move general nc init code to cui module

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Handle incoming configuration messages
Jeremy Kerr [Thu, 24 Oct 2013 06:43:05 +0000 (14:43 +0800)]
discover: Handle incoming configuration messages

When the client sends us a PB_PROTOCOL_ACTION_CONFIG message, we want to
update the current config.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoconfig: Implement config messages
Jeremy Kerr [Fri, 18 Oct 2013 02:31:03 +0000 (10:31 +0800)]
config: Implement config messages

On client connect, send a PB_PROTOCOL_ACTION_CONFIG message.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-protocol: Add serialise & deserialise for struct config
Jeremy Kerr [Fri, 18 Oct 2013 02:21:50 +0000 (10:21 +0800)]
lib/pb-protocol: Add serialise & deserialise for struct config

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/types: use unsigned int for interface, dns and prio counts
Jeremy Kerr [Fri, 18 Oct 2013 02:07:06 +0000 (10:07 +0800)]
lib/types: use unsigned int for interface, dns and prio counts

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib: Move config structure defitinitions to types.h
Jeremy Kerr [Fri, 18 Oct 2013 02:06:02 +0000 (10:06 +0800)]
lib: Move config structure defitinitions to types.h

We don't want to require the lib/pb-config interface in the UIs, just
the structure defintions. This change moves them to the common types
header.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-config: Implement save method for test storage
Jeremy Kerr [Fri, 18 Oct 2013 00:15:19 +0000 (08:15 +0800)]
lib/pb-config: Implement save method for test storage

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-config: Implement save method for powerpc nvram strorage
Jeremy Kerr [Fri, 18 Oct 2013 00:15:19 +0000 (08:15 +0800)]
lib/pb-config: Implement save method for powerpc nvram strorage

Write values back to nvram.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-config: Implement config_set
Jeremy Kerr [Fri, 18 Oct 2013 00:13:53 +0000 (08:13 +0800)]
lib/pb-config: Implement config_set

This change adds config_set, to allow the configuration to be updated,
but calling the storage backend's save() method.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/util: Add build_assert()
Jeremy Kerr [Mon, 21 Oct 2013 06:00:14 +0000 (14:00 +0800)]
lib/util: Add build_assert()

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/util: Implement min & max macros
Jeremy Kerr [Mon, 21 Oct 2013 04:15:20 +0000 (12:15 +0800)]
lib/util: Implement min & max macros

Standard type-safe min & max implementations.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib: consolidate util macros in util/util.h
Jeremy Kerr [Mon, 21 Oct 2013 03:03:17 +0000 (11:03 +0800)]
lib: consolidate util macros in util/util.h

This change groups the offsetof, container_of and ARRAY_SIZE macros in a
single header file util/util.h.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Fix potentially-uninitialised variables
Jeremy Kerr [Fri, 8 Nov 2013 06:23:32 +0000 (14:23 +0800)]
discover: Fix potentially-uninitialised variables

We've been compiling with --enable-debug; this change fixes some
problems exposed by the optimiser.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add local PXE test
Jeremy Kerr [Thu, 7 Nov 2013 05:12:37 +0000 (13:12 +0800)]
test/parser: Add local PXE test

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add new test cases to pxe parser
Neelesh Gupta [Mon, 28 Oct 2013 07:16:12 +0000 (12:46 +0530)]
test/parser: Add new test cases to pxe parser

Adding new cases to the pxe parser code of having conffile file without
complete URL and determining conffile names using mac and ip addresses
passed from the udhcpc.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Update test cases as per new parser requesting conf files
Neelesh Gupta [Mon, 28 Oct 2013 07:15:59 +0000 (12:45 +0530)]
test/parser: Update test cases as per new parser requesting conf files

Update the parser test code/cases as per new prototyping of parse()
function which doesn't require buf and len to be passed from the caller,
instead reading the configuration data either embedded or from file to
a parser's known conffile.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Change parsers to explicitly request configuration files
Neelesh Gupta [Mon, 28 Oct 2013 07:15:21 +0000 (12:45 +0530)]
discover: Change parsers to explicitly request configuration files

Add a new function parser_request_url() to read the data from
configuration files present remotely. We deprecate
iterate_parser_files() and download_config() functions along with the
'filenames' and 'method' members of the 'parser' structure so that
individual parsers would now require to request the configuration files
data from the parser code and doesn't necessarily export the list of
configuration files.

Add the support to handle incoming DHCP event, done by passing all the
relevant environment variables of the udhcpc to the discover code.
Also, update the pxe parser code to populate the list of configuration
file names as per PXELINUX convention of fallback names using mac and ip
addresses of the booting machine.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/url: Export is_url() function
Neelesh Gupta [Mon, 28 Oct 2013 07:15:08 +0000 (12:45 +0530)]
lib/url: Export is_url() function

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Allocate contexts with talloc_zero
Jeremy Kerr [Wed, 6 Nov 2013 08:33:23 +0000 (16:33 +0800)]
discover: Allocate contexts with talloc_zero

Ensure all pointers from the context are NULL.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/log: Always flush after writing logs
Jeremy Kerr [Fri, 1 Nov 2013 02:33:02 +0000 (10:33 +0800)]
lib/log: Always flush after writing logs

We're currently seeing empty log files from the discover server. Rather
than only flishing if the server was compiled with debugging enabled,
always perform the fflush.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agologging: Clean up debug logs
Jeremy Kerr [Fri, 1 Nov 2013 02:31:00 +0000 (10:31 +0800)]
logging: Clean up debug logs

We have quite a few pb_logs which should be pb_debug. This change moves
developer-specific info to pb_debug.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: Allow for arbitrary-sized netlink messages
Jeremy Kerr [Fri, 25 Oct 2013 06:34:30 +0000 (14:34 +0800)]
discover/network: Allow for arbitrary-sized netlink messages

Currently, we drop any netlink data beyond our 4096-byte buffer. This
means that we can only parse a limited number of network interfaces.

This change uses recvmsg with MSG_PEEK to determine the size of an
incoming netlink message before doing the actual recvmsg. This way, we
can realloc our buffer to suit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agolib/pb-config/powerpc-nvram: Use talloc_zero for interface configs
Jeremy Kerr [Mon, 28 Oct 2013 07:34:42 +0000 (15:34 +0800)]
lib/pb-config/powerpc-nvram: Use talloc_zero for interface configs

We're seeing a problem where ifconf->ignore isn't initialised; use
talloc_zero instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/file: Fix invalid free in replace_file
Jeremy Kerr [Thu, 24 Oct 2013 06:05:17 +0000 (14:05 +0800)]
discover/file: Fix invalid free in replace_file

We talloced tempfile, we should be freeing with talloc_free.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: cleanup allocated data
Jeremy Kerr [Fri, 18 Oct 2013 05:26:23 +0000 (13:26 +0800)]
discover: cleanup allocated data

We have a few allocations hanging around at the end of pb-discover; free
them.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/file: Fix invalid free vs talloc_free
Jeremy Kerr [Fri, 18 Oct 2013 03:34:27 +0000 (11:34 +0800)]
discover/file: Fix invalid free vs talloc_free

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/network: Ensure dns config buffer contains a trailling nul
Jeremy Kerr [Fri, 18 Oct 2013 03:31:57 +0000 (11:31 +0800)]
discover/network: Ensure dns config buffer contains a trailling nul

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/parser: free parsers on exit
Jeremy Kerr [Fri, 18 Oct 2013 05:20:57 +0000 (13:20 +0800)]
discover/parser: free parsers on exit

Allocate parsers against a context, and free that context on exit.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/sysinfo: Fix talloc against uninitialised server var
Jeremy Kerr [Fri, 18 Oct 2013 05:10:58 +0000 (13:10 +0800)]
discover/sysinfo: Fix talloc against uninitialised server var

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Clean lexer.[ch]
Jeremy Kerr [Mon, 21 Oct 2013 03:08:01 +0000 (11:08 +0800)]
discover/grub2: Clean lexer.[ch]

`make distcheck` fails with a couple of failes remaining after clean.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Don't free clients on write failure
Jeremy Kerr [Tue, 15 Oct 2013 02:25:23 +0000 (10:25 +0800)]
discover: Don't free clients on write failure

Currently, if we see an error when writing to a client, we free the
client immediately. This means that any pending reads will be discarded.
Additionally, if a client disconnects before we have finished the writes in
discover_server_process_connection, we won't register the waiter to read
from the socket.

Instead of freeing the client on write failure, this change sets a flag
(se we don't continue to write), and we rely on the read EOF to free the
client. This means we don't drop incoming messages.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Allow an in-progress boot to be cancelled
Jeremy Kerr [Mon, 14 Oct 2013 05:29:31 +0000 (13:29 +0800)]
discover: Allow an in-progress boot to be cancelled

Currently, once the boot() function is called, the boot process will
ignore any cancellations.

This change allows boot() to be cancelled, via boot_cancel().

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add load_url_cancel
Jeremy Kerr [Mon, 14 Oct 2013 05:10:38 +0000 (13:10 +0800)]
discover: Add load_url_cancel

We'd like a way to cancel pending loads, as part of aborting the boot
process.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Allow URL resources
Jeremy Kerr [Mon, 14 Oct 2013 07:21:14 +0000 (15:21 +0800)]
discover/grub2: Allow URL resources

Allow URL-format specifiers for GRUB2 resources.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use OK & Cancel buttons for boot editor completion
Jeremy Kerr [Fri, 11 Oct 2013 08:35:09 +0000 (16:35 +0800)]
ui/ncurses: Use OK & Cancel buttons for boot editor completion

Rather than using enter to complete a boot_editor session, add OK and
Cancel buttons. Enter will move between fields.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use 'x' as exit key
Jeremy Kerr [Fri, 11 Oct 2013 07:16:39 +0000 (15:16 +0800)]
ui/ncurses: Use 'x' as exit key

Because terminals will send escape-sequences starting with escape,
ncurses will pause after receiving a signle escape, to detect
these sequences. This introduces a 1-second delay when exiting the
petitboot UI.

Instead, use 'x'.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Allow booting custom boot options
Jeremy Kerr [Thu, 10 Oct 2013 08:00:17 +0000 (16:00 +0800)]
ui/ncurses: Allow booting custom boot options

Currently, we can't boot user-created boot options, as they have no
option ID associated. This change removes the check for option ID.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Defer item creation until boot editor is done
Jeremy Kerr [Thu, 10 Oct 2013 07:35:35 +0000 (15:35 +0800)]
ui/ncurses: Defer item creation until boot editor is done

Currently, when creating new menu entries, we create an empty item, add
it to the menu, then run the boot editor. This means that cancelling the
edit will leave an empty item in the menu.

This change defers the creation until the boot editor is done. To do
this, we modify the on_open callback to take a menu rather than an item,
and pass NULL boot data to the editor.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Use 'New' instead of 'Open'
Jeremy Kerr [Wed, 9 Oct 2013 13:34:53 +0000 (21:34 +0800)]
ui/ncurses: Use 'New' instead of 'Open'

"Open" is ambiguous in the context of the boot menu; use "new" instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Allow device_handler_boot with no option
Jeremy Kerr [Thu, 10 Oct 2013 08:01:42 +0000 (16:01 +0800)]
discover: Allow device_handler_boot with no option

Only call find_boot_option_by_id if we have an ID.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: remove register_parser printf
Jeremy Kerr [Wed, 9 Oct 2013 13:29:06 +0000 (21:29 +0800)]
discover: remove register_parser printf

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoui/ncurses: Display sysinfo type & identifier
Jeremy Kerr [Wed, 9 Oct 2013 08:48:38 +0000 (16:48 +0800)]
ui/ncurses: Display sysinfo type & identifier

Hook into the sysinfo updates to display the type & id at the top of the
petitboot main menu.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/sysinfo: Add helper script to populate sysinfo identifiers
Jeremy Kerr [Wed, 9 Oct 2013 07:40:42 +0000 (15:40 +0800)]
discover/sysinfo: Add helper script to populate sysinfo identifiers

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoAdd system info messages
Jeremy Kerr [Wed, 9 Oct 2013 04:02:08 +0000 (12:02 +0800)]
Add system info messages

Add a little infrastructure for communicating information about the
system to the petitboot UIs. We just send some identifying info (type
and identifier), as well as the interfaces.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agoutils/pb-udhcp: Don't add a new option on renew
Jeremy Kerr [Wed, 9 Oct 2013 08:50:22 +0000 (16:50 +0800)]
utils/pb-udhcp: Don't add a new option on renew

Otherwise we'll keep collecting new options every $lease_time period.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/udev: dup property values returned from udev
Jeremy Kerr [Wed, 9 Oct 2013 08:38:56 +0000 (16:38 +0800)]
discover/udev: dup property values returned from udev

The property strings are managed by the udev code, so we need to strdup.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/device-handler: Fix use-after-free when unmounting
Jeremy Kerr [Wed, 9 Oct 2013 08:37:25 +0000 (16:37 +0800)]
discover/device-handler: Fix use-after-free when unmounting

We need to do the rmdir after clearing mount_path.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Don't call config_set_autoboot before config_init
Jeremy Kerr [Wed, 9 Oct 2013 05:19:58 +0000 (13:19 +0800)]
discover: Don't call config_set_autoboot before config_init

Change f611bde3 shifted the config_init until after process_init, as we
need to run processes during config init. We also needed to move the
config_set_autoboot invocation too.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Fix uninitialised yylineno
Jeremy Kerr [Fri, 4 Oct 2013 04:43:58 +0000 (12:43 +0800)]
discover/grub2: Fix uninitialised yylineno

Valgrind reports an invalid usage of an uninitialised var in yyerror,
causing testcase failures.

Initialise lineno before we start parsing.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Implement save_env command
Jeremy Kerr [Fri, 4 Oct 2013 03:10:18 +0000 (11:10 +0800)]
discover/grub2: Implement save_env command

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agotest/parser: Add check_file_contents
Jeremy Kerr [Fri, 4 Oct 2013 03:09:10 +0000 (11:09 +0800)]
test/parser: Add check_file_contents

We want to test grub2's save_env command, which requires a new function
to check the contents of a file.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Implement load_env
Jeremy Kerr [Fri, 27 Sep 2013 06:21:53 +0000 (14:21 +0800)]
discover/grub2: Implement load_env

Use the new parser_request_file API to access the GRUB environment
block.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: strdup strings used in the environment
Jeremy Kerr [Tue, 1 Oct 2013 04:42:57 +0000 (12:42 +0800)]
discover/grub2: strdup strings used in the environment

Use a copy of the name & value pairs that we pass to the environment, as
the data loaded from load_env will be talloc_free-ed.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Add default prefix
Jeremy Kerr [Thu, 26 Sep 2013 09:32:47 +0000 (17:32 +0800)]
discover/grub2: Add default prefix

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add device_{request,release}_write
Jeremy Kerr [Tue, 1 Oct 2013 04:27:35 +0000 (12:27 +0800)]
discover: Add device_{request,release}_write

Add a pair of functions to the parser API to allow write access to the
underlying device. We'll use this in the GRUB2 parser to implement
environment persistence.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add parser_request_file
Jeremy Kerr [Fri, 27 Sep 2013 06:19:20 +0000 (14:19 +0800)]
discover: Add parser_request_file

Add a function to allow parsers to access files on a local device.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Add test_data member to struct discover_context
Jeremy Kerr [Fri, 27 Sep 2013 06:16:10 +0000 (14:16 +0800)]
discover: Add test_data member to struct discover_context

We have parsers passing discover_contexts around, which we want to hook
into the test framework. Add a void * member, which the test code can
use to reference the test.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Don't continue discovery if mount fails
Jeremy Kerr [Tue, 1 Oct 2013 03:03:48 +0000 (11:03 +0800)]
discover: Don't continue discovery if mount fails

Check the return value from mount_device and abort the discover on
failure.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover: Allow for already-mounted devices
Jeremy Kerr [Tue, 1 Oct 2013 02:42:04 +0000 (10:42 +0800)]
discover: Allow for already-mounted devices

When we start the discover server, we may find that devices are already
mounted. In this case, mount_device will fail, and we'll abort the
parse.

This change uses /proc/self/mounts to check if new devices are already
mounted, and uses the existing mount point.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
10 years agodiscover/grub2: Clean up error-handling for grub2 parser & lexer
Jeremy Kerr [Thu, 26 Sep 2013 07:45:58 +0000 (15:45 +0800)]
discover/grub2: Clean up error-handling for grub2 parser & lexer

Rather than printf() & exit(), use the pb logging functions and abort
the parse.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>