Page MenuHomeFreeBSD

stand: add ability to reference partitions by label
Needs ReviewPublic

Authored by audrey_rhelmot.io on Mar 14 2025, 11:48 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 8, 1:35 AM
Unknown Object (File)
Thu, Apr 3, 8:05 AM
Unknown Object (File)
Mon, Mar 31, 6:00 PM
Unknown Object (File)
Fri, Mar 28, 4:27 AM
Unknown Object (File)
Tue, Mar 25, 12:12 PM
Unknown Object (File)
Wed, Mar 19, 2:02 PM
Unknown Object (File)
Wed, Mar 19, 8:20 AM
Unknown Object (File)
Wed, Mar 19, 6:00 AM

Details

Reviewers
manu
Summary

This allows the bootloader to reference files by partition label with the syntax label:$LABEL:$PATH similar to zfs:$DATASET:$PATH. The main mechanism by which this is achieved is by allowing devsw dv_parsedev functions to specify a different devsw than itself as the resulting idev's d_dev field, meaning that we can just create a new "label" devsw and have it swap out to an appropriate partition driver after parsedev. This is currently only implemented for GPT partitions, but it could realistically be extended to MBR or BSD.

I find this useful because I am trying to boot a system without the kernel copied onto the ESP, and it would be nice to not have to rely on disk indices in order to name the kernel in a loader script.

Test Plan

I'm not really sure what to write here.

I have tested this code and it works for loading kernels. This patch is currently vendored (rebased on 14.1) in the distro I'm working on and it should see a lot of use in the coming weeks.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

So, I really like this change. I have a couple of questions.

This looks good,... I'd break out the malloc -> calloc changes (since they are easy and are obviously right).
I'm less sure about the rest of the changes and need to look at the details a little better. There's some things that don't look quite right and I need more context around the changes to understand if my concerns amount to anything or not.
So please do a 'git diff -U999999' and upload that. This will give better context for me to look at the details so I can provide feedback, if necessary, about any concerns I still have after looking at the bigger picture.

And can you tell me if I should use the following as the 'author' in git?
Audrey Dutcher <audrey@rhelmot.io>

If you are expert enough with git, please separate the malloc->calloc change out and post a separate review. If doing that would delay updating the review and confirming your name, I can split the changes.

Also, have you looked at what it might take to set vfs.root.mountfrom to for labels? Right now ufs and zfs are hard coded, so to do that for labels (which would be cool) would need some work too. I think it's cool even without it, but thought I'd mention it since it would let us do things end-to-end and possibly have other labels types too, but that's also follow on.

stand/efi/libefi/efipart.c
428

what does this mean?

Factored out the calloc changes; added context

And can you tell me if I should use the following as the 'author' in git?

Yes, that's me!

have you looked at what it might take to set vfs.root.mountfrom to for labels?

I'm pretty sure the kernel supports vfs.root.mountfrom=/dev/gpt/label! That syntax doesn't really work in stand because there isn't one filesystem root.

Also, it made me fell really welcomed in this project that you added considerations for if I wasn't a git expert. Looking forward to contributing more!