@@ -78,7 +78,7 @@ static CHAR16* GetDriverName(CONST EFI_HANDLE DriverHandle)
78
78
* To fix it we disconnect drivers that connected to DiskIo BY_DRIVER if this
79
79
* is a partition volume and if those drivers did not produce file system.
80
80
*
81
- * This code was originally derived from similar BSD-3-Clause license one
81
+ * This code was originally derived from similar BSD-3-Clause licensed one
82
82
* (a.k.a. Modified BSD License, which can be used in GPLv2+ works), found at:
83
83
* https://sourceforge.net/p/cloverefiboot/code/3294/tree/rEFIt_UEFI/refit/main.c#l1271
84
84
*/
@@ -202,9 +202,9 @@ static EFI_STATUS PrintSystemInfo(VOID)
202
202
SecureBootStatus = -1 ;
203
203
// Wasteful, but we can't highlight "Enabled"/"Setup" from a %s argument...
204
204
if (SecureBootStatus > 0 )
205
- PrintInfo (L"Secure Boot status: %HEnabled%N " );
205
+ PrintInfo (L"Secure Boot status: Enabled " );
206
206
else if (SecureBootStatus < 0 )
207
- PrintInfo (L"Secure Boot status: %ESetup%N " );
207
+ PrintInfo (L"Secure Boot status: Setup " );
208
208
else
209
209
PrintInfo (L"Secure Boot status: Disabled" );
210
210
@@ -222,6 +222,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
222
222
CONST CHAR16 * FsName [] = { L"NTFS" , L"exFAT" };
223
223
CONST CHAR16 * DriverName [] = { L"ntfs" , L"exfat" };
224
224
CHAR16 DriverPath [64 ], LoaderPath [64 ];
225
+ CHAR16 * DevicePathString ;
225
226
EFI_LOADED_IMAGE_PROTOCOL * LoadedImage ;
226
227
EFI_STATUS Status ;
227
228
EFI_DEVICE_PATH * DevicePath , * ParentDevicePath = NULL , * BootDiskPath = NULL ;
@@ -245,7 +246,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
245
246
// The platform logo may still be displayed → remove it
246
247
SystemTable -> ConOut -> ClearScreen (SystemTable -> ConOut );
247
248
248
- Print (L"\n%H *** UEFI:NTFS %s (%s) ***%N \n\n" , VERSION_STRING , Arch );
249
+ Print (L"\n*** UEFI:NTFS %s (%s) ***\n\n" , VERSION_STRING , Arch );
249
250
#if defined(_GNU_EFI )
250
251
PrintSystemInfo ();
251
252
#endif
@@ -265,7 +266,9 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
265
266
BootDiskPath = GetParentDevice (BootPartitionPath );
266
267
267
268
PrintInfo (L"Searching for target partition on boot disk:" );
268
- PrintInfo (L" %D" , BootDiskPath );
269
+ DevicePathString = DevicePathToString (BootDiskPath );
270
+ PrintInfo (L" %s" , DevicePathString );
271
+ SafeFree (DevicePathString );
269
272
// Enumerate all disk handles
270
273
Status = gBS -> LocateHandleBuffer (ByProtocol , & gEfiDiskIoProtocolGuid ,
271
274
NULL , & HandleCount , & Handles );
@@ -318,7 +321,9 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
318
321
goto out ;
319
322
}
320
323
PrintInfo (L"Found %s target partition:" , FsName [FsType ]);
321
- PrintInfo (L" %D" , DevicePath );
324
+ DevicePathString = DevicePathToString (DevicePath );
325
+ PrintInfo (L" %s" , DevicePathString );
326
+ SafeFree (DevicePathString );
322
327
323
328
PrintInfo (L"Checking if target partition needs the %s service" , FsName [FsType ]);
324
329
// Test for presence of file system protocol (to see if there already is
@@ -327,10 +332,10 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
327
332
(VOID * * )& Volume , MainImageHandle , NULL , EFI_OPEN_PROTOCOL_TEST_PROTOCOL );
328
333
if (Status == EFI_SUCCESS ) {
329
334
// A filesystem driver is already set => no need to start ours
330
- PrintWarning (L" An %s service is already loaded" , FsName [FsType ]);
335
+ PrintWarning (L" An %s driver service is already loaded" , FsName [FsType ]);
331
336
} else if (Status == EFI_UNSUPPORTED ) {
332
337
// Partition is not being serviced by a file system driver yet => start ours
333
- PrintInfo (L"Starting %s partition service:" , FsName [FsType ]);
338
+ PrintInfo (L"Starting %s driver service:" , FsName [FsType ]);
334
339
335
340
// Use 'rufus' in the driver path, so that we don't accidentally latch onto a user driver
336
341
UnicodeSPrint (DriverPath , ARRAY_SIZE (DriverPath ), L"\\efi\\rufus\\%s_%s.efi" , DriverName [FsType ], Arch );
@@ -424,8 +429,14 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
424
429
VolumeInfo = (EFI_FILE_SYSTEM_VOLUME_LABEL * )AllocateZeroPool (Size );
425
430
if (VolumeInfo != NULL ) {
426
431
Status = Root -> GetInfo (Root , & gEfiFileSystemVolumeLabelInfoIdGuid , & Size , VolumeInfo );
427
- if ((Status == EFI_SUCCESS ) && (VolumeInfo -> VolumeLabel [0 ] != 0 ))
432
+ // Some UEFI firmwares return EFI_BUFFER_TOO_SMALL, even with
433
+ // a large enough buffer, unless the exact size is requested.
434
+ if ((Status == EFI_BUFFER_TOO_SMALL ) && (Size <= FILE_INFO_SIZE ))
435
+ Status = Root -> GetInfo (Root , & gEfiFileSystemVolumeLabelInfoIdGuid , & Size , VolumeInfo );
436
+ if (Status == EFI_SUCCESS )
428
437
PrintInfo (L" Volume label is '%s'" , VolumeInfo -> VolumeLabel );
438
+ else
439
+ PrintWarning (L" Could not read volume label: [%d] %r\n" , (Status & 0x7FFFFFFF ), Status );
429
440
FreePool (VolumeInfo );
430
441
}
431
442
@@ -467,7 +478,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
467
478
468
479
// Wait for a keystroke on error
469
480
if (EFI_ERROR (Status )) {
470
- Print (L"%H \nPress any key to exit.%N \n" );
481
+ Print (L"\nPress any key to exit.\n" );
471
482
gST -> ConIn -> Reset (gST -> ConIn , FALSE);
472
483
gST -> BootServices -> WaitForEvent (1 , & gST -> ConIn -> WaitForKey , & Event );
473
484
}
0 commit comments