summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
...
* | commands: provide efi_handle_dump in both payload and loaderAhmad Fatoum2024-03-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | The efi_handle_dump command is currently used when barebox is built as payload, but it's also useful when running as a loader to list handles and their protocols. Move the code into a common area to make it accessible in both configurations. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-109-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: let compiler worry about unaligned unpackingAhmad Fatoum2024-03-051-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Device path nodes are tightly packed and subsequent device nodes may start at any boundary. To parse these, existing code allocated a new buffer and unpacked device paths into it, so they are at a natural boundary (chosen as 8 bytes with x86_64 in mind). We can simplify this by using __packed and letting the compiler worry about not generating unaligned accesses. This has the benefit of simplifying the incoming EFI loader implementation and we now no longer leak the unpacked EFI device path. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-107-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: drop unused macroAhmad Fatoum2024-03-051-2/+0
| | | | | | | | | | | | | | | | This is used no where, so it can just be dropped. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-106-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: use flexible array members for trailing stringsAhmad Fatoum2024-03-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | When we start using fortified string operations in the future, we will need to replace zero and one sized trailing arrays with flexible arrays where required everywhere, but for now let's just avoid having any in the EFI code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-105-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: namespace definitionsAhmad Fatoum2024-03-051-81/+81
| | | | | | | | | | | | | | | | | | Using a DEVICE_PATH_ prefix everywhere will make it clear what the definitions is about and in part align us with the naming in U-Boot. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-104-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: drop underscores in hex constantsAhmad Fatoum2024-03-051-2/+2
| | | | | | | | | | | | | | | | | | The macros couldn't be used before as they would fail to parse, but we will start using BBS_TYPE_UNKNOWN. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-103-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: move END device node definitions into headerAhmad Fatoum2024-03-051-0/+10
| | | | | | | | | | | | | | | | | | While at it, drop DP_IS_END_TYPE and DP_IS_END_SUBTYPE, which are unused. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-102-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: payload: dynamically determine bootloader file nameAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | \EFI\BOOT\BOOTx64.EFI is only the default file path for x86_64. It's different for other architectures and even for x86_64, the EFI loader may be configured to execute a differently named file. Fix this by querying the EFI loader for the file name instead of hardcoding it and while at it, we add debug prints for the loaded image and its parent to make it easier to debug in future. On the off chance, that the EFI firmware doesn't inform us of a file name this way, we revert back to a hardcoded value, that is architecture-dependent. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-94-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: string: import Linux strreplace helperAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | | | | | | | This helper replaces all occurrences of a given character in a string. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-93-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: implement device_path_to_str_buf variantAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Existing device_path_to_str() formats a buffer once to determines the amount of space necessary and then allocates it and formats it again. To make this functionality available as printf format specifier, we need a variant that doesn't allocate memory and that's preferably single pass, which we add here. No functional change for users of device_path_to_str(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-90-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: devicepath: improve const safetyAhmad Fatoum2024-03-051-5/+5
| | | | | | | | | | | | | | | | | | The device path traversal functions don't modify the device path itself, so reflect that in the function prototypes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-88-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM64: add optional EFI stubAhmad Fatoum2024-03-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | While very recent binutils releases have dedicated efi-*-aarch targets, we may want to support older toolchains. For this reason, we import the kernel's EFI stub PE fakery, so the same barebox-dt-2nd.img may be loaded as if it were a "normal" or an EFI-stubbed kernel. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-87-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: payload: factor C efi_main into dedicated fileAhmad Fatoum2024-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | For barebox as EFI payload on ARM, we will not call start_barebox() ourselves as we will be using PBL, which we don't on x86 yet. Therefore move that code out of the common init.c into a new entry-single.c and early-mem.c that can be used as needed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-84-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | filetype: add new file types for EFI-enabled Linux imagesAhmad Fatoum2024-03-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | We currently detect EFI-stubbed Linux images for ARM64 and RISC-V as normal kernel images and would boot them that way. As these images additionally start with MZ like normal PE executables, lets have new filetypes for them. No functional change yet, but we can use a different bootm handler for them in the future when boot is configured to be EFI-enabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-82-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: stdio: fix efi_register_keystroke_notify prototypeAhmad Fatoum2024-03-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | The keydata passed to efi_register_keystroke_notify is passed by reference, not by value, according to spec. This introduced no functional change as we don't yet use the prototype. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-80-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: fs: flesh out file system definitionsAhmad Fatoum2024-03-051-14/+65
| | | | | | | | | | | | | | | | | | | | A number of members aren't prototyped or are using compatible, but less descriptive. In preparation for adding EFI loader as another user of these definitions, flesh them out. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-79-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: efi: move definitions into headerAhmad Fatoum2024-03-051-0/+59
| | | | | | | | | | | | | | | | | | EFI loader support will require access to these same definitions, so move them into a header. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-78-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: improve usability of EFI_PAGE_* macrosAhmad Fatoum2024-03-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | EFI code may want to mask addresses to check if they are page aligned. Add a macro that masks the lower bits and while at it turn the type of EFI_PAGE_SIZE to be 64 bits, so we avoid issues of truncation during multiplication with a 32 bit value. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-77-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: add efi_driver_binding_protocolAhmad Fatoum2024-03-051-0/+19
| | | | | | | | | | | | | | | | | | We didn't need this for the EFI payload use case, but will need this for the EFI loader use case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-76-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: flesh out EFI definitions in headerAhmad Fatoum2024-03-052-49/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a lot of function pointer members in the protocols, that were defined as void pointers instead of properly prototyped function pointers. Similarly, a lot of data types are defined to equivalent types that aren't as descriptive, e.g. size_t vs ulong and s16 vs efi_char16_t. Let's switch them over all at once. No functional change as the types are either equivalent or were unused in the case of function pointers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-75-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: add EFI_WARN constantsAhmad Fatoum2024-03-051-0/+8
| | | | | | | | | | | | | | | | | | These constants can be returned by some of the EFI loader protocols implemented later on. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-72-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: rename efi_simple_input_interface to efi_simple_text_input_protocolAhmad Fatoum2024-03-051-5/+5
| | | | | | | | | | | | | | | | This aligns the name with what's in the specification. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-71-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: constify guid_t in APIAhmad Fatoum2024-03-051-4/+4
| | | | | | | | | | | | | | | | | | Improve const safety by marking parameters that are pointers to const as such. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-70-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: define efi_handle_t as opaque pointerAhmad Fatoum2024-03-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Typedef'ing efi_handle_t as void * means that we don't catch instance where we pass a double indirect pointer when a normal pointer is expected. With loader support, we will start to dereference it anyway, so have it point at an opaque type instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-69-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: block: move definitions into header fileAhmad Fatoum2024-03-051-0/+27
| | | | | | | | | | | | | | | | | | We will need these definitions for the EFI loader as well, so move them into a header. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-68-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: use efi_handle_t where appropriateAhmad Fatoum2024-03-051-5/+5
| | | | | | | | | | | | | | | | | | | | efi_handle_t is a typedef for a void pointer. We use either void * directly or unsigned long at places, where a handle would be the more descriptive type. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-67-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: add PE/COFF loaderAhmad Fatoum2024-03-053-0/+607
| | | | | | | | | | | | | | | | | | EFI loader will need to parse and load PE executables. Add functions to facilitate that. The API is inspired by the already existing ELF API. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-66-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | boarddata: add barebox_boarddata_is_machine helperAhmad Fatoum2024-03-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | In a later commit, the same barebox binary may be used either as EFI payload or as EFI loader being initialized from the device tree. The difference will be the barebox_boarddata, so add a helper for checking it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-65-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: make board data definitions accessible to other architecturesAhmad Fatoum2024-03-051-0/+41
| | | | | | | | | | | | | | | | | | | | | | struct barebox_arm_boarddata is a way for PBL to handover a machine number instead of a FDT. We will reuse this mechanism to hand over EFI image handle and system table in a later commit, so prepare for that by moving it to a central location and adjust the naming. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-64-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: payload: suppress EFI payload initcalls when not EFI-loadedAhmad Fatoum2024-03-053-6/+54
| | | | | | | | | | | | | | | | | | | | | | | | For development, it has proven very useful to be able to load the same barebox binary both as EFI loader and EFI payload and debug the interaction. For this to work, we need to mark all current EFI payload initcalls as such to avoid running them when barebox is not running as EFI payload. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-63-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: add efi_is_loader/efi_is_payload helpersAhmad Fatoum2024-03-051-0/+30
| | | | | | | | | | | | | | | | | | | | | | So far, whether we are running under EFI was a compile-time decision. This will change with ARM support, where the same barebox binary can either probe from DT or from EFI. Prepare for this by adding helpers to determine whether barebox is acting as EFI loader or as payload. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-62-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: payload: fix ARM buildAhmad Fatoum2024-03-051-1/+1
| | | | | | | | | | | | | | | | | | So far we only ever built EFI for x86. Prepare building it for ARM by removing the x86-specific attributes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-60-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | pbl: introduce CONFIG_PBL_FULLY_PICAhmad Fatoum2024-03-052-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the quest for making barebox PBL code W^X mappable, we have now taken care to make the ARM64 assembly routines not emit code relocations, so let's do the same for the C code as well. We do this by setting pragma GCC visibility push(hidden) globally. This option is stronger than -fvisibility=hidden and ensures we are completely position-independent. See kernel commit e544ea57ac07 ("x86/boot/compressed: Force hidden visibility for all symbol references") for more information. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-59-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: efi-guid: add more GUIDsAhmad Fatoum2024-03-051-0/+59
| | | | | | | | | | | | | | | | | | These GUIDs will be useful for the incoming EFI loader support, so add them all at once. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-56-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: unify whitespace for GUIDsAhmad Fatoum2024-03-051-43/+43
| | | | | | | | | | | | | | | | | | Half the GUID definitions indent with a tab and the other with 4 spaces. Stick to 4 spaces throughout and remove the discrepancy. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-55-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: make headers self-containedAhmad Fatoum2024-03-057-73/+92
| | | | | | | | | | | | | | | | | | | | With the loader support, efi.h will grow quite a bit. To avoid having to include it always, lets move the base definitions into a new <efi/types.h> and make the different <efi/*.h> headers self contained. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-54-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | efi: don't hide structs, enums or unions behind _tAhmad Fatoum2024-03-053-53/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Kernel coding style is to usually not hide the fact that a type is a struct or enum behind a typedef. Follow that in the EFI code. Besides being more descriptive, this also allows forward declarations, so <efi.h> doesn't have to be included everywhere. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-53-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | filetype: have cdev_detect_type take a cdevAhmad Fatoum2024-03-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | cdev_detect_type reads as if it would take a cdev argument, but instead it takes the adev's path. Fix it, so it takes a cdev and change the only user. A new user will be added later that will pass in an already open cdev. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-51-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: time: refactor into new strjoinAhmad Fatoum2024-03-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | time concatenates all its remaining arguments with a space in-between and then passes that to the command executor. This can be useful elsewhere as well, so factor it out into a new strjoin function. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-49-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: stat: add option for statatAhmad Fatoum2024-03-051-1/+1
| | | | | | | | | | | | | | | | | | The stat command is a debugging aid for developing the VFS, so it makes sense to add support for dirfd, so they can be tested interactively. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-44-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: introduce new findmnt commandAhmad Fatoum2024-03-052-0/+7
| | | | | | | | | | | | | | | | | | | | EFI loader support will need to map barebox VFS paths to fs_device and back. Make development easier by providing a findmnt command to test the mapping. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-40-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: implement O_CHROOTAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For use by EFI file system path resolution, implement an O_CHROOT flag that will map / to the root of the file system the dirfd points to instead of the VFS root. If the dirfd points to a mountpoint, it will be followed to the file system inside. This is similar to Linux openat2 with RESOLVE_IN_ROOT. Without this, the EFI protocol would have to do path sanitization itself before passing paths to the barebox VFS implementation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-39-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: implement O_PATHAhmad Fatoum2024-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | For use with the newly added openat and friends API, add O_PATH file descriptors that are not usable for doing actual I/O, but only for use as dirfd. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-37-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: implement openat and friendsAhmad Fatoum2024-03-054-8/+51
| | | | | | | | | | | | | | | | | | | | | | | | The EFI file system API takes as handle an arbitrary file within the volume. Directory iteration should happen relative to that file, which lends itself well to mapping this to openat and friends. Add support for these to barebox in preparation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-36-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: implement fdopendir and rewinddirAhmad Fatoum2024-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | We will be using the incoming O_PATH support to implement the EFI file system protocol for when barebox acts as EFI loader. The protocol also requires being able to rewind iteration, so add support for that too. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-32-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: opendir: reference mount point until closedir is calledAhmad Fatoum2024-03-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We currently don't keep the path used for opendir alive beyond the function, because all files are read and added into a linked list at once. If an unmount happens before closedir though, the file names will become invalidated, which shouldn't happen. Keep the path alive for longer to block unmount until directory iteration is over. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-30-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: drop unused LOOKUP_ flagsAhmad Fatoum2024-03-051-13/+0
| | | | | | | | | | | | | | | | | | Most flags used during VFS lookup are apparently unused, so let's delete them to make the code easier to reason about. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-29-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: turn creat into static inline helperAhmad Fatoum2024-03-051-1/+5
| | | | | | | | | | | | | | | | | | creat is a oneliner that can be inlined at no extra cost, so move it into a header. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-28-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | include: add definitions for UAPI discoverable partitions specAhmad Fatoum2024-03-051-0/+370
| | | | | | | | | | | | | | | | | | | | Now that we remember the Type GUID of block devices, let's import the UUIDs assigned by the UAPI group discoverable partition specification as found in systemd v255's src/systemd/sd-gpt.h. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-25-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | block: record block device typeAhmad Fatoum2024-03-052-3/+18
| | | | | | | | | | | | | | | | | | | | Software running under EFI can query the type of a block device. For barebox to be able to report this, start assigning types to all block devices it can create. No functional change yet. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-24-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>