summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* configure.ac: Add checks for libflash and libdevmapperSamuel Mendoza-Jonas2016-04-051-1/+1
| | | | | | | | | libdevmapper is a hard dependency since snapshots were introduced, so add an unconditional configure-time check for it. Also add a check for libflash library and headers if --enable-mtd is set. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/fold: Catch error case from mbrtowc()Sam Mendoza-Jonas2016-03-151-3/+4
| | | | | | | | | | | | | The assert() statement in fold_text() only evaluates in a debug build. If mbrtowc() encounters an error return the portion of the string that has been parsed and stop. This avoids an issue with glibc 2.22 where previous calls to setlocale() failed and set an unsuitable locale. Since the error was not caught this resulted in an infinite loop when trying to access the Language screen. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/flash: Fix version side being interpreted backwardsSam Mendoza-Jonas2016-03-051-1/+1
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Use 'Primary' instead of 'Current' for flash sidesSam Mendoza-Jonas2016-02-262-12/+12
| | | | | | | | | | | | When queried libflash will return the 'first' flash side (ie. the one with the lowest TOC address), however we label this the 'Current' side which is incorrect if the machine has booted from the alternate side. A future fix will inlcude additional platform logic to determine which flash side is current; in the interim label the first flash side as 'Primary' instead of 'Current'. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Retrieve BMC version info via IPMISam Mendoza-Jonas2016-02-102-1/+43
| | | | | | | | On BMC machines the "Get Device ID" and "Get BMC Golden Side Version" IPMI commands are available. If possible retrieve some interesting version numbers and display them in the System Information screen. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Display VERSION partition info on BMC machinesSamuel Mendoza-Jonas2016-02-092-0/+43
| | | | | | | | | | On supported platforms read the VERSION partition on startup and display the available versions strings in the System Information screen. This adds a skeleton hostboot.c to support possible additional BMC platform support. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/flash: Add support for platform versionsSamuel Mendoza-Jonas2016-02-094-1/+273
| | | | | | | | | | | | | Add basic libflash support to read the VERSION partition on BMC machines. This adds a dependency on the libflash shared library from Skiboot. The MTD partition is accessed through the libflash helper functions. Once read into a buffer, the VERSION partition is a simple list of newline-terminated version strings. Some BMC platforms may have two 'sides' to flash - these are interpreted as the "current" and "other" sides depending on which one the current Petitboot is running from. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib: Add CCAN headers for endian helpersSamuel Mendoza-Jonas2016-02-096-0/+550
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/talloc: Avoid early exit before va_end()Samuel Mendoza-Jonas2016-02-091-1/+3
| | | | | | Fixes Coverity defect #30486 Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/pb-protocol: Fix NULL dereference on non-powerpcSamuel Mendoza-Jonas2015-12-211-1/+4
| | | | | | | | If not running on a powerpc platform the bmc_mac pointer remains NULL. If this is the case set an address of zero when serialising rather than dereferencing the pointer. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui: add URL for static configurations to load a specified fileNishanth Aravamudan2015-12-182-0/+7
| | | | | | | | | | | | In certain configurations, e.g. automation, we want to use static networking but load a particular file, automatically and parse it as a pxelinux config file. Currently, we support something like this for DHCP based booting, but not static. Add a URL field to the UI for static configurations and reuse the logic from device_handler_process_url() to load the specified file. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib/talloc: Add missing va_end() callsSamuel Mendoza-Jonas2015-12-181-0/+2
| | | | | | Fixes Coverity defects #30485 and #30486 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Add BMC interface MAC to system info outputJack Miller2015-12-152-1/+18
| | | | | | Useful for identifying the initial BMC traffic on the network. Signed-off-by: Jack Miller <jack@codezen.org>
* Consolidate display string for optical devicesSamuel Mendoza-Jonas2015-08-311-1/+1
| | | | | | | Instead of using 'Optical' in some places and 'CD/DVD' in others, simply use 'CD/DVD' for all cases. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Recognise storage devices on USB busSamuel Mendoza-Jonas2015-08-312-0/+7
| | | | | | | | Users may want to prioritise USB-attached storage devices differently to other devices. Detect if a device is USB-attached and add a new device type to identify it. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib/i18n: Move strncols to i18n.cSamuel Mendoza-Jonas2015-08-313-0/+53
| | | | | | Make the strncols() helper available generally to i18n-concerned code. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib/fold: Handle extra mbrtowc return caseSamuel Mendoza-Jonas2015-08-251-2/+3
| | | | | | | | Commit 9781a370 ("Handle mblen return code when n is zero.") in glibc changes the return value for when the number of bytes ('n') is zero. Add an extra condition to detect if we've reached the end of the buffer. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Add disable param for dm-snapshotsSamuel Mendoza-Jonas2015-08-181-0/+1
| | | | | | | Add a debug-style nvram parameter to disallow the use of device-mapper snapshots. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Make read-only guarantee user-settableSamuel Mendoza-Jonas2015-08-063-0/+13
| | | | | | | | Create a new Petitboot option 'petitboot,write?' that specifies whether the system is allowed to mount devices read-write. The option can be toggled by the user in the nc-config screen. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib: Move ipmi_bootdev enum to types.hSamuel Mendoza-Jonas2015-05-052-0/+31
| | | | | | | Move the ipmi_bootdev definition to types.h to support returning descriptive strings to the system configuration UI. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* petitboot: Implement ordered boot optionsSamuel Mendoza-Jonas2015-05-053-49/+47
| | | | | | | | | | | Move petitboot to a more familiar 'boot-order' based autoboot system. The discover server now reads multiple values from the petitboot,bootdev parameter and adds them in order to config->autoboot_opts. Boot priority is determined by the options' position in the list. On the client, nc-config now recognises the new boot order, and allows the user to add, remove, and reorder the devices in the list. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib: Define autoboot_options, device_type helpersSamuel Mendoza-Jonas2015-05-053-0/+67
| | | | | | | | | Add the new autoboot_option struct, and helper functions for working with device_type enums. device_type_name() returns exact strings as used by platform code to read/write nvram params, so device_type_display_name() is added for use in user-visible strings. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Integrate ipmi bootdev settings into the priority systemJeremy Kerr2014-12-153-1/+22
| | | | | | | | | | | | | | | | | | Currently, we expose the boot device priorities through an array in struct config, which will either be the default (network -> disk), or a single device type specified by the IPMI code. Rather than hide the implementation details in this array, we'd like to expose the details of the machine configuration instead. This allows user visibility of the real boot configuration (for example, if an IPMI boot preference is set). This change removes the priority array, and replaces it with the ipmi_bootdev data (and a persistent flag). We update the default-conflict-resolution code to reflect the priorities between IPMI and UUID preferences. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/fold: fix warning with -DDEBUGJeremy Kerr2014-12-011-1/+1
| | | | | | | | | | | | | When compiling the fold code with DEBUG defined, we get: ../lib/fold/fold.c: In function 'fold_text': ../lib/fold/fold.c:37:3: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] assert(bytes >= 0); ^ We should be comparing with != (size_t)-1, not >= 0 Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/fold: Add support for multibyte stringsJeremy Kerr2014-09-231-11/+59
| | | | | | | | | | Currently, the fold_text function doesn't understand multibyte strings, so may break a line in the middle of a multibyte sequence. This change adds multibyte-awareness to the fold code, and uses proper width calculations for the contents of the folded string. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add debug flag to configJeremy Kerr2014-08-051-1/+4
| | | | | | | | | | This change adds a debug flag to the config, and groups it under not-user-modifiable parts of struct config. This means we no longer need the pb-sysinfo helper, as the last remaining function (--debug-enabled) can be implemented with pb-config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: Move generic file-handling code to lib/Jeremy Kerr2014-08-053-1/+149
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Use non-recursive makeJeremy Kerr2014-08-011-31/+30
| | | | | | | | | | | | With the current testing infrastructure, we don't have a strictly hierarchical set of dependencies. This causes problems with a recursive make, and means we have to hack around some of the dependencies. This change generates a single, top-level makefile from all of the Makefile.am fragments. We still need the po/ directory as a separate SUBDIR, but all others can be converted to non-recursive. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-protocol: Define new 'add-url' actionSamuel Mendoza-Jonas2014-07-282-0/+21
| | | | | Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Add lang member to configJeremy Kerr2014-07-283-0/+15
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* i18n: Mark translatable strings for ncurses UIJeremy Kerr2014-07-281-0/+26
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add safe modeJeremy Kerr2014-07-223-1/+11
| | | | | | | | | | | Safe mode configures the discover server to not start any device parsing; this can be used to diagnose any problems with early device handing. In safe mode, we don't initialise any of the device sources - udev, network and user events are disabled. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: check config.boot_device before setting a defaultJeremy Kerr2014-07-211-0/+2
| | | | | | If a default device is set, we only allow booting from that device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Add boot_device member to configJeremy Kerr2014-07-213-3/+16
| | | | | | | We'd like to specify a way to only boot from a specific block device; this adds a field to the configuration to hold the value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Don't require custom automake optionsJeff Bailey2014-07-161-0/+2
| | | | | | | | | | | | | 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>
* 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>
* log: Allow runtime selection of 'debug' log levelJeremy Kerr2014-04-072-0/+6
| | | | | | | | | | | | | | | | | 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>
* lib/process: Add debug on process killJeremy Kerr2014-04-031-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-021-0/+1
| | | | | | | 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>
* lib/process: Don't abort stdout reads on EINTRJeremy Kerr2014-02-201-3/+15
| | | | | | | | | | | | | | | | | 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>
* lib/fold: Add text fold utilityJeremy Kerr2014-01-313-0/+73
| | | | | | | We want to fold help text into the ncurses UI, so add a little module to split text into lines. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add DEVICE_TYPE_ANY for matching any deviceJeremy Kerr2014-01-301-0/+1
| | | | | | | | | | Currently, If we want disable all but a specific device type from default boot, we need to add a negative priority for all other devices. This change adds a DEVICE_TYPE_ANY definition, to allow a simpler way to express "only boot a specific type" by default behaviour. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Make boot_priorities more flexibleJeremy Kerr2014-01-303-3/+15
| | | | | | | | | | | | Rather than rely on the ordering of the boot_priorities array to define which device types have a higher "default boot" priority, this change introduces a slightly more flexible way of priority lookups, by adding a separate priority field to struct boot_priority. This means we can have an unordered array, change priorities without re-writing the array, and implementing a disable mechanism. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-config: Move config storage modules to "platform" modules in discover codeJeremy Kerr2014-01-307-814/+3
| | | | | | | | | | | | | | | | | | There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Add config_copyJeremy Kerr2014-01-302-0/+65
| | | | | | | | | | | | | | At the moment, UIs have the config_set_defaults function to estabilish an initial configuration when performing an update. Rather than using the defaults, this change provides a config_copy() function, so that the updated configuration can be initialised from the current config. With this in place, the UI/server-common pb-config module can be reduced to just the one function. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-config/powerpc: fix default option handlingJeremy Kerr2014-01-231-10/+30
| | | | | | | | | | | Currently, we don't update nvram if an NVRAM parameter is set to the default. This means we can never revert a configuration to its default value. This change fixes the default setting behaviour; instead of checking for a default, we want to check if it's a default and the option is absent. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add helper for check process clean exitJeremy Kerr2014-01-213-4/+13
| | | | | | | We have a few incorrect checks for the exit status of a process; this change adds a helper with the correct WIFEXITED && WEXITSTATUS==0 logic. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add add_stderr flag to process moduleJeremy Kerr2014-01-142-1/+5
| | | | | | | | | | | | For some process execution functions, we'd like to capture stderr as well as stdout. Currently, we unconditionally redirect subprocess stderr to the petitboot log file. This change adds an add_stderr flag to struct process, which indicates to the process library that we want stderr as well as stdout. If this is specified, the subprocess' stderr is captured to stdout_buf. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config/powerpc: Always call update_network_configJeremy Kerr2013-12-231-2/+1
| | | | | | | | | | | | | | Currently, we have a bug when setting the default network configuration (ie, no devices have any specific config), as we won't call update_network_config to clear out the value of the petitboot,network parameter. This change always invokes update_network_config, regardless of the number of interfaces configured. This ensures we clear out the petitboot,network param, which is then synced to nvram if the param has changed. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Use AC_GNU_SOURCEJeremy Kerr2013-12-181-1/+0
| | | | | | | Rather than #defining _GNU_SOURCE in our .c files, we can define this from config.h instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud