summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* lib/util: Avoid sprintf in mac_strJeremy Kerr2013-12-181-3/+6
| | | | | | The conversion is simple, no need for sprintf. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/util: Move mac_buf from nc code to util libraryJeremy Kerr2013-12-183-0/+51
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* sysinfo: Add interface link status to sysinfo dataJeremy Kerr2013-12-182-1/+9
| | | | | | | | This changes adds a 'link' parameter to the interface information sent in sysinfo messages. The discover network code populates this from the incoming netlink messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config/powerpc-nvram: Fix format of dns configJeremy Kerr2013-11-261-1/+1
| | | | | | It should be dns,<server> not dns=<server> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: Add block device information to system infoJeremy Kerr2013-11-222-1/+49
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/system: Don't leak in pb_mkdir_recursiveJeremy Kerr2013-11-141-3/+6
| | | | | | If the mkdir fails, we'll exit without freeing str. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle incoming configuration messagesJeremy Kerr2013-11-131-2/+2
| | | | | | | 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>
* lib/pb-protocol: Add serialise & deserialise for struct configJeremy Kerr2013-11-132-0/+209
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/types: use unsigned int for interface, dns and prio countsJeremy Kerr2013-11-133-6/+6
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: Move config structure defitinitions to types.hJeremy Kerr2013-11-132-38/+37
| | | | | | | | 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>
* lib/pb-config: Implement save method for test storageJeremy Kerr2013-11-131-3/+15
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Implement save method for powerpc nvram strorageJeremy Kerr2013-11-131-0/+179
| | | | | | Write values back to nvram. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Implement config_setJeremy Kerr2013-11-133-4/+36
| | | | | | | 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>
* lib/util: Add build_assert()Jeremy Kerr2013-11-131-0/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/util: Implement min & max macrosJeremy Kerr2013-11-131-0/+14
| | | | | | Standard type-safe min & max implementations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: consolidate util macros in util/util.hJeremy Kerr2013-11-135-19/+39
| | | | | | | 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>
* lib/url: Export is_url() functionNeelesh Gupta2013-11-062-2/+4
| | | | | Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/log: Always flush after writing logsJeremy Kerr2013-11-011-2/+1
| | | | | | | | 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>
* lib/pb-config/powerpc-nvram: Use talloc_zero for interface configsJeremy Kerr2013-10-281-1/+1
| | | | | | | We're seeing a problem where ifconf->ignore isn't initialised; use talloc_zero instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add system info messagesJeremy Kerr2013-10-093-0/+132
| | | | | | | | 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>
* lib/url: talloc from new URL in pb_url_copyJeremy Kerr2013-09-261-6/+6
| | | | | | | We're ending up with members of new_url being allocated from the old URL's context. We should be tallocing from the new_url instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/system: Don't modify dir parameter to pb_rmdir_recursiveJeremy Kerr2013-09-261-3/+3
| | | | | | | We're modifying dir rather than cur (the local copy of dir), so the caller-provided (const!) string is no longer const. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't depend on tftp failure for type detectionJeremy Kerr2013-09-262-0/+15
| | | | | | | | Rather than always trying both TFTP client types, do a runtime detection on first invocation. This can be fixed at build-time with --with-tftp=TYPE. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: Add array-size headerJeremy Kerr2013-09-242-2/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement device prioritiesJeremy Kerr2013-09-192-0/+16
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Remove unnecessary event passingJeremy Kerr2013-09-191-0/+12
| | | | | | | | | | | | | | | Currently, we pass "events" between the udev, user-event and device-handler layers. These events all get sent through device_handler_event, then de-multiplexed to an appropriate handler, depending on their source. Instead, just export relevant device_handler functions, and have the (old) event sources call these functions directly. This also means we can include a lot more of the device hander code in the parser tests. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Initialise DNS server infoJeremy Kerr2013-09-191-0/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/log: Cleanup log APIJeremy Kerr2013-09-192-19/+44
| | | | | | | | | | Rather than exposing log internals (through always_flush and set_stream), do all logging init through pb_log_init(). If pb_log_init() hasn't been called, pb_log will drop messages. Also, add a pb_debug() function, specifically for debugging information. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* types: Add device_type to struct deviceJeremy Kerr2013-09-182-0/+18
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config/powerpc-nvram: Add petitboot,timeout nvram propertyJeremy Kerr2013-09-181-0/+14
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Add autoboot timeout to configuration varsJeremy Kerr2013-09-182-2/+7
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: handle EINTR from waitpidJeremy Kerr2013-08-201-2/+7
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add dry_run argument to process_initJeremy Kerr2013-08-202-2/+6
| | | | | | | Implement dry-run behaviour on the discover server by passing a bool to process_init. UIs don't need to support dry runs. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: replace pb_run_cmdJeremy Kerr2013-08-191-79/+0
| | | | | | | This change replaces the pb_run_cmd() function with proper usage of the process API. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: replace pb_run_cmd_pipeJeremy Kerr2013-08-193-124/+24
| | | | | | Replace pb_run_cmd_pipe with process_create / process_run_sync. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/waiter: handle -EINTRJeremy Kerr2013-08-191-2/+5
| | | | | | | Now that we're handing non-fatal signals (i.e., SIGCHLD in the process lib), we need to gracefully handle -EINTR from poll(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add process helpersJeremy Kerr2013-08-193-0/+515
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've grown-out of pb_run_cmd a little, as we have a number of different process types: boot(): - kexec: short-running process, run synchronously - boot hooks: short-running, run sync, need exit code & stdout network init: - interface configuration: short running, run sync - udhcp processes are long running, we may want completion, but doesn't block other actions downloads: - potentially long-running, block parse progress config nvram: - read: short running, can block, need stdout - write: short running, can block We'd like to introduce proper asynchronous processes, to allow config & boot-option downloads without blocking the discover server. This change introduces a new type for processes, 'struct process'. These structures are created with process_create, and run with process_run_sync or process_run_async. The latter reports completion through a callback member of struct process. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/waiter: remove waitset_destroyJeremy Kerr2013-08-192-6/+0
| | | | | | We can rely on the ctx free to destroy the waitset. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/waiter: talloc waiters from waitset contextJeremy Kerr2013-08-161-1/+1
| | | | | | | We can lose a reference to the first waiter allocated, as set->waiters may be NULL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud