Coder Social home page Coder Social logo

winfsp_wrs's Introduction

Winfsp Wrapper Rust

actions status

Requirements

WinFSP must be installed:

choco install winfsp

Run example

cargo run -p memfs my-mountpoint

Testing

Download winfsp-tests: https://github.com/winfsp/winfsp/releases/

winfsp-tests itself depends on WinFSP's DLL, hence the easiest way to avoid troubles is to put the winfsp-tests executable in the C:/Program Files (x86)/WinFsp/bin/ install folder (the alternative being to copy C:/Program Files (x86)/WinFsp/bin/winfsp-x64.dll in the directory where winfsp-tests executable resides).

Re-generate WinFSP bindgen code

(This is only needed when WinFSP headers change)

Rust bindgen CLI must be installed

cargo install bindgen-cli

On top of that, Clang is needed by rust-bindgen for parsing WinFSP C++ API headers.

To install Clang (also see rust-bindgen doc):

winget install LLVM.LLVM
set LIBCLANG_PATH="C:\Program Files\LLVM\bin"

Then to re-generate:

python scripts/generate_bindgen.py  winfsp_wrs_sys/src/gen.rs

winfsp_wrs's People

Contributors

timeengineer avatar touilleman avatar mmmarcos avatar

Stargazers

 avatar  avatar

Watchers

 avatar Antoine Dupré avatar Vincent Michel avatar Thierry LEBLOND avatar  avatar NicoTuxx avatar Maximilien de Dinechin avatar  avatar Volham avatar Aurelia avatar

winfsp_wrs's Issues

Return error instead of silent cutoff when configuring too long prefix/file_system_name

pub fn set_prefix(&mut self, val: &U16CStr) -> &mut Self {
let len = std::cmp::min(self.0.Prefix.len(), val.len());
self.0.Prefix[..len].copy_from_slice(&val.as_slice()[..len]);
self
}
pub fn set_file_system_name(&mut self, val: &U16CStr) -> &mut Self {
let len = std::cmp::min(self.0.FileSystemName.len(), val.len());

Would be better to return a Return<&mut Self, &mut Self> so that the caller is informed of the issue

Notes:

  • no actual error type is needed given there is only one error reason and it is obvious)
  • error returns the object so that the caller can then recover from the error and continue the configuration

Is `init` idempotent ?

/// This function is needed to initialize `WinFSP`.
/// You should also add `winfsp_build::build()` in your `build.rs` to allow
/// delayload, which is needed because `winfsp_wrs` depends on `WinFSP's dll`
/// which is not in Windows path or at the same location of your binary.
pub fn init() -> Result<(), u32> {
unsafe {
if LoadLibraryW(get_lplibfilename()?.as_ptr().cast_mut()) == 0 {
Err(ERROR_DELAY_LOAD_FAILED)
} else {
Ok(())
}
}
}

Currently it's unclear what happen if init is called multiple times, so we should:

  • ensure it is fine to call it multiple times
  • add a comment to the docstring (something like This function is idempotent, hence calling it multiple times is safe.
  • add a test (typically call 3 times init, then mount and do an access on the mountpoint)

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.