Skip to content

Latest commit

 

History

History
118 lines (83 loc) · 3.88 KB

BSD_PORTING.md

File metadata and controls

118 lines (83 loc) · 3.88 KB

Relation to upstream

Based on top of 38 release and patches added on top of it up to September 2022, all of which are fixes that should have no functional changes, but are useful for porting, although "LLD: fix detection and remove not needed workarounds" was reverted to make build work with lld 13.0.

API readiness

libefivar: errors

Debug logging is off as it is on Android systems and for the same reason: the implementation relies on fopencookie() GNU extension.

libefivar: EFI variables and GUIDs

There is an extra mode_t parameter in efi_set_variable() as well as efi_chmod_variable(), which are specific to pseudo file-systems of Linux. The parameter is ignored and the function succeed while doing nothing.

libefivar: device paths

This provides means for manipulating data structures that describe device paths. Should work fine as it's not system-specific.

libefivar: time

Should work properly, it's about time converting and formatting.

libefiboot: load options

Should work as expected. It's another data formatting API for things like Boot0001 variables.

libefiboot: device path generation

efi_generate_ipv4_device_path() doesn't work. Needs platform-specific implementation for querying things like MAC address.

efi_generate_file_device_path() should work only if abbreviated device path is requested and implementation can handle disk/partition devices on the system (find parent device from partition device, see more on this below). Drives without a partition table might have some issues, needs testing.

efi_generate_file_device_path_from_esp() is also restricted to abbreviated device paths and might not work if implementation can't derive partition device name from a combination of disk device name and partition number.

When non-abbreviated device path is requested, the invocation fails with EINVAL error.

libsecdb

Should work. It's about manipulating data in files with no special requirements on the environment.

Support of different BSD variants

FreeBSD/DragonflyBSD

These use device naming scheme that's easy to parse and thus shouldn't have much issues.

NetBSD

Assumption is that wedges are enabled (dk driver) and are used.

Conventional partition names (i.e., "slices" like sd3f) seem to lack an API for querying partition number and their support is thus limited. Disk label obtained from DIOCGDINFO ioctl() has empty partition table.

Might need to add a new ioctl() for partitions to make this work reliably. Need to know partition number in some way. Getting just partition's offset on a disk might take less work in the kernel, will then need to look it up in MBR/GPT, which is done by the code anyway to fetch other information.

OpenBSD

No wedges here, only slices, but DIOCGPDINFO ioctl() (note that "P" which NetBSD doesn't have, not a typo) provides offsets at least for some drives (weirdly, root drive seems missing), allowing the translation between partition number and device name.

Prospects

A nice thing to do would be to group more of platform specific things to get rid of #ifdefs. Also dev_probes array (currently in linux.c) could be changed to be constructed by the linker to remove declaration dependencies between files and allow managing available probes by the build system by including only certain source files.

Supporting unabbreviated device paths would take querying logical topology of drives (ACPI, PCI, USB, etc.).

Random notes

Partition number is base 1, partition number 0 is the drive itself.

Questions

FreeBSD has only p in device names and DragonflyBSD has only s in them or both p and s can appear in both kinds of systems?