2019-10-31 10:16:28 -07:00
|
|
|
// Copyright © 2019 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
2019-10-31 10:26:24 -07:00
|
|
|
|
2019-10-31 13:09:20 -07:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
|
2019-10-31 14:55:06 -07:00
|
|
|
pub mod descriptor_utils;
|
2019-11-01 09:56:06 -07:00
|
|
|
pub mod file_traits;
|
2019-10-31 12:21:21 -07:00
|
|
|
pub mod filesystem;
|
2020-02-12 15:08:35 -08:00
|
|
|
pub mod fs_cache_req_handler;
|
2019-10-31 10:26:24 -07:00
|
|
|
pub mod fuse;
|
2019-10-31 10:40:33 -07:00
|
|
|
pub mod multikey;
|
2019-10-31 13:09:20 -07:00
|
|
|
pub mod passthrough;
|
2020-04-24 13:43:36 +02:00
|
|
|
pub mod sandbox;
|
2020-05-01 17:26:07 +01:00
|
|
|
pub mod seccomp;
|
2019-10-31 13:24:10 -07:00
|
|
|
pub mod server;
|
|
|
|
|
|
|
|
use std::ffi::FromBytesWithNulError;
|
|
|
|
use std::{error, fmt, io};
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
/// Failed to decode protocol messages.
|
|
|
|
DecodeMessage(io::Error),
|
|
|
|
/// Failed to encode protocol messages.
|
|
|
|
EncodeMessage(io::Error),
|
|
|
|
/// One or more parameters are missing.
|
|
|
|
MissingParameter,
|
|
|
|
/// A C string parameter is invalid.
|
|
|
|
InvalidCString(FromBytesWithNulError),
|
|
|
|
/// The `len` field of the header is too small.
|
|
|
|
InvalidHeaderLength,
|
|
|
|
/// The `size` field of the `SetxattrIn` message does not match the length
|
|
|
|
/// of the decoded value.
|
|
|
|
InvalidXattrSize((u32, usize)),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl error::Error for Error {}
|
|
|
|
|
|
|
|
impl fmt::Display for Error {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
use Error::*;
|
|
|
|
match self {
|
|
|
|
DecodeMessage(err) => write!(f, "failed to decode fuse message: {}", err),
|
|
|
|
EncodeMessage(err) => write!(f, "failed to encode fuse message: {}", err),
|
|
|
|
MissingParameter => write!(f, "one or more parameters are missing"),
|
|
|
|
InvalidHeaderLength => write!(f, "the `len` field of the header is too small"),
|
|
|
|
InvalidCString(err) => write!(f, "a c string parameter is invalid: {}", err),
|
|
|
|
InvalidXattrSize((size, len)) => write!(
|
|
|
|
f,
|
|
|
|
"The `size` field of the `SetxattrIn` message does not match the length of the\
|
|
|
|
decoded value: size = {}, value.len() = {}",
|
|
|
|
size, len
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Result<T> = ::std::result::Result<T, Error>;
|