Skip to content

Commit

Permalink
Split into fuse and fuse-sys crate
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 7, 2018
1 parent 9ad6783 commit 30a118b
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 60 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update && sudo apt-get install -y libfuse-dev; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew tap caskroom/cask && brew cask install osxfuse; fi
script:
- cargo build --verbose
- cargo test --verbose
- cargo doc --verbose --no-deps
- cargo build --all --all-targets
- cargo test --all
- cargo doc --all --no-deps
34 changes: 2 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
[package]
name = "fuse"
version = "0.3.1"
authors = ["Andreas Neuhaus <[email protected]>"]
build = "build.rs"
description = "Rust library for filesystems in userspace (FUSE)"
documentation = "https://docs.rs/fuse"
homepage = "https://github.com/zargony/rust-fuse"
repository = "https://github.com/zargony/rust-fuse"
readme = "README.md"
keywords = ["fuse", "filesystem", "system", "bindings"]
categories = ["api-bindings", "filesystem"]
license = "MIT"

[badges]
travis-ci = { repository = "zargony/rust-fuse" }

[build-dependencies]
pkg-config = "0.3"

[dependencies]
libc = "0.2"
log = "0.3"
time = "0.1"
thread-scoped = "1"

[dev-dependencies]
env_logger = "0.5"

[lib]
name = "fuse"
path = "src/lib.rs"
[workspace]
members = ["fuse", "fuse-sys"]
18 changes: 18 additions & 0 deletions fuse-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "fuse-sys"
version = "0.4.0-alpha"
authors = ["Andreas Neuhaus <[email protected]>"]
description = "FFI bindings to the FUSE kernel interface and libfuse"
documentation = "https://docs.rs/fuse"
homepage = "https://github.com/zargony/rust-fuse"
repository = "https://github.com/zargony/rust-fuse"
keywords = ["fuse", "filesystem", "system", "bindings"]
categories = ["external-ffi-bindings", "filesystem", "os::unix-apis"]
license = "MIT"
build = "build.rs"
links = "fuse"

[build-dependencies]
pkg-config = "0.3"

