summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* version.sh: Use git tags in versionsJeremy Kerr2014-07-161-7/+11
| | | | | | | | If the current HEAD is tagged, we'd like to use that tag as the version. We remove a 'v' prefix, so that v1.0 -> 1.0 Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* version.sh: Unify version generationJeremy Kerr2014-07-161-17/+10
| | | | | | | | | | | | | This change includes a few fixes to the version.sh script, in order to unify the versions generated from git vs. dev- versions. We unify on a simple YYYYMMDD format, and drop the time specifier (if you're relying on time info, you probably have the git SHAs to lookup from instead). We also clean up the date-generation code, by using printf's %T formatter, on git's %ct time specification, rather than trying to transform a %ci date. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Make petitboot autoreconfableJeff Bailey2014-07-164-45/+40
| | | | | | | | | | | | | | | | The standard way to regenerate the autotools bits is with 'autoreconf', but that doesn't work with our custom bootstrap script. We only need the bootstrap script to generate the version in configure.ac, which we can easily do with m4_esyscmd_s instead. This change allows autoreconfiguration with `autoreconf -f -i`. Includes changes proposed by Yann E. Morin <yann.morin.1998@free.fr>, and modifications from the original patch from Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Don't require custom automake optionsJeff Bailey2014-07-164-2/+6
| | | | | | | | | | | | | We need a couple of automake options to prevent errors when regenerating Makefile.ins during source preparation. Some makefiles assume GNU make, so add 'foreign' where necessary. Also, we are building objects in subdirectories, so we need 'subdir-objects'. Modified to suit recent petitboot by Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: leave udhcpc processes runningJeremy Kerr2014-06-301-2/+1
| | | | | | | | | | Currently, we start udhcpc with the '-n' argument, which means they'll exit if no lease is obtained. We'd prefer to leave the DHCP client running, so that any slow-to-initialise links are not left deconfigured. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/platform-powerpc: Don't rely on NVRAM workingJeremy Kerr2014-06-301-5/+1
| | | | | | | | | Although we need nvram to save settings, we may be running on a nvram-less machine, but still need to detect as powerpc. This change removes the nvram check. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Fix incorrect udhcpc command if we have no platform definitionJeremy Kerr2014-06-301-1/+1
| | | | | | | | | | If we don't have a platform defined, we generate an invalid uchdpc command, as we've NULL-ed out the interface name. This change fixes the no-platform case to terminate *after* the interface name. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* grub2: fix empty file handlingJeremy Kerr2014-06-053-0/+14
| | | | | | | | | | | Currently, we have a bug when parsing zero-length files: we subtract one from the length to exclude the trailing NUL (added by read_file), but a zero-length file will result in a length of -1. This change adds an explicit exit if we're attempting to parse an empty file. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/paths: Fix wget command with https and !DEBUGJeremy Kerr2014-06-051-2/+3
| | | | | | | | When DEBUG is undefed, we run out of wget arguments for loading https URLs. We need an extra element in the argv array to handle all possible arguments. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: don't free cancelled load tasksJeremy Kerr2014-05-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, we have a bug when a boot task with more than one load tasks is cancelled: 1) boot_cancel calls cleanup_cancellations, which performs a load_url_async_cancel on all load tasks. This sets the load tasks' states to LOAD_CANCELLED, and signals associated processes. 2) The first load task process completes, we get a load_url_process_exit callback. This then invokes cleanup_cancellations. 3) cleanup_cancellations then (incorrectly) frees the boot task (and hence freeing all pending load tasks) as no load tasks are in LOAD_ASYNC state (we set them all to LOAD_CANCELLED in step 1) 4) The actual completion for the second load task attempts to reference the now-freed task structure. This change fixes the issue by handing the LOAD_CANCELLED state properly - if we find a load task in this state, we consider the boot task still pending, and delay the free until all loads are complete. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* utils/pb-console: use a linux termcap entry for local consolesJeremy Kerr2014-05-191-0/+7
| | | | | | For local consoles, we always want a TERM=linux. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* 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>
OpenPOWER on IntegriCloud