summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
Commit message (Collapse)AuthorAgeFilesLines
* discover: Reject ADD_URL actions without configured networkSamuel Mendoza-Jonas2014-09-041-0/+6
| | | | | Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add missing includeJeremy Kerr2014-08-011-0/+1
| | | | | | We use setlocale() in device-handler.c, so we need locale.h Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Enable 'url' pb-eventsSamuel Mendoza-Jonas2014-07-281-0/+134
| | | | | | | | | | Adds a new option to pb-event; ./pb-event url@dev url=scheme://path/to/petitboot.conf Specifies a remote conf file to parse for boot options Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Use translated strings for boot status messagesJeremy Kerr2014-07-281-2/+2
| | | | | | | Since we're operating in the correct locale now, we can send translated strings in the boot status messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add setlocale calls in discover serverJeremy Kerr2014-07-281-0/+22
| | | | | | | | We want the discover server to respect the configured language, so we'll need to add appropriate setlocale() calls. We use the config->lang setting to use any previously-saved language. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Only update our config if the config_set succeeded.Jeremy Kerr2014-07-281-1/+6
| | | | | | | If config_set fails, we don't want to send the failed config out to clients. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add safe modeJeremy Kerr2014-07-221-0/+10
| | | | | | | | | | | 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/+20
| | | | | | If a default device is set, we only allow booting from that device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: allow separate lifetimes for network interfaces and discover devicesJeremy Kerr2014-07-211-0/+7
| | | | | | | | | | | | | We want the network code's network interfaces to (potentially) persist remove events. For example, discover devices may be removed by a user event (this happens during a udhcpc deconfig). In this case, we want the boot options to be removed, but the struct interface needs to stay present. This change adds network_(un)_register_device functions, to allow the device handler to detach from and attach to interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: place countdown earlier in boot status messagesJeremy Kerr2014-07-161-1/+1
| | | | | | | | | | The boot status messages may be trimmed on the right-hand side; In this case, we'll lose the boot countdown. This change moves the boot countdown time to before the arbitrary-length label string. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-021-1/+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>
* discover: add reinit pathJeremy Kerr2014-04-021-0/+41
| | | | | | | | | | | | | 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-021-0/+42
| | | | | | | | | | | | | | | | | | | | 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: 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-141-1/+6
| | | | | | | | | | | | | | | | | | | | | | | 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: 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: Add DEVICE_TYPE_ANY for matching any deviceJeremy Kerr2014-01-301-1/+2
| | | | | | | | | | 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-301-5/+13
| | | | | | | | | | | | 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-301-1/+1
| | | | | | | | | | | | | | | | | | 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>
* discover/device-handler: Ensure we free unresolved boot options on removeJeremy Kerr2013-12-021-0/+11
| | | | | | | | | | When we remove a device, some options may still be unresolved, and so won't be deallocated through freeing the device. This chagne explicitly removes & frees any currently-unresolved options for this device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: populate sysinfo with block devicesJeremy Kerr2013-11-221-0/+5
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Handle incoming configuration messagesJeremy Kerr2013-11-131-1/+7
| | | | | | | 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/types: use unsigned int for interface, dns and prio countsJeremy Kerr2013-11-131-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Change parsers to explicitly request configuration filesNeelesh Gupta2013-11-061-8/+26
| | | | | | | | | | | | | | | | | | | Add a new function parser_request_url() to read the data from configuration files present remotely. We deprecate iterate_parser_files() and download_config() functions along with the 'filenames' and 'method' members of the 'parser' structure so that individual parsers would now require to request the configuration files data from the parser code and doesn't necessarily export the list of configuration files. Add the support to handle incoming DHCP event, done by passing all the relevant environment variables of the udhcpc to the discover code. Also, update the pxe parser code to populate the list of configuration file names as per PXELINUX convention of fallback names using mac and ip addresses of the booting machine. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allocate contexts with talloc_zeroJeremy Kerr2013-11-061-3/+1
| | | | | | Ensure all pointers from the context are NULL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* logging: Clean up debug logsJeremy Kerr2013-11-011-3/+3
| | | | | | | We have quite a few pb_logs which should be pb_debug. This change moves developer-specific info to pb_debug. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow an in-progress boot to be cancelledJeremy Kerr2013-10-151-3/+20
| | | | | | | | | Currently, once the boot() function is called, the boot process will ignore any cancellations. This change allows boot() to be cancelled, via boot_cancel(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow device_handler_boot with no optionJeremy Kerr2013-10-101-2/+3
| | | | | | Only call find_boot_option_by_id if we have an ID. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/device-handler: Fix use-after-free when unmountingJeremy Kerr2013-10-091-2/+3
| | | | | | We need to do the rmdir after clearing mount_path. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add device_{request,release}_writeJeremy Kerr2013-10-011-3/+53
| | | | | | | | Add a pair of functions to the parser API to allow write access to the underlying device. We'll use this in the GRUB2 parser to implement environment persistence. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add test_data member to struct discover_contextJeremy Kerr2013-10-011-0/+1
| | | | | | | | We have parsers passing discover_contexts around, which we want to hook into the test framework. Add a void * member, which the test code can use to reference the test. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't continue discovery if mount failsJeremy Kerr2013-10-011-1/+5
| | | | | | | Check the return value from mount_device and abort the discover on failure. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Allow for already-mounted devicesJeremy Kerr2013-10-011-8/+81
| | | | | | | | | | | When we start the discover server, we may find that devices are already mounted. In this case, mount_device will fail, and we'll abort the parse. This change uses /proc/self/mounts to check if new devices are already mounted, and uses the existing mount point. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Check for devices with duplicate serial propertiesJeremy Kerr2013-09-241-0/+13
| | | | | | | | | If we have multipath devices present in the system, we'll end up with duplicate mounts, parse results and boot options. This change adds a check to see if we've encountered a device with this serial number previously. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: clear default_timeout waiter on timeoutJeremy Kerr2013-09-231-0/+2
| | | | | | We don't want cancel_default to try to remove an already-removed waiter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't register multiple boot_timeout waitersJeremy Kerr2013-09-231-2/+8
| | | | | | | Rather than adding another timeout waiter, just override handler->default_boot_option and extend the timeout a little. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement device prioritiesJeremy Kerr2013-09-191-4/+37
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Remove unnecessary event passingJeremy Kerr2013-09-191-328/+195
| | | | | | | | | | | | | | | 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>
* discover: Consolidate device path, name and ID.Jeremy Kerr2013-09-191-28/+7
| | | | | | | | | | | | This change cleans up our usage of device path, names and IDs. Device ID is the kernel name for the device. We also expose this through lookup_by_name. Device path is the path to the dev node (ie, always starts with /dev/), and is only used for mounting. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: populate udev device typesJeremy Kerr2013-09-181-0/+22
| | | | | | Now that we have device types, populate from the udev info. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-config: Add autoboot timeout to configuration varsJeremy Kerr2013-09-181-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: replace pb_run_cmdJeremy Kerr2013-08-191-38/+14
| | | | | | | This change replaces the pb_run_cmd() function with proper usage of the process API. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Log autoboot timeoutGeoff Levand2013-07-231-3/+5
| | | | Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover: Rename default_enabledGeoff Levand2013-07-231-4/+4
| | | | | | | Rename default_enabled to autoboot_enabled for consistency with pb-config. Signed-off-by: Geoff Levand <geoff@infradead.org>
* discover/device-handler: hook up autoboot_enabled config varJeremy Kerr2013-07-021-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add initial dtb supportGeoff Levand2013-06-241-0/+5
| | | | | | | Updates & fixes by Jeremy Kerr <jk@ozlabs.org>. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add logging for default boot option behaviourJeremy Kerr2013-06-241-0/+6
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add "cancel default boot" messagesJeremy Kerr2013-06-241-0/+29
| | | | | | | Allow the default boot process to be cancelled, via a message with action PB_PROTOCOL_ACTION_CANCEL_DEFAULT. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud