Skip to content

Allow to borrow a file descriptor without taking ownership #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cmeissl opened this issue Mar 12, 2022 · 3 comments
Open

Allow to borrow a file descriptor without taking ownership #29

cmeissl opened this issue Mar 12, 2022 · 3 comments

Comments

@cmeissl
Copy link

cmeissl commented Mar 12, 2022

When operating on external provided file descriptors it would be useful if it was possible to create a Memfd that does not
take ownership of the file descriptor.

For example in a graphics pipeline the file descriptor is transported in a separate structure that has the ownership of the
file descriptor. Within the pipeline a filter wants to operate on the file descriptor using Memfd.

impl Filter for GraphicsPipeline {
  fn filter(&self, memory: &Memory) -> Result<(), Error> {
    let mfd = Memfd::try_borrow_from(memory.fd())?;
   ...
  }
}
@lucab
Copy link
Owner

lucab commented Mar 12, 2022

Thanks for the suggestion. There are indeed a number of improvements that could be done around FD-handling. I'm personally waiting for the Rust io-safety work to stabilize first. Then the feature that you are looking for can be directly built with BorrowedFd. See https://rust-lang.github.io/rfcs/3128-io-safety.html#ownedfd-and-borrowedfdfd.

@sdroege
Copy link

sdroege commented Mar 12, 2022

@lucab
Copy link
Owner

lucab commented Mar 22, 2022

/cc @sunfishcode in case they may be interested in this FD-using gstreamer example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants