diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-05 05:09:22 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-06-05 05:09:22 +0200 |
commit | bbc35cc01b3632fe345244a5a366dd5e80755265 (patch) | |
tree | 8188a5280eac9d16ad76f5cb5a1eaed0eebf8698 /sys/src/boot | |
parent | 045530aed25b515d501e7502af2c42ecf66d6dd2 (diff) |
9boot: look for plan9.ini in all filesystems accessible to efi to find plan9 partition
try the handle buffer in reverse order looking for plan9.ini
to find plan9 partition (9fat). when that fails, we'll default
to the first handle which should be the esp.
Diffstat (limited to 'sys/src/boot')
-rw-r--r-- | sys/src/boot/efi/fs.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/sys/src/boot/efi/fs.c b/sys/src/boot/efi/fs.c index 7850a5e81..c6d2331a8 100644 --- a/sys/src/boot/efi/fs.c +++ b/sys/src/boot/efi/fs.c @@ -87,23 +87,48 @@ int fsinit(void **pf) { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs; + EFI_FILE_PROTOCOL *root; + EFI_HANDLE *Handles; + void *f; + UINTN Count; + int i; - fs = nil; - fsroot = nil; - if(eficall(ST->BootServices->LocateProtocol, - &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, nil, &fs)) - return -1; - if(eficall(fs->OpenVolume, fs, &fsroot)){ - fsroot = nil; + Count = 0; + Handles = nil; + if(eficall(ST->BootServices->LocateHandleBuffer, + ByProtocol, &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, nil, &Count, &Handles)) return -1; + + /* + * assuming the ESP is the first entry in the handle buffer, so go backwards + * to scan for plan9.ini in other (9fat) filesystems first. if nothing is found + * we'll be defaulting to the ESP. + */ + fsroot = nil; + for(i=Count-1; i>=0; i--){ + root = nil; + fs = nil; + if(eficall(ST->BootServices->HandleProtocol, + Handles[i], &EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, &fs)) + continue; + if(eficall(fs->OpenVolume, fs, &root)) + continue; + fsroot = root; + f = fsopen("/plan9.ini"); + if(f != nil){ + if(pf != nil) + *pf = f; + else + fsclose(f); + break; + } } + if(fsroot == nil) + return -1; read = fsread; close = fsclose; open = fsopen; - if(pf != nil) - *pf = fsopen("/plan9.ini"); - return 0; } |