src/pxar/fuse.rs: rename from_decoder into new, new into from_path

This commit is contained in:
Dietmar Maurer 2019-11-26 10:56:41 +01:00
parent 99b5b6cba9
commit 2a11191072
3 changed files with 19 additions and 19 deletions

View File

@ -1709,7 +1709,7 @@ async fn mount_do(param: Value, pipe: Option<RawFd>) -> Result<Value, Error> {
let reader = BufferedDynamicReader::new(index, chunk_reader); let reader = BufferedDynamicReader::new(index, chunk_reader);
let decoder = pxar::Decoder::new(reader)?; let decoder = pxar::Decoder::new(reader)?;
let options = OsStr::new("ro,default_permissions"); let options = OsStr::new("ro,default_permissions");
let mut session = pxar::fuse::Session::from_decoder(decoder, &options, pipe.is_none()) let mut session = pxar::fuse::Session::new(decoder, &options, pipe.is_none())
.map_err(|err| format_err!("pxar mount failed: {}", err))?; .map_err(|err| format_err!("pxar mount failed: {}", err))?;
// Mount the session but not call fuse deamonize as this will cause // Mount the session but not call fuse deamonize as this will cause

View File

@ -253,7 +253,7 @@ fn mount_archive(
let archive = Path::new(archive); let archive = Path::new(archive);
let mountpoint = Path::new(mountpoint); let mountpoint = Path::new(mountpoint);
let options = OsStr::new("ro,default_permissions"); let options = OsStr::new("ro,default_permissions");
let mut session = pxar::fuse::Session::new(&archive, &options, verbose) let mut session = pxar::fuse::Session::from_path(&archive, &options, verbose)
.map_err(|err| format_err!("pxar mount failed: {}", err))?; .map_err(|err| format_err!("pxar mount failed: {}", err))?;
// Mount the session and deamonize if verbose is not set // Mount the session and deamonize if verbose is not set
session.mount(&mountpoint, !verbose)?; session.mount(&mountpoint, !verbose)?;

View File

@ -159,7 +159,7 @@ impl Session {
/// default signal handlers. /// default signal handlers.
/// Options have to be provided as comma separated OsStr, e.g. /// Options have to be provided as comma separated OsStr, e.g.
/// ("ro,default_permissions"). /// ("ro,default_permissions").
pub fn new(archive_path: &Path, options: &OsStr, verbose: bool) -> Result<Self, Error> { pub fn from_path(archive_path: &Path, options: &OsStr, verbose: bool) -> Result<Self, Error> {
let file = File::open(archive_path)?; let file = File::open(archive_path)?;
let args = Self::setup_args(options, verbose)?; let args = Self::setup_args(options, verbose)?;
let oprs = Self::setup_callbacks(); let oprs = Self::setup_callbacks();
@ -171,6 +171,22 @@ impl Session {
Self::setup_session(decoder, args, oprs, verbose) Self::setup_session(decoder, args, oprs, verbose)
} }
/// Create a new low level fuse session using the given `Decoder`.
///
/// `Session` is created using the provided mount options and sets the
/// default signal handlers.
/// Options have to be provided as comma separated OsStr, e.g.
/// ("ro,default_permissions").
pub fn new(
decoder: Decoder,
options: &OsStr,
verbose: bool,
) -> Result<Self, Error> {
let args = Self::setup_args(options, verbose)?;
let oprs = Self::setup_callbacks();
Self::setup_session(decoder, args, oprs, verbose)
}
fn setup_args(options: &OsStr, verbose: bool) -> Result<Vec<CString>, Error> { fn setup_args(options: &OsStr, verbose: bool) -> Result<Vec<CString>, Error> {
// First argument should be the executable name // First argument should be the executable name
let mut arguments = vec![ let mut arguments = vec![
@ -246,22 +262,6 @@ impl Session {
}) })
} }
/// Create a new low level fuse session using the given `Decoder`.
///
/// `Session` is created using the provided mount options and sets the
/// default signal handlers.
/// Options have to be provided as comma separated OsStr, e.g.
/// ("ro,default_permissions").
pub fn from_decoder(
decoder: Decoder,
options: &OsStr,
verbose: bool,
) -> Result<Self, Error> {
let args = Self::setup_args(options, verbose)?;
let oprs = Self::setup_callbacks();
Self::setup_session(decoder, args, oprs, verbose)
}
/// Mount the filesystem on the given mountpoint. /// Mount the filesystem on the given mountpoint.
/// ///
/// Actually mount the filesystem for this session on the provided mountpoint /// Actually mount the filesystem for this session on the provided mountpoint