aboutsummaryrefslogtreecommitdiffstats
path: root/nlplug-findfs.c
Commit message (Collapse)AuthorAgeFilesLines
* nlplug-findfs: detect zfs poolNatanael Copa2019-01-251-1/+15
| | | | | | | | | | if search device is prefixed with ZFS= then we search for a label with the zpool name in the zfs path. For example, if search device is "ZFS=tank/alpine/root" then we search for device that is type "zfs_member" and label "tank". This makes it work better with grub which creates a boot cmdline with ZFS=
* Add support for keyfileslemmarathon2018-06-121-0/+17
| | | | | | | The "cryptkey" boot parameter enables keyfile decryption. By default, init will look for a keyfile named "/crypto_keyfile.bin". Another file may be specified like so: "cryptkey=/path/to/keyfile.bin". If keyfile decryption fails, init will fall back to passphrase mode.
* nlplug-findfs: describe -D in usagelemmarathon2018-05-071-0/+1
|
* nlplug-findfs: add primitive support for LUKS2 containersSören Tempel2018-01-251-1/+1
| | | | | | | | | Since we previously specified an explicit request_type for the crypt_load() function nlplug-findfs couldn't open LUKS2 containers. By using CRYPT_LUKS crypt_load accepts any known LUKUS container format. We could add an additional command line flag to nlplug-finds for specifying the request_type but I guess this is good enough for now.
* init: add cryptdiscards optionSören Tempel2017-08-031-1/+7
| | | | | When enabled allows the use of discard (TRIM) requests for the device. See cryptsetup(1) for more information.
* nlplug-findfs: fix the deported header feature7heo2017-04-051-0/+6
| | | | | | | | Without a call to crypt_set_data_device(), the cryptsetup system does not know where to find the data device. It works whether the header is deported or not, according to https://github.com/mbroz/cryptsetup/blob/8f84fb49faa69b0ddde3d534ee9c72119256f4c9/src/cryptsetup.c#L782 so it is fine to call it in all cases.
* nlplug-findfs: remove double \n for consistency7heo2017-04-051-2/+0
|
* nlplug-findfs: alloca isn't POSIX, use stack7heo2017-04-051-4/+5
|
* nlplug-findfs: refactor crypt device searchingNatanael Copa2017-04-051-18/+32
| | | | move the logic to separate function
* nlplug-findfs: refactor cryptsetup structsNatanael Copa2017-04-051-39/+44
| | | | | put all data related cryptsetup in a struct. No changes in functionality.
* nlplug-findfs: Support for LUKS detached header7heo2017-04-051-18/+59
|
* nlplug-findfs: dont return error on successful read passNatanael Copa2017-01-101-1/+0
| | | | | We could sucessfully read the password but fail to reset the tty. If that happens, then just warn, but return success.
* nlplug-findfs: wipe password after useNatanael Copa2017-01-101-0/+1
|
* nlplug-findfs: make sure we dont leak fd when execute lvmNatanael Copa2017-01-101-2/+2
|
* nlplug-findfs: only mount and search a device if neededNatanael Copa2017-01-101-1/+1
| | | | | we dont need mount and scan the tree if not explicitly told to look for apkovls or bootrepos.
* nlplug-findfs: Better messages7heo2017-01-101-1/+2
|
* nlplug-findfs: verify that stdin is TTY7heo2017-01-101-9/+17
|
* add zpool import capabilityMark Riedesel2016-12-241-2/+15
|
* nlplug-findfs: speed up and simplify boot media findingtteras-workTimo Teräs2016-11-231-116/+105
|
* nlplug-findfs: fix cold plug triggeringTimo Teräs2016-11-231-92/+190
|
* nlplug-findfs: improve logging about spawned commandsTimo Teräs2016-11-211-13/+39
|
* nlplug-findfs: handle uevent strictly after mdev executionTimo Teräs2016-11-211-52/+101
|
* nlplug-findfs: convert to kernel style linked lists and track spawned pidsTimo Teräs2016-11-211-32/+116
|
* nlplug-findfs: improve debugging, make device finding asyncTimo Teräs2016-11-211-53/+59
|
* nlplug-findfs: accept passphrase of non-zero slotsTimo Teräs2016-11-211-1/+1
| | | | ref #6473
* nlplug-findfs: fix erratic behavior and SIGSEGV7heo2016-09-281-1/+1
| | | | | Likely introduced in the major rehaul done in e4af128b30855b2b29a27c2fd7580b62059bbe51
* nlplug-findfs: refacor crypt device to its own structNatanael Copa2016-07-041-15/+19
| | | | makes things a bit cleaner
* nlplug-findfs: increase max delayNatanael Copa2016-06-101-10/+21
| | | | | | | | | Increase timeout to 5sec if we have not found anything so we don't get error too early. If boot repos are found then reduce the event timeout to 250ms. If usb_storage is found, then always add 1 second of delay in addition, to let the usb host settle.
* nlplug-findfs: increase the /sys recursion limitTimo Teräs2016-03-211-2/+2
| | | | | certain platform and usb devices expose things deep down the tree, increase the recursion limit
* nlplug-findfs: scan block devices on changeTimo Teräs2016-03-111-1/+1
| | | | | | | | raid disks are created zero sized. when mdadm has found all the disks it finally enables it. this causes md devices to be zero sized for some time after their creation, and blkid will not detect them. catch the 'change' notification and rescan block devices for updated blkid.
* nlplug-findfs: limit recursion depthTimo Teräs2016-03-111-7/+8
| | | | | | | Based on patch by donoban. Limit recursion depth for repository search to 2 levels (shell script had -maxdepth 3 for finding the file entry, so it's maximum of 2 levels of directories). For sysfs entries deeper search is allowed. ref #5192
* nlplug-findfs: allow success even if nothing foundNatanael Copa2016-01-181-1/+5
| | | | | add -n option to allow return success even if nothing was found. This is useful for net boot, where apkovl and repositories are on network.
* nlplug-findfs: fix usb settle delayNatanael Copa2015-12-161-10/+14
| | | | | | | kernel does not set any "DRIVER" env var in uevent from netlink so we use kmod to find usb_storage driver. We also reduce the timeout to 1 sec, which should be enough.
* nlplug-findfs: do not try execute programs that does not existsNatanael Copa2015-11-251-4/+13
| | | | | Avoid printing error message if there are lvm devices but root is not on any of those.
* nlplug-findfs: print device name user expectsNatanael Copa2015-11-251-1/+2
| | | | | | | we want print the device name that user is looking for when we prompt for cryptsetup password instead of the devname from kernel uevent. If user specified UUID, then we print kernel provided name.
* nlplug-findfs: make lvm more silentNatanael Copa2015-11-251-1/+1
| | | | | we want avoid lvm messages be printed after password prompt for cryptsetup is displayed.
* nlplug-findfs: fix cryptsetup race conditionNatanael Copa2015-11-251-18/+115
| | | | | | | | | | | | | | | | | | | We need run cryptsetup in parallel so that keyboard drivers are loaded while waiting for password input. But cryptsetup will recreate the device which means that the uevent for new device node will first be added then changed and finally will it create the /dev/mapper/* device node. We handle the first generated uevent and while handling, the device node might have disappeared causeing blkid not find any UUID, and the /dev/mapper/* does not yet exist. This means that we need to: - handle uevents in parallel while waiting for password input - block uevent handling while actually setting up the crypt device So we use libcryptsetup and add a mutex while setting up the crypt device.
* nlplug-findfs: use bit mask to indicate running threadNatanael Copa2015-11-251-5/+12
| | | | | Use a bit mask to indicate trigger thread. This is so we can have more threads in future.
* nlplug-findfs: compare device node major/minorNatanael Copa2015-11-241-15/+29
| | | | | | | | | Fix issue where /dev/vg0/lv_device is used as crypt device. We compare the major/minor of the event with the device we are searching for. That way we can find the device we are looking for regardless of the name it gets. ref #4863
* nlplug-findfs: improve debug infoNatanael Copa2015-11-231-2/+3
| | | | | | | - print only once when we reset timeout - print what the timeout was set to on exit This helps to show if what we were looking for was found or not
* nlplug-findfs: asynchronously fork child processesTimo Teräs2015-10-241-82/+185
| | | | | | | | instead of waiting each child to run end before continuing, fork or queue each command allowing up to CPU count concurrent childs. this enables full use of SMP cores, and allows loading of modules after a blocking command is started; fixing e.g. keyboard driver to load even if crypto disk command is waiting keyboard input.
* nlplug-findfs: check for valid key value pair in uevent processingTimo Teräs2015-10-241-1/+1
| | | | just to be on the safe side
* nlplug-findfs: make all functions staticTimo Teräs2015-10-231-16/+14
|
* nlplug-findfs: maintain environment for exec's in arrayTimo Teräs2015-10-231-22/+30
| | | | | | Using clearenv and setenv is slow, non-thread safe and problematic. This makes PATH inherited from parent environment, and explicitly constructs the rest of the environment for mdev.
* nlplug-findfs: support search for /dev/<devname>Natanael Copa2015-10-221-2/+3
| | | | this is so we also can specify cryptroot=/dev/sdaX at boot prompt
* nlplug-findfs: make sure we handle all events in queueNatanael Copa2015-10-191-1/+7
| | | | | | | | | | we want handle all the events in queue, even if we find the devices we are looking for. This is so we load kernel module for framebuffer even if the apkvol and bootrepo are found first. This means that the only valid exit condition is a poll timeout and that we can set the timeout to 0 once we found all the things we are looking for.
* nlplug-findfs: wait indefinitively til trigger thread is completeNatanael Copa2015-10-191-11/+14
| | | | | | make sure that we dont exit before the trigger thread is complete, regardless if we find the devices/bootrepo/apkovl we are looking for or not.
* nlplug-findfs: use DT_UNKNOWN to detect if lstat is to be usedNatanael Copa2015-10-191-10/+4
|
* nlplug-findfs: dont exit before trigger thread is completeNatanael Copa2015-10-141-1/+1
|
* nlplug-findfs: avoid lstat syscall wen scanning /sys if possibleNatanael Copa2015-10-091-5/+18
| | | | | | | There are ~10k entries in /sys so we want be fast. Not all filesystems supports dirent filed d_type, (iso9660 for example) so we need use lstat to find directories. However, we know that sysfs supports it, so we can avoid 10k lstat syscalls. This might be noticiable difference on rpi.