summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* discover,ui: fix checks for debug optionJeremy Kerr2014-05-012-2/+2
| | | | | | We need to check for equality with opt_yes, not just check for non-zero. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/yaboot: support lilo & silo for x86 and Sparc.Jeff Bailey2014-04-231-0/+4
| | | | | | | | | The yaboot.conf format is essentially the same format as silo.conf and lilo.conf, especially if the author isn't using OF paths. This is a cheap way of getting support for silo and lilo. Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: only cancel default boot on valid key eventsJeremy Kerr2014-04-221-4/+7
| | | | | | | | | | We're seeing occasionaly failures to autoboot due to supirious key events (getch() returing -1) on an IPMI console. This change modifies the process_key logic to only abort the default if we see a valid key event. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: NULL return from udev_enumerate_get_list_entry isn't an errorJeremy Kerr2014-04-171-5/+0
| | | | | | | | | | A NULL return can mean the list is empty; don't return a failure from this case. udev_list_entry_foreach does a check for a NULL entry, so we'll do the correct thing in the following loop. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: fix double free on udev_init failuresJeremy Kerr2014-04-171-13/+13
| | | | | | | | | | | If the udev monitor or enumerate functions fail, we'll call the udev_unref and udev_monitor_unref functions twice: once in the cleanup path and once in the talloc destructor. This change moves all cleanup to the talloc destructor, so we only do the unrefs once. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Always provide a key definition for backtabJeremy Kerr2014-04-161-0/+5
| | | | | | | | | | | | | Petitboot environments will probably want a basic terminfo defintion (eg, vt220) rather than a full linux or xterm, but vt220 and friends don't define a backtab key. Backtab can be useful for proper form navigation, and without a key definition, we just get an escape, which exits the current screen. This change provides a static definition for KEY_BTAB, so we should always have one available. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use a fixed-sized for small, known-length fieldsJeremy Kerr2014-04-163-1/+11
| | | | | | | | | | | | | Fields without O_STATIC can "scroll" horizontally, and we may miss a left-hand section of text from the current display. This can mean that the user can't leave a validated field with no indication why, if the off-to-the-left data is not a valid entry. This change adds a widgetset function to mark a field as fixed-size, so we don't have this scrolling behaviour. This means that the entire field contents will always be visible, and any validation errors can be seen. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix uninitialised var warningsJeremy Kerr2014-04-162-3/+3
| | | | | | | | | | | | | | We get a couple of uninitialised var warning when compiling with certain CFLAGS (-fprofile-arcs -ftest-coverage at this stage). In statement_if_execute: We'll never actually use this uninitialised (as there must be at least one conditional in the parsed statement), but we should address the warning nonetheless. As passed to strtok_r: strtok will initialise this, but it isn't obvious to the compiler. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Ensure boot option labels are displayable as menu itemsJeremy Kerr2014-04-101-1/+43
| | | | | | | | | | | | | | | ncurses' new_item() expects the name parameter to be a "printable string", by converting it to a wchar *, and checking that each character is printable with iswprint(). If it fails, we won't see a boot option at all. This change introduces a function to convert the label into something we know is printable, and valid UTF-8. If mbstowcs fails, we replace it with a generic 'Invalid option' label. If we encounter a valid multibyte string with unprintable characters, we replace those with U+fffd REPLACEMENT CHARACTER. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Fix discover_client leakJeremy Kerr2014-04-101-0/+1
| | | | | | | We're not freeing the discover_client on exit, as it's not attached to any existing talloc context. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: unpost ncurses menu in pmenu cleanup pathJeremy Kerr2014-04-101-0/+1
| | | | | | We need to unpost the menu so that free_item can actually free the item. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use pmenu_item destrutor to free ncurses ITEMsJeremy Kerr2014-04-101-6/+9
| | | | | | | | | | Currently, pemnu_destroy is used to free items. This means that the menu code needs to iterate over items, and we have no way to free the ITEM * of items that aren't in a menu. Instead, free the ITEM in the pmenu_item destructor. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Separate menu item creation & initialisation from insertionJeremy Kerr2014-04-104-70/+67
| | | | | | | | | | | | | | | | | | | | | | | Currently, the menu item creation is has two main functions: pmenu_item_alloc and pmenu_item_setup. The latter does initialisation (it sets item->name), and inserts the item into the menu. We have pmenu_item_init to combine this into one, but that means we need to do further initialisation (eg, to set on_execute) after the item has been added to the menu. Instead, this change use a more direct _create and _insert interface. Create does the allocation and initialisation, while _insert does the actual insertion. This means new_item failures will be detected at creation time, rather than during pmenu_insert. Also, we're now insert a completely-populated item into the menu, rather than populating on_edit, on_execute and data after insertion. Because we can detect errors from creation (ie, from new_item failing), we add handling code to cui_boot_option_add and cui_boot_editor_on_exit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Don't use menu offsets for user item numbersJeremy Kerr2014-04-101-1/+2
| | | | | | | The menu offsets are arbitrary, use a separate numbering scheme for user items. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Remove pmenu_item_replaceJeremy Kerr2014-04-082-49/+0
| | | | | | ... as nothing uses it. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Don't free item in pmenu_item_setupJeremy Kerr2014-04-083-7/+16
| | | | | | | | | | | | | Currently pmenu_item_setup may free its item parameter on error. This makes it non-obvious whether the item is still allocated on exit to the caller. Instead, this change removes the talloc_free, and requires that the caller do this on error. This makes the potential use-after-free in cui_boot_editor_on_exit obvious, so we fix that too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-protocol: fix deserialise of boot option prioritiesJeremy Kerr2014-04-071-0/+3
| | | | | | | | | | | | Commit aa530148 introduced a priority member to struct boot_priority, but didn't update the protocol deserialise function to properly decode config messages. This meant we were leaving half of the struct uninitialised, and getting invalid values in the initialised part. This change updates the config deserialise function to do proper handling for boot priority data. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: clear DNS server setting before appending new serversJeremy Kerr2014-04-071-0/+4
| | | | | | | | | | Currently, we have a bug where newly-configured DNS servers are appended to the existing set of servers, rather than replacing them. This change clears the existing servers out before adding the newly-configured ones. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* log: Allow runtime selection of 'debug' log levelJeremy Kerr2014-04-077-19/+50
| | | | | | | | | | | | | | | | | Currently, we need to compile with -DDEBUG to implement debug-level logging in the UIs and discover server. Since we may not be able to easily replace a system's petitboot binaries, this change introduces a -v|--verbose option to the discver server and ncurses UI, which enables debug at runtime. We also move some of the udev debug code out of an #ifdef DEBUG block. Since petitboot is generally started on boot, we also add a little infrastructure to pass -v to petitboot on certain system contitions: either petitboot.debug on the kernel command line, or a petitboot,debug? NVRAM property containing the value 'true'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: run udhcpc process in foreground modeJeremy Kerr2014-04-031-0/+1
| | | | | | | We don't want udhcpc processes to detach, otherwise we aren't able to stop the spawned background process, which we need to do on reinit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use tty name in default log filenameJeremy Kerr2014-04-031-5/+35
| | | | | | | | | | | When we have multiple ncurses UIs running, we'd like to log to separate files. Currenly, all UIs log to the same file, which makes it diffifult to determine which UI is logging each message. This change uses the output of ttyname() (sanitised appropriately) as a component of the default log filename. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add debug on process killJeremy Kerr2014-04-031-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: flush addresses when bringing an interface downJeremy Kerr2014-04-021-0/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add menu option to restart discoveryJeremy Kerr2014-04-023-2/+16
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/common: associate boot options with devicesJeremy Kerr2014-04-021-0/+2
| | | | | | | The discover client isn't currently associating boot options with their devices. This change adds appropriate device list management. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-026-1/+23
| | | | | | | Now that we can re-initialise the device handler, allow this to be triggered from UIs over the petitboot protocol. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: add reinit pathJeremy Kerr2014-04-024-1/+49
| | | | | | | | | | | | | Currently, changes to settings doesn't take effect while the discover server is running. This means we need to reboot for any changes (eg, to network settings) to take effect. This change introduces a reinit path. Triggered by a configuration update, this will cause the device handler to drop all of its devices (and boot options), and restart the discovery process from the device sources. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: move device sources to the device handlerJeremy Kerr2014-04-026-44/+53
| | | | | | | | | | | | | | | | | | | | Currently, the pb-discover main() function initialises the device handler and the device sources. We want to eventually be able to re-init the device sources, which will be initiated by the handler. In this case, the handler will need references to the sources. This change moves the creation of the device sources to be internal to the handler. This way, the device handler gets a reference to everything, without having to pass pointers around in main(). We also remove the _destroy functions, as we handle everything through talloc destructors, as all sources are parented to the handler. We also change user_event_init and udev_init to take the handler as the first ('context') argument, to make them consistent with network_init. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: duplicate devices aren't an errorJeremy Kerr2014-04-011-1/+1
| | | | | | | We don't need to error out of udev_handle_block_add if this is a duplicate UUID. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: don't propagate non-fatal errors from udev_processJeremy Kerr2014-04-011-10/+3
| | | | | | | | | | | | Currently, we have a bug where non-zero return codes from udev_handle_dev_* cause the udev worker from deregistering from the waiter poll loop. This is becasue udev_process is propagating these errors, causing the deregistration. This change stops propagation of non-fatal errors, so we don't deregister. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Increase udev monitor buffer sizeJeremy Kerr2014-03-181-0/+11
| | | | | | | | | Since we may be enumerating devices after enabling the udev monitor, we may miss udev events that occur during this process. This change increases the default udev buffer size. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* udev: use pb_log for device SKIP messagesJeremy Kerr2014-03-141-5/+5
| | | | | | | We often want to find out why a device has been skipped, so include the SKIP messages at pb_log, which doesn't require a -DDEBUG build. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Call mount syscall directlyJeremy Kerr2014-03-141-14/+17
| | | | | | | | | | | We used to use the mount binary to do filesystem autodetection. Since we now know the fstype, we may as well call the mount syscall directly. We add a log messages too, as we'll no longer get the 'running process:' output from the process code, which is helpful is debugging discovery issues. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Use ID_FS_TYPE property for filesystem type detectionJeremy Kerr2014-03-142-1/+12
| | | | | | | | | | | | | | | | | | | | | | | Currently, we don't hand any -t option to mount, as we expect the mount binary to do autodetection of the filesystem type for us. Turns out this isn't great with busybox mount, (which we're likely to be using in petitboot builds), which implements "autodetection" by trying the mount() syscall with every fs type in /proc/filesystems, until one succeeds. We expect a lot of the mount calls to fail, as we currently try to mount everything (and abort discovery on devices that don't mount), including non-filesystem partitions. On a test machine with 560 block devices, and 37 entries in /proc/partitions, this results in around 20,000 calls to mount(). A better way would be to pass a -t option to mount. It turns out that udev uses libblkid to probe the filesystem type, which is available in the ID_FS_TYPE property. This change only attempts to mount filesystems with this property, and passes an explicit fstype to the mount binary. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/powerpc: Invalidate next bootdev after readingJeremy Kerr2014-03-141-3/+46
| | | | | | | The next-bootdev sysparam should only apply for the next boot, so invalidate it after reading. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/powerpc: Fix sysparams base pathJeremy Kerr2014-03-141-1/+1
| | | | | | | We are appending the sysparam filename onto sysparams_dir, so we need a trailing slash. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add debug output to sysparams parsingJeremy Kerr2014-03-141-2/+10
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Include boot priorities in configuration dumpJeremy Kerr2014-03-141-0/+26
| | | | | | | To help debug boot priority issues, it'd be useful to include the priority data in the configuration dump. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: Register udev monitor before enumerating devicesJeremy Kerr2014-03-071-20/+47
| | | | | | | | | | | | | | | | Currently, we enumerate udev devices before setting up our monitor. This means that we may lose devices that udev discovers after we start the enumeration, but before the monitor is registered. This change enables the monitor before enumeration, so we don't lose devices. We add a filter to the enumeration code to only parse completely initialised devices. This means we may need to handle change events as the main source of device notifications. We keep the existing CDROM event handler, but check for new devices and handle those as an add. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Print error message on mount failureJeremy Kerr2014-03-071-0/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: don't retry mount without ro optionJeremy Kerr2014-03-071-11/+0
| | | | | | | | | | Currently, if the read-only mount fails during device discovery, we retry without the '-o ro' option. This was originally due to the read-only mount failing when a device was already mounted elsewhere. Since we check for exsiting mounts now, we can drop this retry. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: fix return value for discover_device_get_paramJeremy Kerr2014-03-061-1/+1
| | | | | | We're incorrectly returning the name, we need the value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/udev: Separate block-specific udev discoveryJeremy Kerr2014-03-051-14/+33
| | | | | | | | | | We'd like to trigger network device discovery from udev code, but most of the device_add code path assumes block devices. This change adds a subsystem check, and moves the block-specific code to udev_handle_block_add. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Ensure that the selected menu item is visibleJeremy Kerr2014-03-031-5/+16
| | | | | | | | | | When adding new items to the petitboot menu, we need to ensure that the scroll position of the menu includes the currently-selected item. This change adds a call to set_top_row, calculated from the selected item index, and the number of rows in the menu. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* test/parser: Add pxe discovery testsJeremy Kerr2014-02-276-0/+204
| | | | | | Add tests to cover pxlinux-style configuration autodiscovery. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: pxe parser should only treat "::" paths as absoluteJeremy Kerr2014-02-278-7/+121
| | | | | | | | | | PXELinux treats all paths as relative, requiring a "::/path" syntax for truly absolute URLs. This change implements the same behaviour in petitboot, and updates the testcases to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: Fix prefix autodetection when bootfile is in the root dirJeremy Kerr2014-02-271-2/+3
| | | | | | | | | | | | | | | | | | | | | Currently, if the bootfile doesn't contain a directory, the path we use for config file resolution will use the bootfile as the first component of path. For example, if bootfile is: pxelinux.0 the config files requested will be: pxelinux.0/<mac> pxelinux.0/<ips> pxelinux.0/default For cases where bootfile is a single file, we need to use a blank prefix. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: Add pxelinux.cfg/ directory to autodiscovered pxe pathsJeremy Kerr2014-02-275-15/+23
| | | | | | | | | | The pxelinux project will perform autodiscovery by looking for files under the pxelinux.cfg/ prefix (in addition to any pxepathprefix from DHCP option 210) This change unifies petitboot's behaviour with pxelinux. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Fix incorrect static DNS servers in resolv.confJeremy Kerr2014-02-251-1/+1
| | | | | | | | | | | | | | | | We currently have a bug where we write NUL characters into /etc/resolv.conf, when using static DNS server configurations: With a network setting of: dns,9.0.6.11,9.0.7.1 We generate a resolv.conf containing: nameserver 9.0.6.11^@nameserver 9.0.7.1^@ This is due to an off-by-one bug when terminating the nameserver entries. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Don't abort stdout reads on EINTRJeremy Kerr2014-02-203-3/+73
| | | | | | | | | | | | | | | | | If our read() of the process stdout pipe fails with EINTR (eg, if we receive a SIGCHLD because the process exited), then process_read_stdout_once will return a non-zero exit code, and we'll abort any further stdout collection. Instead, we should check for EINTR, and allow the reads to continue. This change normalises the return value from process_read_stdout_once to return positive on success, negative on failure, and zero on competion. We use a positive return value for the non-error EINTR case. Also, add a pb_log if the read fails for non-EINTR reasons. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud