summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-05 23:52:12 +0800
committerruki <[email protected]>2022-04-05 23:52:12 +0800
commit43431946fbd66c1ff6c9726e93527efa7cf7dc98 (patch)
tree30fa88458d5ac568fee81f62ba8d70023ee81533
parent314f11d73d924d8ff8340fb989a545149850dfda (diff)
revert gid uid
-rw-r--r--core/src/xmake/engine.c8
-rw-r--r--core/src/xmake/makefile4
-rw-r--r--core/src/xmake/os/gid.c (renamed from core/src/xmake/os/getgid.c)24
-rw-r--r--core/src/xmake/os/uid.c (renamed from core/src/xmake/os/getuid.c)24
-rw-r--r--xmake/core/base/os.lua20
5 files changed, 40 insertions, 40 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index e91e5ac3e..a2b43e12b 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -114,8 +114,8 @@ tb_int_t xm_os_strerror(lua_State* lua);
tb_int_t xm_os_getwinsize(lua_State* lua);
tb_int_t xm_os_getpid(lua_State* lua);
#ifndef TB_CONFIG_OS_WINDOWS
-tb_int_t xm_os_getuid(lua_State* lua);
-tb_int_t xm_os_getgid(lua_State* lua);
+tb_int_t xm_os_uid(lua_State* lua);
+tb_int_t xm_os_gid(lua_State* lua);
tb_int_t xm_os_getown(lua_State* lua);
#endif
@@ -292,8 +292,8 @@ static luaL_Reg const g_os_functions[] =
, { "getwinsize", xm_os_getwinsize}
, { "getpid", xm_os_getpid }
#ifndef TB_CONFIG_OS_WINDOWS
-, { "getuid", xm_os_getuid }
-, { "getgid", xm_os_getgid }
+, { "uid", xm_os_uid }
+, { "gid", xm_os_gid }
, { "getown", xm_os_getown }
#endif
, { tb_null, tb_null }
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index d82ff51f9..dbe9bc201 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -44,8 +44,8 @@ xmake_C_FILES += \
os/strerror \
os/filesize \
os/getwinsize \
- os/getuid \
- os/getgid \
+ os/uid \
+ os/gid \
os/getpid \
os/getown \
io/stdfile \
diff --git a/core/src/xmake/os/getgid.c b/core/src/xmake/os/gid.c
index a089f855e..8a05cd145 100644
--- a/core/src/xmake/os/getgid.c
+++ b/core/src/xmake/os/gid.c
@@ -15,14 +15,14 @@
* Copyright (C) 2015-present, TBOOX Open Source Group.
*
* @author TitanSnow
- * @file getgid.c
+ * @file gid.c
*
*/
/* //////////////////////////////////////////////////////////////////////////////////////
* trace
*/
-#define TB_TRACE_MODULE_NAME "getgid"
+#define TB_TRACE_MODULE_NAME "gid"
#define TB_TRACE_MODULE_DEBUG (0)
/* //////////////////////////////////////////////////////////////////////////////////////
@@ -40,7 +40,7 @@
#ifndef TB_CONFIG_OS_WINDOWS
// get & set gid
-tb_int_t xm_os_getgid(lua_State* lua)
+tb_int_t xm_os_gid(lua_State* lua)
{
// check
tb_assert_and_check_return_val(lua, 0);
@@ -52,14 +52,14 @@ tb_int_t xm_os_getgid(lua_State* lua)
{
if (lua_istable(lua, 1))
{
- // os.getgid({["rgid"] = rgid, ["egid"] = egid})
+ // os.gid({["rgid"] = rgid, ["egid"] = egid})
lua_getfield(lua, 1, "rgid");
lua_getfield(lua, 1, "egid");
if (!lua_isnil(lua, -1))
{
if (!lua_isnumber(lua, -1))
{
- lua_pushfstring(lua, "invalid field type(%s) in `egid` for os.getgid", luaL_typename(lua, -1));
+ lua_pushfstring(lua, "invalid field type(%s) in `egid` for os.gid", luaL_typename(lua, -1));
lua_error(lua);
return 0;
}
@@ -70,7 +70,7 @@ tb_int_t xm_os_getgid(lua_State* lua)
{
if (!lua_isnumber(lua, -1))
{
- lua_pushfstring(lua, "invalid field type(%s) in `rgid` for os.getgid", luaL_typename(lua, -1));
+ lua_pushfstring(lua, "invalid field type(%s) in `rgid` for os.gid", luaL_typename(lua, -1));
lua_error(lua);
return 0;
}
@@ -80,24 +80,24 @@ tb_int_t xm_os_getgid(lua_State* lua)
}
else if (lua_isnumber(lua, 1))
{
- // os.getgid(gid)
+ // os.gid(gid)
rgidset = egidset = (tb_int_t)lua_tonumber(lua, 1);
}
else
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 1));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
}
else if (argc == 2)
{
- // os.getgid(rgid, egid)
+ // os.gid(rgid, egid)
if (!lua_isnil(lua, 1))
{
if (!lua_isnumber(lua, 1))
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 1));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
@@ -107,7 +107,7 @@ tb_int_t xm_os_getgid(lua_State* lua)
{
if (!lua_isnumber(lua, 2))
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getgid", luaL_typename(lua, 2));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 2));
lua_error(lua);
return 0;
}
@@ -116,7 +116,7 @@ tb_int_t xm_os_getgid(lua_State* lua)
}
else if (argc != 0)
{
- lua_pushstring(lua, "invalid argument count for os.getgid");
+ lua_pushstring(lua, "invalid argument count for os.gid");
lua_error(lua);
return 0;
}
diff --git a/core/src/xmake/os/getuid.c b/core/src/xmake/os/uid.c
index 9c2c2fa2c..bdaee036f 100644
--- a/core/src/xmake/os/getuid.c
+++ b/core/src/xmake/os/uid.c
@@ -15,14 +15,14 @@
* Copyright (C) 2015-present, TBOOX Open Source Group.
*
* @author TitanSnow
- * @file getuid.c
+ * @file uid.c
*
*/
/* //////////////////////////////////////////////////////////////////////////////////////
* trace
*/
-#define TB_TRACE_MODULE_NAME "getuid"
+#define TB_TRACE_MODULE_NAME "uid"
#define TB_TRACE_MODULE_DEBUG (0)
/* //////////////////////////////////////////////////////////////////////////////////////
@@ -40,7 +40,7 @@
#ifndef TB_CONFIG_OS_WINDOWS
// get & set uid
-tb_int_t xm_os_getuid(lua_State* lua)
+tb_int_t xm_os_uid(lua_State* lua)
{
// check
tb_assert_and_check_return_val(lua, 0);
@@ -52,14 +52,14 @@ tb_int_t xm_os_getuid(lua_State* lua)
{
if (lua_istable(lua, 1))
{
- // os.getuid({["ruid"] = ruid, ["euid"] = euid})
+ // os.uid({["ruid"] = ruid, ["euid"] = euid})
lua_getfield(lua, 1, "ruid");
lua_getfield(lua, 1, "euid");
if (!lua_isnil(lua, -1))
{
if (!lua_isnumber(lua, -1))
{
- lua_pushfstring(lua, "invalid field type(%s) in `euid` for os.getuid", luaL_typename(lua, -1));
+ lua_pushfstring(lua, "invalid field type(%s) in `euid` for os.uid", luaL_typename(lua, -1));
lua_error(lua);
return 0;
}
@@ -70,7 +70,7 @@ tb_int_t xm_os_getuid(lua_State* lua)
{
if (!lua_isnumber(lua, -1))
{
- lua_pushfstring(lua, "invalid field type(%s) in `ruid` for os.getuid", luaL_typename(lua, -1));
+ lua_pushfstring(lua, "invalid field type(%s) in `ruid` for os.uid", luaL_typename(lua, -1));
lua_error(lua);
return 0;
}
@@ -80,24 +80,24 @@ tb_int_t xm_os_getuid(lua_State* lua)
}
else if (lua_isnumber(lua, 1))
{
- // os.getuid(uid)
+ // os.uid(uid)
ruidset = euidset = (tb_int_t)lua_tonumber(lua, 1);
}
else
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 1));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
}
else if (argc == 2)
{
- // os.getuid(ruid, euid)
+ // os.uid(ruid, euid)
if (!lua_isnil(lua, 1))
{
if (!lua_isnumber(lua, 1))
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 1));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
@@ -107,7 +107,7 @@ tb_int_t xm_os_getuid(lua_State* lua)
{
if (!lua_isnumber(lua, 2))
{
- lua_pushfstring(lua, "invalid argument type(%s) for os.getuid", luaL_typename(lua, 2));
+ lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 2));
lua_error(lua);
return 0;
}
@@ -116,7 +116,7 @@ tb_int_t xm_os_getuid(lua_State* lua)
}
else if (argc != 0)
{
- lua_pushstring(lua, "invalid argument count for os.getuid");
+ lua_pushstring(lua, "invalid argument count for os.uid");
lua_error(lua);
return 0;
}
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index daff4d75b..2f44afa38 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -31,8 +31,8 @@ local string = require("base/string")
local process = require("base/process")
-- save original interfaces
-os._getuid = os._getuid or os.getuid or os.uid -- for old core
-os._getgid = os._getgid or os.getgid or os.gid
+os._uid = os._uid or os.uid
+os._gid = os._gid or os.gid
os._getpid = os._getpid or os.getpid
os._exit = os._exit or os.exit
os._mkdir = os._mkdir or os.mkdir
@@ -610,7 +610,7 @@ function os.tmpdir(opt)
local subdir = os._TMPSUBDIR
if not subdir then
local name = "." .. xmake._NAME
- subdir = path.join((os._FAKEROOT and (name .. "fake") or name) .. (os.getuid().euid or ""), os.date("%y%m%d"))
+ subdir = path.join((os._FAKEROOT and (name .. "fake") or name) .. (os.uid().euid or ""), os.date("%y%m%d"))
os._TMPSUBDIR = subdir
end
@@ -975,19 +975,19 @@ function os.nuldev(input)
end
-- get uid
-function os.getuid(...)
+function os.uid(...)
os._UID = {}
- if os._getuid then
- os._UID = os._getuid(...) or {}
+ if os._uid then
+ os._UID = os._uid(...) or {}
end
return os._UID
end
-- get gid
-function os.getgid(...)
+function os.gid(...)
os._GID = {}
- if os._getgid then
- os._GID = os._getgid(...) or {}
+ if os._gid then
+ os._GID = os._gid(...) or {}
end
return os._GID
end
@@ -1004,7 +1004,7 @@ end
-- check the current command is running as root
function os.isroot()
- return os.getuid().euid == 0
+ return os.uid().euid == 0
end
-- is case-insensitive filesystem?