summaryrefslogtreecommitdiff
path: root/ext/node/ops
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/ops')
-rw-r--r--ext/node/ops/fs.rs41
-rw-r--r--ext/node/ops/os/mod.rs19
2 files changed, 60 insertions, 0 deletions
diff --git a/ext/node/ops/fs.rs b/ext/node/ops/fs.rs
index 304a6c253..47b66ee1d 100644
--- a/ext/node/ops/fs.rs
+++ b/ext/node/ops/fs.rs
@@ -273,3 +273,44 @@ where
Ok(())
}
+
+#[op2]
+pub fn op_node_lchown_sync<P>(
+ state: &mut OpState,
+ #[string] path: String,
+ uid: Option<u32>,
+ gid: Option<u32>,
+) -> Result<(), AnyError>
+where
+ P: NodePermissions + 'static,
+{
+ let path = PathBuf::from(path);
+ state
+ .borrow_mut::<P>()
+ .check_write_with_api_name(&path, Some("node:fs.lchownSync"))?;
+ let fs = state.borrow::<FileSystemRc>();
+ fs.lchown_sync(&path, uid, gid)?;
+ Ok(())
+}
+
+#[op2(async)]
+pub async fn op_node_lchown<P>(
+ state: Rc<RefCell<OpState>>,
+ #[string] path: String,
+ uid: Option<u32>,
+ gid: Option<u32>,
+) -> Result<(), AnyError>
+where
+ P: NodePermissions + 'static,
+{
+ let path = PathBuf::from(path);
+ let fs = {
+ let mut state = state.borrow_mut();
+ state
+ .borrow_mut::<P>()
+ .check_write_with_api_name(&path, Some("node:fs.lchown"))?;
+ state.borrow::<FileSystemRc>().clone()
+ };
+ fs.lchown_async(path, uid, gid).await?;
+ Ok(())
+}
diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs
index 5b32113e5..b7374dc32 100644
--- a/ext/node/ops/os/mod.rs
+++ b/ext/node/ops/os/mod.rs
@@ -75,6 +75,25 @@ where
Ok(euid)
}
+#[op2(fast)]
+pub fn op_getegid<P>(state: &mut OpState) -> Result<u32, AnyError>
+where
+ P: NodePermissions + 'static,
+{
+ {
+ let permissions = state.borrow_mut::<P>();
+ permissions.check_sys("getegid", "node:os.getegid()")?;
+ }
+
+ #[cfg(windows)]
+ let egid = 0;
+ #[cfg(unix)]
+ // SAFETY: Call to libc getegid.
+ let egid = unsafe { libc::getegid() };
+
+ Ok(egid)
+}
+
#[op2]
#[serde]
pub fn op_cpus<P>(state: &mut OpState) -> Result<Vec<cpus::CpuInfo>, AnyError>