From 6edbb046fa3df6fc6e32a74c6aee57f349866a55 Mon Sep 17 00:00:00 2001 From: Aaron Kaiser Date: Thu, 18 Apr 2024 09:28:45 +0200 Subject: [PATCH] feat: add function to get fd of memfd --- src/bump_allocator.rs | 4 ++++ src/lib.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/bump_allocator.rs b/src/bump_allocator.rs index 1ccf13c..ef56ade 100644 --- a/src/bump_allocator.rs +++ b/src/bump_allocator.rs @@ -91,6 +91,10 @@ impl BumpAllocator { offset as usize } + + pub(crate) fn get_fd(&self) -> i32 { + self.backing_fd + } } #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index 35a9d3f..49c3de6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,14 @@ #![feature(test)] #![feature(lazy_cell)] +use bump_allocator::BUMP_ALLOCATOR; + mod allocator; mod bump_allocator; pub mod sharedptr; + +pub fn get_shared_mem_fd() -> i32 { + let allocator = BUMP_ALLOCATOR.lock().unwrap(); + + allocator.get_fd() +}