summaryrefslogtreecommitdiff
path: root/0029-CryptoPkg-CrtLib-add-access-open-read-write-close-sy.patch
blob: b32c5bd9bf10845aff43ae7b11dc89ac74905325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
From 168cfe83b250d3166817549c1e96e6b1f02bcab4 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
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 <kraxel@redhat.com>
---
 .../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 37cdecc9bd..dfdb635536 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c
@@ -550,6 +550,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 f36fe08f0c..7d98496af8 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -78,6 +78,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 */
@@ -102,6 +103,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
 //
@@ -324,6 +334,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 *