From c41544ac7b502fbdb6c1ee96a604490b72eb7770 Mon Sep 17 00:00:00 2001 From: James Bradlee Date: Tue, 31 May 2022 10:42:44 +0200 Subject: feat(unstable): add Deno.getGid (#14528) --- runtime/js/30_os.js | 5 +++++ runtime/js/90_deno_ns.js | 1 + runtime/ops/os.rs | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) (limited to 'runtime') diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 9cc2ba5c7..f9df42305 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -30,6 +30,10 @@ return core.opSync("op_network_interfaces"); } + function getGid() { + return core.opSync("op_getgid"); + } + function getUid() { return core.opSync("op_getuid"); } @@ -94,6 +98,7 @@ env, execPath, exit, + getGid, getUid, hostname, loadavg, diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 879e63e57..24a31bc31 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -124,6 +124,7 @@ osRelease: __bootstrap.os.osRelease, systemMemoryInfo: __bootstrap.os.systemMemoryInfo, networkInterfaces: __bootstrap.os.networkInterfaces, + getGid: __bootstrap.os.getGid, getUid: __bootstrap.os.getUid, sleepSync: __bootstrap.timers.sleepSync, listen: __bootstrap.netUnstable.listen, diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs index c74a423ab..37da410ca 100644 --- a/runtime/ops/os.rs +++ b/runtime/ops/os.rs @@ -22,6 +22,7 @@ pub fn init(maybe_exit_code: Option>) -> Extension { op_exit::decl(), op_delete_env::decl(), op_get_env::decl(), + op_getgid::decl(), op_getuid::decl(), op_hostname::decl(), op_loadavg::decl(), @@ -225,6 +226,22 @@ fn op_system_memory_info( } } +#[cfg(not(windows))] +#[op] +fn op_getgid(state: &mut OpState) -> Result, AnyError> { + super::check_unstable(state, "Deno.getGid"); + state.borrow_mut::().env.check_all()?; + unsafe { Ok(Some(libc::getgid())) } +} + +#[cfg(windows)] +#[op] +fn op_getgid(state: &mut OpState) -> Result, AnyError> { + super::check_unstable(state, "Deno.getGid"); + state.borrow_mut::().env.check_all()?; + Ok(None) +} + #[cfg(not(windows))] #[op] fn op_getuid(state: &mut OpState) -> Result, AnyError> { -- cgit v1.2.3