From ab99061ccc218f6a71df049be1228187d7eb7a48 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Fri, 14 Jun 2013 01:58:12 +0000 Subject: Please find this patch that makes FatGetCurrentFatTime() always return a valid time. Without this patch if gRT->GetTime fails to return the time then some operations on the filesystem could fail. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin Reviewed-by: Ruiyu Ni (based on FatPkg commit c9429aef66663a27642bdaa3685e8a86f7bc74c7) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen Acked-by: Laszlo Ersek Acked-by: Leif Lindholm --- FatPkg/EnhancedFatDxe/Misc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'FatPkg') diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c index b62c4c54ae..9a8f3cab4f 100644 --- a/FatPkg/EnhancedFatDxe/Misc.c +++ b/FatPkg/EnhancedFatDxe/Misc.c @@ -342,9 +342,19 @@ Returns: --*/ { - EFI_TIME Now; - gRT->GetTime (&Now, NULL); - FatEfiTimeToFatTime (&Now, FatNow); + EFI_STATUS Status; + EFI_TIME Now; + + Status = gRT->GetTime (&Now, NULL); + if (!EFI_ERROR (Status)) { + FatEfiTimeToFatTime (&Now, FatNow); + } else { + ZeroMem (&Now, sizeof (EFI_TIME)); + Now.Year = 1980; + Now.Month = 1; + Now.Day = 1; + FatEfiTimeToFatTime (&Now, FatNow); + } } BOOLEAN -- cgit v1.2.3