mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Add open64() hook for _FILE_OFFSET_BITS=64
This commit is contained in:
parent
58429f4172
commit
555a65c8ea
@ -94,20 +94,19 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req,
|
|||||||
// hook this variant of open(), since that's what SDL uses. When we see
|
// hook this variant of open(), since that's what SDL uses. When we see
|
||||||
// the open a FD for the same card as the Qt DRM master FD, we'll drop
|
// the open a FD for the same card as the Qt DRM master FD, we'll drop
|
||||||
// master on the Qt FD to allow the new FD to have master.
|
// master on the Qt FD to allow the new FD to have master.
|
||||||
int open(const char *pathname, int flags, ...)
|
int openHook(const char *funcname, const char *pathname, int flags, va_list va)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
mode_t mode;
|
||||||
|
|
||||||
// Call the real thing to do the open operation
|
// Call the real thing to do the open operation
|
||||||
if (__OPEN_NEEDS_MODE(flags)) {
|
if (__OPEN_NEEDS_MODE(flags)) {
|
||||||
va_list va;
|
mode = va_arg(va, mode_t);
|
||||||
va_start(va, flags);
|
fd = ((typeof(open)*)dlsym(RTLD_NEXT, funcname))(pathname, flags, mode);
|
||||||
mode_t mode = va_arg(va, mode_t);
|
|
||||||
fd = ((typeof(open)*)dlsym(RTLD_NEXT, "open"))(pathname, flags, mode);
|
|
||||||
va_end(va);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fd = ((typeof(open)*)dlsym(RTLD_NEXT, "open"))(pathname, flags);
|
mode = 0;
|
||||||
|
fd = ((typeof(open)*)dlsym(RTLD_NEXT, funcname))(pathname, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file was successfully opened and we have a DRM master FD,
|
// If the file was successfully opened and we have a DRM master FD,
|
||||||
@ -140,14 +139,10 @@ int open(const char *pathname, int flags, ...)
|
|||||||
// simply creating a new FD. Let's do it.
|
// simply creating a new FD. Let's do it.
|
||||||
close(fd);
|
close(fd);
|
||||||
if (__OPEN_NEEDS_MODE(flags)) {
|
if (__OPEN_NEEDS_MODE(flags)) {
|
||||||
va_list va;
|
fd = ((typeof(open)*)dlsym(RTLD_NEXT, funcname))(pathname, flags, mode);
|
||||||
va_start(va, flags);
|
|
||||||
mode_t mode = va_arg(va, mode_t);
|
|
||||||
fd = ((typeof(open)*)dlsym(RTLD_NEXT, "open"))(pathname, flags, mode);
|
|
||||||
va_end(va);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fd = ((typeof(open)*)dlsym(RTLD_NEXT, "open"))(pathname, flags);
|
fd = ((typeof(open)*)dlsym(RTLD_NEXT, funcname))(pathname, flags);
|
||||||
}
|
}
|
||||||
g_SdlDrmMasterFd = fd;
|
g_SdlDrmMasterFd = fd;
|
||||||
}
|
}
|
||||||
@ -157,6 +152,24 @@ int open(const char *pathname, int flags, ...)
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int open(const char *pathname, int flags, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, flags);
|
||||||
|
int fd = openHook("open", pathname, flags, va);
|
||||||
|
va_end(va);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
int open64(const char *pathname, int flags, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
va_start(va, flags);
|
||||||
|
int fd = openHook("open64", pathname, flags, va);
|
||||||
|
va_end(va);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
// Our close() hook handles restoring DRM master to the Qt FD
|
// Our close() hook handles restoring DRM master to the Qt FD
|
||||||
// after SDL closes its DRM FD.
|
// after SDL closes its DRM FD.
|
||||||
int close(int fd)
|
int close(int fd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user