156 lines
4.8 KiB
Diff
156 lines
4.8 KiB
Diff
From 242abbbfea38515e6f5e048399a216b88cce8224 Mon Sep 17 00:00:00 2001
|
|
From: ayaka <ayaka@soulik.info>
|
|
Date: Sun, 29 Aug 2021 16:05:17 +0800
|
|
Subject: [PATCH] dll/wrap: fix build for glibc 2.33
|
|
|
|
I don't think I need the step that converting to legacy struct.
|
|
|
|
Signed-off-by: ayaka <ayaka@soulik.info>
|
|
---
|
|
dll/common_includes.h | 3 +-
|
|
dll/wrap.cpp | 67 +++++++++++++++++++++++++++++++++++++++----
|
|
2 files changed, 63 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/dll/common_includes.h b/dll/common_includes.h
|
|
index 4dc55d1..f15f49e 100644
|
|
--- a/dll/common_includes.h
|
|
+++ b/dll/common_includes.h
|
|
@@ -113,7 +113,6 @@ inline std::wstring utf8_decode(const std::string &str)
|
|
#include <sys/ioctl.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/mount.h>
|
|
- #include <sys/stat.h>
|
|
#include <sys/statvfs.h>
|
|
#include <sys/time.h>
|
|
|
|
@@ -190,4 +189,4 @@ inline std::wstring utf8_decode(const std::string &str)
|
|
|
|
#define LOBBY_CONNECT_APPID ((uint32)-2)
|
|
|
|
-#endif//__INCLUDED_COMMON_INCLUDES__
|
|
\ No newline at end of file
|
|
+#endif//__INCLUDED_COMMON_INCLUDES__
|
|
diff --git a/dll/wrap.cpp b/dll/wrap.cpp
|
|
index 50defc7..7cabf7c 100644
|
|
--- a/dll/wrap.cpp
|
|
+++ b/dll/wrap.cpp
|
|
@@ -25,6 +25,7 @@
|
|
// Nothing to be done here
|
|
#else
|
|
#define STEAM_API_FUNCTIONS_IMPL
|
|
+
|
|
#include "base.h"
|
|
#include "dll.h"
|
|
|
|
@@ -34,6 +35,26 @@
|
|
const char *STEAM_PATH;
|
|
size_t STEAM_PATH_SIZE;
|
|
|
|
+#ifndef __x86_64__
|
|
+# define _STAT_VER_LINUX_OLD 1
|
|
+# define _STAT_VER_KERNEL 1
|
|
+# define _STAT_VER_SVR4 2
|
|
+# define _STAT_VER_LINUX 3
|
|
+# define _MKNOD_VER_LINUX 1
|
|
+# define _MKNOD_VER_SVR4 2
|
|
+#else
|
|
+# define _STAT_VER_KERNEL 0
|
|
+# define _STAT_VER_LINUX 1
|
|
+# define _MKNOD_VER_LINUX 0
|
|
+#endif
|
|
+#define _STAT_VER _STAT_VER_LINUX
|
|
+#define _MKNOD_VER _MKNOD_VER_LINUX
|
|
+
|
|
+/* From kernel_stat.h It help me save some condition */
|
|
+#define XSTAT_IS_XSTAT64 1
|
|
+#define STATFS_IS_STATFS64 __STATFS_MATCHES_STATFS64
|
|
+#define STAT_IS_KERNEL_STAT 1
|
|
+
|
|
// Returns a '/' terminated absolute path to the steam folder in user's home,
|
|
// root is returned if env home is not set
|
|
const char *get_steam_path()
|
|
@@ -290,7 +311,16 @@ STEAMAPI_API int __wrap_access(const char *path, int mode)
|
|
STEAMAPI_API int __wrap___xstat(int ver, const char * path, struct stat * stat_buf)
|
|
{
|
|
const char *path_lowercased = lowercase_path(path, false, false);
|
|
- int result = __xstat(ver, path_lowercased, stat_buf);
|
|
+ int result;
|
|
+
|
|
+ switch (ver) {
|
|
+ case _STAT_VER_KERNEL:
|
|
+ result = stat(path_lowercased, stat_buf);
|
|
+ break;
|
|
+ default:
|
|
+ result = EINVAL;
|
|
+ }
|
|
+
|
|
if (path_lowercased != path) {
|
|
free((void *)path_lowercased);
|
|
}
|
|
@@ -305,7 +335,16 @@ STEAMAPI_API int __wrap_stat(const char * path, struct stat * stat_buf)
|
|
STEAMAPI_API int __wrap___lxstat(int ver, const char * path, struct stat * stat_buf)
|
|
{
|
|
const char *path_lowercased = lowercase_path(path, false, false);
|
|
- int result = __lxstat(ver, path_lowercased, stat_buf);
|
|
+ int result;
|
|
+
|
|
+ switch (ver) {
|
|
+ case _STAT_VER_KERNEL:
|
|
+ result = lstat(path_lowercased, stat_buf);
|
|
+ break;
|
|
+ default:
|
|
+ result = EINVAL;
|
|
+ }
|
|
+
|
|
if (path_lowercased != path) {
|
|
free((void *)path_lowercased);
|
|
}
|
|
@@ -350,7 +389,16 @@ STEAMAPI_API DIR *__wrap_opendir(const char *path)
|
|
STEAMAPI_API int __wrap___xstat64(int ver, const char *path, struct stat64 *stat_buf)
|
|
{
|
|
const char *path_lowercased = lowercase_path(path, false, false);
|
|
- int result = __xstat64(ver, path_lowercased, stat_buf);
|
|
+ int result;
|
|
+
|
|
+ switch (ver) {
|
|
+ case _STAT_VER_KERNEL:
|
|
+ result = stat64(path_lowercased, stat_buf);
|
|
+ break;
|
|
+ default:
|
|
+ result = EINVAL;
|
|
+ }
|
|
+
|
|
if (path_lowercased != path) {
|
|
free((void *)path_lowercased);
|
|
}
|
|
@@ -360,7 +408,16 @@ STEAMAPI_API int __wrap___xstat64(int ver, const char *path, struct stat64 *stat
|
|
STEAMAPI_API int __wrap___lxstat64(int ver, const char *path, struct stat64 *stat_buf)
|
|
{
|
|
const char *path_lowercased = lowercase_path(path, false, false);
|
|
- int result = __lxstat64(ver, path_lowercased, stat_buf);
|
|
+ int result;
|
|
+
|
|
+ switch (ver) {
|
|
+ case _STAT_VER_KERNEL:
|
|
+ result = lstat64(path_lowercased, stat_buf);
|
|
+ break;
|
|
+ default:
|
|
+ result = EINVAL;
|
|
+ }
|
|
+
|
|
if (path_lowercased != path) {
|
|
free((void *)path_lowercased);
|
|
}
|
|
@@ -448,7 +505,7 @@ STEAMAPI_API int __wrap_link(const char *path1, const char *path2)
|
|
STEAMAPI_API int __wrap_mknod(const char *path, mode_t mode, dev_t dev)
|
|
{
|
|
const char *path_lowercased = lowercase_path(path, true, true);
|
|
- int result = __xmknod(1, path_lowercased, mode, &dev);
|
|
+ int result = mknod(path_lowercased, mode, dev);
|
|
if (path_lowercased != path) {
|
|
free((void *)path_lowercased);
|
|
}
|
|
--
|
|
GitLab
|
|
|