From 6667446db3979a5c7930f0deaf40936a6b992f93 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 9 Mar 2022 10:46:31 +0800 Subject: [PATCH] [TD-13876]: forbid big-end machine. --- include/os/osSysinfo.h | 1 + source/dnode/mgmt/daemon/src/dmnMain.c | 5 +++++ source/os/src/osSysinfo.c | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 1ebad370b5..54a3cfef7b 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -33,6 +33,7 @@ typedef struct { SDiskSize size; } SDiskSpace; +bool taosCheckSystemIsSmallEnd(); void taosGetSystemInfo(); int32_t taosGetEmail(char *email, int32_t maxLen); int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen); diff --git a/source/dnode/mgmt/daemon/src/dmnMain.c b/source/dnode/mgmt/daemon/src/dmnMain.c index df705898ca..7ba272453c 100644 --- a/source/dnode/mgmt/daemon/src/dmnMain.c +++ b/source/dnode/mgmt/daemon/src/dmnMain.c @@ -97,6 +97,11 @@ int32_t dmnRunDnode() { } int main(int argc, char const *argv[]) { + if (!taosCheckSystemIsSmallEnd()) { + uError("TDengine does not run on non-small-end machines."); + return -1; + } + if (dmnParseOption(argc, argv) != 0) { return -1; } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index ff9d5fb71b..02d7e6c0e9 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -16,6 +16,15 @@ #define _DEFAULT_SOURCE #include "os.h" +bool taosCheckSystemIsSmallEnd() { + union check{ + int16_t i; + char ch[2]; + }c; + c.i=1; + return c.ch[0]==1; +} + #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) /*