Giter VIP home page Giter VIP logo

file-descriptors's Introduction

file-descriptors

file-descriptors is a Rust crate wrapping the various kinds of file descriptors with safe abstractions, including IPv4 / IPv6 sockets, Unix domain sockets, epoll, timerfd, signalfd, eventfd, POSIX message queues, pipes, FIFOs, terminals (and serial ports), character devices, inotify, fanotify and Files.

There is a particularly extensive and safe wrapper for signals and terminals.

Fully functional on Android and Linux.

Somewhat functional on Fuschia, Illumos (a Solaris fork), uclibc and emscripten.

Support for the BSDs is desired.

Supported File Descriptors

  • character devices.
  • epoll.
  • eventfd.
  • fanotify.
  • inotify.
  • POSIX message queues (<(https://linux.die.net/man/7/mq_overview>).
  • pipes and FIFOs (anonymous and named FIFOs), including support for splice, vmsplice and tee.
  • sockets (TCP, UDP and the equivalent over Unix Domain Sockets; sendfile supported).
  • terminals (serial ports and modems).
  • timerfd.

Additionally, extensions (SendFile, SpliceRecipient and SpliceSender) are implemented for Rust's File.

Unix Domain Sockets

When using file paths

  • Every effort is made to create the socket file path cleanly;
  • To make sure all parent folders exist;
  • To make sure parent folder permissions are correctly set;
  • To remove any stale files;
  • To remove socket file paths on drop (close).

The above features may not work correctly after the use of seccomp to lock down system calls (particularly the attempt to delete a socket file path on close).

Pipes

  • The use of splice(), vmsplice() and tee() are supported for all file descriptors where possible (including Rust's ::std::fs::File).
  • To be able to use epoll with standard in (stdin), use pipes_and_fifos::ReceivePipeFileDescriptor::standard_in().
  • To be able to use epoll with standard out (stdout), use pipes_and_fifos::SendPipeFileDescriptor::standard_out().
  • To be able to use epoll with standard error (stderr), use pipes_and_fifos::SendPipeFileDescriptor::standard_error().

Unsupported for now

  • Linux zero copy send (MSG_ZEROCOPY) and receive (SO_ZEROCOPY), mostly because they have a horrible, hacky API.
  • SO_BUSY_POLL and SO_INCOMING_CPU.
  • Unix Domain Sockets using autobind; setting of the SO_PASSCRED socket option.
  • Receiving credentials over Unix Domain Sockets using recvmsg().
  • mkfifo().
  • mknod().
  • infiniband sockets.
  • canbus (SocketCAN sockets and can4linux http://can-wiki.info/can4linux/man/can4linux_8h_source.html character device drivers).

Licensing

The license for this project is MIT.

file-descriptors's People

Contributors

raphaelcohn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

file-descriptors's Issues

Support for New Fanotify APIs/Flags

I noticed there's no support for some newer fanotify APIs, like FAN_MARK_FILESYSTEM for MarkFlags, and FAN_CREATE, FAN_DELETE, FAN_MOVED_FROM, FAN_MOVED_TO, etc. for MarkEventFlags. Could you add these flags? Or can I submit a pull request for all the missing flags?

Compilation fails on stable channel due to use of `#![feature]`

When attempting to compile using Rust 1.53:

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/sec/.cargo/registry/src/github.com-1ecc6299db9ec823/file-descriptors-0.9.1/src/lib.rs:10:1
   |
10 | #![feature(core_intrinsics)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/sec/.cargo/registry/src/github.com-1ecc6299db9ec823/file-descriptors-0.9.1/src/lib.rs:11:1
   |
11 | #![feature(read_initializer)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

read_initializer almost has an implementation, but is delayed due to performance regressions.

What would it take to make this work without the custom features?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.