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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
--- src/drm-shim/drm_shim.c 2025-07-14 02:47:27.834000000 +0000
+++ src/drm-shim/drm_shim.c 2025-07-14 02:58:33.373000000 +0000
@@ -324,8 +324,6 @@
return real_fopen(path, mode);
}
-PUBLIC FILE *fopen64(const char *path, const char *mode)
- __attribute__((alias("fopen")));
/* Intercepts access(render_node_path) to trick drmGetMinorType */
PUBLIC int access(const char *path, int mode)
@@ -371,7 +369,6 @@
return fd;
}
-PUBLIC int open64(const char*, int, ...) __attribute__((alias("open")));
/* __open64_2 isn't declared unless _FORTIFY_SOURCE is defined. */
PUBLIC int __open64_2(const char *path, int flags);
@@ -429,45 +426,6 @@
return 0;
}
-/* Fakes stat to return character device stuff for our fake render node. */
-PUBLIC int __xstat64(int ver, const char *path, struct stat64 *st)
-{
- init_shim();
-
- /* Note: call real stat if we're in the process of probing for a free
- * render node!
- */
- if (render_node_minor == -1)
- return real___xstat64(ver, path, st);
-
- if (hide_drm_device_path(path)) {
- errno = ENOENT;
- return -1;
- }
-
- /* Fool libdrm's probe of whether the /sys dir for this char dev is
- * there.
- */
- char *sys_dev_drm_dir;
- nfasprintf(&sys_dev_drm_dir,
- "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
- if (strcmp(path, sys_dev_drm_dir) == 0) {
- free(sys_dev_drm_dir);
- return 0;
- }
- free(sys_dev_drm_dir);
-
- if (strcmp(path, render_node_path) != 0)
- return real___xstat64(ver, path, st);
-
- memset(st, 0, sizeof(*st));
- st->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- st->st_mode = S_IFCHR;
-
- return 0;
-}
-
/* Fakes fstat to return character device stuff for our fake render node. */
PUBLIC int __fxstat(int ver, int fd, struct stat *st)
{
@@ -485,22 +443,6 @@
return 0;
}
-PUBLIC int __fxstat64(int ver, int fd, struct stat64 *st)
-{
- init_shim();
-
- struct shim_fd *shim_fd = drm_shim_fd_lookup(fd);
-
- if (!shim_fd)
- return real___fxstat64(ver, fd, st);
-
- memset(st, 0, sizeof(*st));
- st->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- st->st_mode = S_IFCHR;
-
- return 0;
-}
-
#else
PUBLIC int stat(const char* path, struct stat* stat_buf)
@@ -541,44 +483,6 @@
return 0;
}
-PUBLIC int stat64(const char* path, struct stat64* stat_buf)
-{
- init_shim();
-
- /* Note: call real stat if we're in the process of probing for a free
- * render node!
- */
- if (render_node_minor == -1)
- return real_stat64(path, stat_buf);
-
- if (hide_drm_device_path(path)) {
- errno = ENOENT;
- return -1;
- }
-
- /* Fool libdrm's probe of whether the /sys dir for this char dev is
- * there.
- */
- char *sys_dev_drm_dir;
- nfasprintf(&sys_dev_drm_dir,
- "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
- if (strcmp(path, sys_dev_drm_dir) == 0) {
- free(sys_dev_drm_dir);
- return 0;
- }
- free(sys_dev_drm_dir);
-
- if (strcmp(path, render_node_path) != 0)
- return real_stat64(path, stat_buf);
-
- memset(stat_buf, 0, sizeof(*stat_buf));
- stat_buf->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- stat_buf->st_mode = S_IFCHR;
-
- return 0;
-}
-
PUBLIC int fstat(int fd, struct stat* stat_buf)
{
init_shim();
@@ -594,22 +498,6 @@
return 0;
}
-
-PUBLIC int fstat64(int fd, struct stat64* stat_buf)
-{
- init_shim();
-
- struct shim_fd *shim_fd = drm_shim_fd_lookup(fd);
-
- if (!shim_fd)
- return real_fstat64(fd, stat_buf);
-
- memset(stat_buf, 0, sizeof(*stat_buf));
- stat_buf->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- stat_buf->st_mode = S_IFCHR;
-
- return 0;
-}
#endif
/* Tracks if the opendir was on /dev/dri. */
@@ -664,34 +552,6 @@
return ent;
}
-/* If we're looking at /dev/dri, add our render node to the list
- * before the real entries in the directory.
- */
-PUBLIC struct dirent64 *
-readdir64(DIR *dir)
-{
- init_shim();
-
- struct dirent64 *ent = NULL;
-
- static struct dirent64 render_node_dirent = { 0 };
-
- simple_mtx_lock(&shim_lock);
- if (_mesa_set_search(opendir_set, dir)) {
- strcpy(render_node_dirent.d_name,
- render_node_dirent_name);
- render_node_dirent.d_type = DT_CHR;
- ent = &render_node_dirent;
- _mesa_set_remove_key(opendir_set, dir);
- }
- simple_mtx_unlock(&shim_lock);
-
- if (!ent && dir != fake_dev_dri)
- ent = real_readdir64(dir);
-
- return ent;
-}
-
/* Cleans up tracking of opendir("/dev/dri") */
PUBLIC int
closedir(DIR *dir)
@@ -774,7 +634,7 @@
* our DRM fd to drm_shim_ioctl().
*/
PUBLIC int
-ioctl(int fd, unsigned long request, ...)
+ioctl(int fd, int request, ...)
{
init_shim();
@@ -810,8 +670,6 @@
return ret;
}
-PUBLIC int fcntl64(int, int, ...)
- __attribute__((alias("fcntl")));
/* I wrote this when trying to fix gallium screen creation, leaving it around
* since it's probably good to have.
@@ -841,15 +699,3 @@
return real_mmap(addr, length, prot, flags, fd, offset);
}
-
-PUBLIC void *
-mmap64(void* addr, size_t length, int prot, int flags, int fd, off64_t offset)
-{
- init_shim();
-
- struct shim_fd *shim_fd = drm_shim_fd_lookup(fd);
- if (shim_fd)
- return drm_shim_mmap(shim_fd, length, prot, flags, fd, offset);
-
- return real_mmap64(addr, length, prot, flags, fd, offset);
-}
|