summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* discover/platform-powerpc: Zero-pad BMC aux-versionv1.0.1Samuel Mendoza-Jonas2016-04-261-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub2: Do not set $0 in functionsAlan Dunn2016-04-261-1/+1
| | | | | | | | | | | | | | | GRUB2 does not set $0 in functions, so don't set it in our GRUB2 script parser. (As it doesn't have a value in GRUB2 scripts, probably no GRUB2 script depends on the value of $0.) Additionally, dash and bash set environment variable 0 to the name of the script (even in functions), so the current behavior of $0 doesn't really match shell scripts either. Tested: Existing tests pass. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Allow evaluation of arbitrarily-positioned arguments in GRUB2 parserAlan Dunn2016-04-261-1/+2
| | | | | | | | | | | | | | | GRUB2 allows essentially arbitrary numbers of positional arguments, so ensure that they can be evaluated within scripts. GRUB2 also appears to support arbitrary numbers of leading 0's in positional parameters (i.e., $01 should evalute the same as $1), but this doesn't seem like a particularly important case to support. Tested: Modified test-grub2-pos-param to cover higher-numbered positional arguments. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Fix sparse warningsAndrew Donnellan2016-04-201-1/+1
| | | | | | | | Fix some sparse warnings by using NULL instead of 0 and static-ifying a variable not used outside its file. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/udev: Don't call udev_set_log_fn()Samuel Mendoza-Jonas2016-04-131-0/+4
| | | | | | | | | | As of libudev 218 udev_set_log_fn() is deprecated, causing a -Wdeprecated-declarations warning when building, and is otherwise a noop. Add a configure check for libudev, and only call udev_set_log_fn() if using a version older than 218. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Perform pre-boot steps when timeout expiresSamuel Mendoza-Jonas2016-04-131-0/+2
| | | | | | | | | | | When a default boot timeout expires boot() is called via default_timeout() rather than device_handler_boot(). default_timeout() doesn't call platform_pre_boot() beforehand, which means steps such as clearing a temporary boot device override are skipped. Add a call to platform_pre_boot() immediately before boot() to ensure these steps are performed regardless of boot type. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/devmapper: Read device size from sysfsSamuel Mendoza-Jonas2016-04-082-12/+79
| | | | | | | | | | | | | If udev doesn't export the ID_PART_ENTRY_SIZE variable for a device we skip creating a snapshot for it. However in most cases the sysfs attribute which udev reads to find ID_PART_ENTRY_SIZE is still available. Therefore if we don't have access to ID_PART_ENTRY_SIZE try to find the size in sysfs directly. This allows us to create snapshots for devices which often don't have this udev variable set, such as software raid (md) devices and NVMe devices. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* 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>
* discover/grub2: Ignore sign-compare warning for generated codeSamuel Mendoza-Jonas2016-04-011-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Respect persistent flag for network overridesv1.0.0Samuel Mendoza-Jonas2016-03-233-14/+28
| | | | | | | If the persistent bit is set in a IPMI network override, overwrite any existing interface config in NVRAM with the new network override. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Attempt to retry failed mountsSam Mendoza-Jonas2016-03-231-44/+56
| | | | | | | | | | | | | | | | Commit 6c1a9dd, "discover: Allow fs recovery if snapshot available", forced the use of 'norecovery' for all XFS mounts to avoid failing when a cross-endian journal existed. This is a bit heavy handed, healthy XFS file systems can still be safely mounted, as can dirty filesystems in the same endian as Petitboot. This adds try_mount() which opportunistically mounts devices and falls back to using 'norecovery' where possible on failure. This enables XFS filesystems to be mounted read-write when possible. try_mount() contains the logic previously described by fs_parameters(), and should be used in place of any existing calls to mount(). Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: Safely cleanup after failed loadSam Mendoza-Jonas2016-03-231-2/+3
| | | | | | | | | | | | | If a call to load_url_async() fails immediately, boot() will free the boot task and return. If other jobs started by load_url_async() are still running they will attempt to free their task struct in load_url_process_exit(), however the original boot task is the parent context of this process task, resulting in a double-free. Instead call cleanup_cancellations if an error immediately occurs to cancel any pending load operations safely before freeing the boot task. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub2: Fix handling of positional parametersAlan Dunn2016-03-151-1/+1
| | | | | | | | | | | | | | Positional parameters are set in the environment with '$' prepended to the name. This causes lookups to fail because parameter lookups don't include the '$'. TESTED: Added a test that covers positional parameters in GRUB2 parser. Build succeeds, tests pass. Bootstrapped-by: Nancy Yuen <yuenn@google.com> Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Change parser interface to allow statAlan Dunn2016-03-153-26/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the GRUB2 parser incorrectly reports "[ -f <path> ]" as false if the size of the file is above 1 MB. This patch changes the parser interface to allow stating files (with parser_stat_file). Then in the implementation of "[ -f <path> ]", we can use parser_stat_file instead of parser_request_file which has the size limitation. I eliminate parser_check_dir in lieu of this new interface, which has the side effect of making "[ -d <path> ]" work (the error code for stat was not checked correctly before). I add a basic test for the test file operations -f, -s, and -d (to show that my changes to test file operations do not break them) and minorly modify the test framework to ensure it has enough fidelity to cause the expected results. Unfortunately the test wouldn't have caught the issue with -d, since the test framework stubs out the parser interface itself. Nor can the test framework catch the initial problem with -f because the imposed limit is (transitively) in function parser_request_file. Note that -f and -d follow symlinks despite the fact that GRUB does not (see http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00142.html discussing GRUB's behavior). This is not a change to Petitboot's behavior though. Tested: The test test-grub2-test-file-ops passes. I booted Petitboot against a GRUB snippet: status=success if [ ! -f /large_file -a $status = success ] then status=fail_large_file fi if [ ! -d /a_directory -a $status = success ] then status=fail_dir fi menuentry $status { linux /vmlinux } (after making /large_file a file of size > 1 MiB and /a_directory a directory) and the menuentry had title "success", as desired. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* In GRUB2 parser save_env, treat unset variable value as emptyAlan Dunn2016-03-151-0/+4
| | | | | | | | | | | | | | It seems better to treat unset variable values as empty rather than crashing in save_env. While GRUB's behavior is actually to delete the variable from the environment block, it seems useful to at least not crash while later on someone can do further work to improve GRUB compatibility if desired. Tested: Modified test-grub2-save-env to cover this case. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Use 'Primary' instead of 'Current' for flash sidesSam Mendoza-Jonas2016-02-261-2/+2
| | | | | | | | | | | | 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>
* discover: Include leading zero in firmware version stringSam Mendoza-Jonas2016-02-261-2/+2
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add support for IPMI network overrideSam Mendoza-Jonas2016-02-263-0/+196
| | | | | | | | | | | | | | | | | | | | | | On BMC platforms the 'Get System Boot Options' command can also be used to check for a temporary network interface config override. This is implemented via the optional 'OEM Parameters' field defined in the IPMI v2 spec. We define the actual format of the field as: - 4 byte cookie value - 2 byte version value - 1 byte hardware address size - 1 byte IP address size - Hardware address - 1 byte flags for 'ignore' and 'method' And for static configs: - IP Address - 1 byte subnet value - Gateway address If set the config override replaces any other interface config, forcing the use of the specified configuration. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Retrieve BMC version info via IPMISam Mendoza-Jonas2016-02-102-0/+95
| | | | | | | | 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-094-0/+65
| | | | | | | | | | 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>
* discover: Print IPMI bootdev response for debugSam Mendoza-Jonas2016-02-091-0/+5
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Fix handling of empty stringsSam Mendoza-Jonas2016-02-091-0/+7
| | | | | | | | | | | If "" or '' are used in a statement to omit a word, we must still return a TOKEN_WORD for an empty string. In particular this fixes an issue where Petitboot would fail to parse the grub.cfg included in the Debian 8.2 install image, which includes a menuentry statement with an empty name. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover: Release process resources on errorSamuel Mendoza-Jonas2016-02-091-2/+4
| | | | | | Fixes Coverity defect #30472 Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover: Handle BTRFS root subvolumesSam Mendoza-Jonas2016-02-093-1/+27
| | | | | | | | | | | | | | | | | | During install some distributions[0] will create subvolumes when formatting the root filesystem with BTRFS. In particular this can mean that bootloader config files will appear (in the case of GRUB) under /var/petitboot/mnt/dev/$device/@/boot/grub/ rather than the expected /var/petitboot/mnt/dev/$device/boot/grub/ If this is the case, perform all file operations from the parser relative to this subvolume rather than the mount point. At the moment this only supports the trivial case where the subvolume name for root is blank (ie. '@'). [0] In particular, Ubuntu from at least 14.04 Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub2: Fix behavior of save_env -fAlan Dunn2016-02-081-3/+14
| | | | | | | | | | | | | | | Currently, "save_env -f" in the GRUB2 parser only works with three arguments, which means only commands of the form "save_env -f <path>" that save *no* environment variables are allowed. Allow "save_env -f <path> [<var>]*", making "save_env -f" useful. Tested: Unit test test-grub2-save-env-dash-f tests this change, and the remaining unit tests still pass. Signed-off-by: Alan Dunn <amdunn@google.com> Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* discover: extend URL in UI to support auto-discoveryNishanth Aravamudan2015-12-185-11/+29
| | | | | | | | | | | | | The URL field currently only supports loading a particular file for static network configurations. But it makes sense in certain static network configurations to 'auto-discover' a file like petitboot does with DHCP -- based off the MAC address and IP. Extend device_handler_process_url to take those as parameters, and toggle off the URL ending in a '/' to indicate whether to 'auto-discover' or directly load the specified URL. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui: add URL for static configurations to load a specified fileNishanth Aravamudan2015-12-183-5/+21
| | | | | | | | | | | | 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>
* discover: Set umask before mkstemp()Samuel Mendoza-Jonas2015-12-181-0/+5
| | | | | | Fixes Coverity defect #30479 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Null-terminate buffer in user_event_process()Samuel Mendoza-Jonas2015-12-181-2/+4
| | | | | | Fixes Coverity defect #30480 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Add two missing talloc_free()sSamuel Mendoza-Jonas2015-12-182-0/+2
| | | | | | Fixes Coverity defects #30474 and #30475 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Skip malformed bootdev fieldsSamuel Mendoza-Jonas2015-12-181-5/+2
| | | | | | Fixes Coverity defect #30471 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Fix dead code in udev_handle_cdrom_events()Samuel Mendoza-Jonas2015-12-181-3/+1
| | | | | | | | | The check against ddev->mounted to cause an eject action is logically impossible. Change it so a cdrom_eject() is called properly. Change the return value to 'true' for any action caused by DISK_EJECT_REQUEST - no further action is appropriate in this case Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Use snprintf() when building sysparam pathSamuel Mendoza-Jonas2015-12-171-6/+4
| | | | | | Fixes Coverity defects #30481 and #30482 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Properly handle return valuesSamuel Mendoza-Jonas2015-12-174-8/+8
| | | | | | | | Fixes three unchecked return values, and one missing initialisation. Fixes Coverity defects #30450, #30451, #30454, and #30483 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Add BMC interface MAC to system info outputJack Miller2015-12-152-1/+31
| | | | | | Useful for identifying the initial BMC traffic on the network. Signed-off-by: Jack Miller <jack@codezen.org>
* discover/ipmi: Increase IPMI timeout to a reasonable valueJeremy Kerr2015-09-301-1/+1
| | | | | | | | | | | | | | | | | We've seen some IPMI timeouts during testing - meaning that an IPMI bootdev setting will be ignored. This can result in a machine booting from an incorrect boot device, or missing a 'safe mode' indication, or incorrectly proceeding past petitboot. The firmware & kernel has its own timeout & retry mechanism, so we already have a little error-recovery there; the timeout in petitboot is to prevent an indefinite block if the kernel interface isn't behaving correctly. So, this change bumps the timeout to a value that suits BMCs we've seen in the field (specifying a 2 second timeout, with one retry). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/ipmi: Use advisory locking on ipmi deviceJeremy Kerr2015-09-301-4/+22
| | | | | | | | | | | | The ipmi module is shared between pb-config and pb-discover. During system initilisation, we're likely to have a few invocations of pb-config running, as well as pb-discover starting. We may have multiple potential concurrent accesses to the ipmi device node. To avoid problems, this change introduces a fcntl lock on the device node. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/devmapper: Use explicit 64-bit types for sector countsJeremy Kerr2015-09-302-12/+14
| | | | | | | | | We currently have a bug where the return value from get_block_sectors may overflow an unsigned int, so we create a snapshot that is too small. This change uses uint64_t types for the sector counts. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Set default languageJeremy Kerr2015-09-241-1/+11
| | | | | | | Rather than setting NULL, do a setlocale(LC_ALL, NULL) to query the system locale value as our default. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: status messages shouldn't have a trailing newlineJeremy Kerr2015-09-181-2/+2
| | | | | | Fix the status message, and remove the newline from our translations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add translation comments for status messagesJeremy Kerr2015-09-181-0/+18
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Fix certain calls to gettextSamuel Mendoza-Jonas2015-09-151-6/+6
| | | | | | | Properly call gettext for strings in discover/device-handler.c that are user-visible, and fix the help string in ui/ncurses/nc-subset.c Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Allow fs recovery if snapshot availableSamuel Mendoza-Jonas2015-09-101-8/+18
| | | | | | | | | If we have a device-mapper snapshot available we can now guarantee filesystem recovery will not write back to a read-only mounted disk. Allow recovery on those devices with the notable exception of XFS which may fail to mount if the filesystem is the opposite endian of Petitboot. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Recognise storage devices on USB busSamuel Mendoza-Jonas2015-08-312-3/+10
| | | | | | | | 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>
* discover: Add disable param for dm-snapshotsSamuel Mendoza-Jonas2015-08-183-0/+13
| | | | | | | 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>
* discover/udev: Additional checks in udev_handle_block_addSamuel Mendoza-Jonas2015-08-181-3/+21
| | | | | | | | | | | | | - Several filesystem types can appear that we won't be able to mount. Instead of waiting to fail mounting them in device_handler_discover(), skip processing them at all. - Do not create dm-snapshots on top of raid arrays until we have a reliable way of determining the sector count for a md raid device. - Turn down the verbosity on skipping dm-devices. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover/devmapper: Disable libdm udev sync supportSamuel Mendoza-Jonas2015-08-181-3/+12
| | | | | | | | | | | Certain userspace environments that Petitboot is packaged with include a libdm built with udev sync support which hung with the previous approach. Relying on udev to properly process dm device creation makes some assumptions about the flavour of udev available - until that is certain disable udev sync support and have device-mapper control device creation itself. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Make read-only guarantee user-settableSamuel Mendoza-Jonas2015-08-063-0/+17
| | | | | | | | 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>
* discover: Mount snapshots for all eligible disk devicesSamuel Mendoza-Jonas2015-08-062-21/+80
| | | | | | | | Device-mapper snapshots are created for all disk devices prior to being mounted. If explicit writes are made to the snapshot they are merged back to the disk once write access is released. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Support creation of device-mapper devicesSamuel Mendoza-Jonas2015-08-063-0/+557
| | | | | | | | | | | | | | | | | | | Add discover/dm-snapshot that allows the creation of device-mapper snapshots that support merging changes back to disk. Device-mapper snapshots are a CoW device backed by a ramdisk, mirroring the contents of a source device. No changes are made to the original disk unless an explicit merge action is performed. This guarantees read-only mounting of host disks even when writes could implicitly occur, eg. when performing recovering a journaled filesystem. In the event that writing back to the disk is desired, such as when updating grubenv, the changes made to the snapshot can be merged back to the source disk. This patch adds support but does not change functionality. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
OpenPOWER on IntegriCloud