From b9adc98473593da055c45f036219a469ceddbc34 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 28 Aug 2023 13:27:09 +0200 Subject: [PATCH] CryptoPkg/CrtLib: add access/open/read/write/close syscalls Needed by rhel downstream openssl patches, they use unix syscalls for file access (instead of fopen + friends like the rest of the code base). No actual file access is needed for edk2, so just add stubs to make linking work. Signed-off-by: Gerd Hoffmann --- .../Library/BaseCryptLib/SysCall/CrtWrapper.c | 46 +++++++++++++++++++ CryptoPkg/Library/Include/CrtLibSupport.h | 41 +++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c index b114cc069a..6ba751c1f1 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c @@ -589,6 +589,52 @@ fread ( return 0; } +int +access( + const char*, + int + ) +{ + return -1; +} + +int +open ( + const char *, + int + ) +{ + return -1; +} + +ssize_t +read ( + int, + void*, + size_t + ) +{ + return -1; +} + +ssize_t +write ( + int, + const void*, + size_t + ) +{ + return -1; +} + +int +close ( + int + ) +{ + return -1; +} + uid_t getuid ( void diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h index cd51e197e7..b1616a7b4c 100644 --- a/CryptoPkg/Library/Include/CrtLibSupport.h +++ b/CryptoPkg/Library/Include/CrtLibSupport.h @@ -79,6 +79,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // // Definitions for global constants used by CRT library routines // +#define EINTR 4 #define EINVAL 22 /* Invalid argument */ #define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ #define INT_MAX 0x7FFFFFFF /* Maximum (signed) int value */ @@ -103,6 +104,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define NS_INADDRSZ 4 /*%< IPv4 T_A */ #define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */ +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 + +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_OK 0 + // // Basic types mapping // @@ -329,6 +339,37 @@ fprintf ( ... ); +int +access( + const char*, + int + ); + +int +open ( + const char *, + int + ); + +ssize_t +read ( + int, + void*, + size_t + ); + +ssize_t +write ( + int, + const void*, + size_t + ); + +int +close ( + int + ); + time_t time ( time_t *