[dependencies]
1 change: 1 addition & 0 deletions fuse-sys/LICENSE.md
File renamed without changes.
5 changes: 2 additions & 3 deletions src/kernel.rs → fuse-sys/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
//! - supports ABI 7.19 since FUSE 2.9.1
//! - supports ABI 7.26 since FUSE 3.0.0
//!
//! Types/fields without a version annotation are valid with ABI 7.8 and later
#![allow(non_camel_case_types, missing_docs, dead_code)]
//! Items without a version annotation are valid with ABI 7.8 and later
// TODO: We currently target ABI 7.8, which is very conservative and missing many newer
// features. We still need to figure out a way to support different ABI version without hazzle.
Expand Down Expand Up @@ -121,6 +119,7 @@ pub mod consts {

#[repr(C)]
#[derive(Debug)]
#[allow(non_camel_case_types)]
pub enum fuse_opcode {
FUSE_LOOKUP = 1,
FUSE_FORGET = 2, // no reply
Expand Down
6 changes: 1 addition & 5 deletions src/libfuse.rs → fuse-sys/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
//! Native FFI bindings to libfuse
//!
//! This is a small set of bindings that are required to mount/unmount FUSE filesystems and
//! open/close a fd to the kernel driver with it. Since these bindings by far don't cover
//! everything in libfuse, we don't use a fuse-sys crate. It would actually be nice to get rid
//! of these bindings to become independent from libfuse, but FUSE mounting isn't trivial
//! unfortunately.
#![allow(non_camel_case_types, missing_docs, dead_code)]
//! open/close a fd to the kernel driver with it.
use std::os::raw::{c_char, c_int};

Expand Down
6 changes: 6 additions & 0 deletions fuse-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! FFI bindings to the FUSE kernel interface and libfuse
#![allow(missing_docs)]

pub mod abi;
pub mod ffi;
25 changes: 25 additions & 0 deletions fuse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "fuse"
version = "0.4.0-alpha"
authors = ["Andreas Neuhaus <[email protected]>"]
description = "Rust library for filesystems in userspace (FUSE)"
documentation = "https://docs.rs/fuse"
homepage = "https://github.com/zargony/rust-fuse"
repository = "https://github.com/zargony/rust-fuse"
readme = "README.md"
keywords = ["fuse", "filesystem", "system", "bindings"]
categories = ["api-bindings", "filesystem"]
license = "MIT"

[badges]
travis-ci = { repository = "zargony/rust-fuse" }

[dependencies]
fuse-sys = { path = "../fuse-sys", version = "0.4.0-alpha" }
libc = "0.2"
log = "0.3"
time = "0.1"
thread-scoped = "1"

[dev-dependencies]
env_logger = "0.5"
1 change: 1 addition & 0 deletions fuse/LICENSE.md
1 change: 1 addition & 0 deletions fuse/README.md
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions src/channel.rs → fuse/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use std::io;
use std::ffi::{CString, CStr, OsStr};
use std::os::unix::ffi::OsStrExt;
use std::path::{PathBuf, Path};
use fuse_sys::ffi::{fuse_args, fuse_mount_compat25};
use libc::{self, c_int, c_void, size_t};
use libfuse::{fuse_args, fuse_mount_compat25};

use reply::ReplySender;

/// Helper function to provide options as a fuse_args struct
Expand Down Expand Up @@ -131,7 +132,7 @@ pub fn unmount(mountpoint: &Path) -> io::Result<()> {
target_os = "openbsd", target_os = "bitrig", target_os = "netbsd")))]
#[inline]
fn libc_umount(mnt: &CStr) -> c_int {
use libfuse::fuse_unmount_compat22;
use fuse_sys::ffi::fuse_unmount_compat22;
use std::io::ErrorKind::PermissionDenied;

let rc = unsafe { libc::umount(mnt.as_ptr()) };
Expand Down
7 changes: 3 additions & 4 deletions src/lib.rs → fuse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![warn(missing_docs, bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, missing_debug_implementations)]

extern crate fuse_sys;
extern crate libc;
#[macro_use]
extern crate log;
Expand All @@ -19,8 +20,8 @@ use std::path::Path;
use libc::{c_int, ENOSYS};
use time::Timespec;

pub use kernel::FUSE_ROOT_ID;
pub use kernel::consts;
pub use fuse_sys::abi::FUSE_ROOT_ID;
pub use fuse_sys::abi::consts;
pub use reply::{Reply, ReplyEmpty, ReplyData, ReplyEntry, ReplyAttr, ReplyOpen};
pub use reply::{ReplyWrite, ReplyStatfs, ReplyCreate, ReplyLock, ReplyBmap, ReplyDirectory};
pub use reply::ReplyXattr;
Expand All @@ -31,8 +32,6 @@ pub use session::{Session, BackgroundSession};

mod argument;
mod channel;
mod kernel;
mod libfuse;
mod reply;
mod request;
mod session;
Expand Down
13 changes: 7 additions & 6 deletions src/reply.rs → fuse/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ use std::ffi::OsStr;
use std::fmt;
use std::marker::PhantomData;
use std::os::unix::ffi::OsStrExt;
use fuse_sys::abi::{fuse_attr, fuse_kstatfs, fuse_file_lock, fuse_entry_out, fuse_attr_out};
use fuse_sys::abi::{fuse_open_out, fuse_write_out, fuse_statfs_out, fuse_lk_out, fuse_bmap_out};
use fuse_sys::abi::fuse_getxattr_out;
#[cfg(target_os = "macos")]
use fuse_sys::abi::fuse_getxtimes_out;
use fuse_sys::abi::{fuse_out_header, fuse_dirent};
use libc::{c_int, S_IFIFO, S_IFCHR, S_IFBLK, S_IFDIR, S_IFREG, S_IFLNK, S_IFSOCK, EIO};
use time::Timespec;
use kernel::{fuse_attr, fuse_kstatfs, fuse_file_lock, fuse_entry_out, fuse_attr_out};
use kernel::{fuse_open_out, fuse_write_out, fuse_statfs_out, fuse_lk_out, fuse_bmap_out};
use kernel::fuse_getxattr_out;
#[cfg(target_os = "macos")]
use kernel::fuse_getxtimes_out;
use kernel::{fuse_out_header, fuse_dirent};

use {FileType, FileAttr};

/// Generic reply callback to send data
Expand Down
11 changes: 6 additions & 5 deletions src/request.rs → fuse/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
use std::mem;
use libc::{EIO, ENOSYS, EPROTO};
use time::Timespec;
use fuse_sys::abi::*;
use fuse_sys::abi::consts::*;
use fuse_sys::abi::fuse_opcode::*;
use reply::{Reply, ReplyRaw, ReplyEmpty, ReplyDirectory};

use argument::ArgumentIterator;
use channel::ChannelSender;
use Filesystem;
use kernel::*;
use kernel::consts::*;
use kernel::fuse_opcode::*;
use reply::{Reply, ReplyRaw, ReplyEmpty, ReplyDirectory};
use session::{MAX_WRITE_SIZE, Session};
use Filesystem;

/// We generally support async reads
#[cfg(not(target_os = "macos"))]
Expand Down
1 change: 1 addition & 0 deletions src/session.rs → fuse/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::fmt;
use std::path::{PathBuf, Path};
use thread_scoped::{scoped, JoinGuard};
use libc::{EAGAIN, EINTR, ENODEV, ENOENT};

use channel::{self, Channel};
use Filesystem;
use request;
Expand Down

0 comments on commit 30a118b

Please sign in to comment.