1 // Copyright 2020 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use std::ffi::FromBytesWithNulError; 6 use std::io; 7 8 use thiserror::Error as ThisError; 9 10 pub mod filesystem; 11 #[cfg(fuzzing)] 12 pub mod fuzzing; 13 pub mod mount; 14 mod server; 15 #[allow(dead_code)] 16 pub mod sys; 17 pub mod worker; 18 19 pub use mount::mount; 20 pub use server::{Mapper, Reader, Server, Writer}; 21 22 /// Errors that may occur during the creation or operation of an Fs device. 23 #[derive(ThisError, Debug)] 24 pub enum Error { 25 /// A request is missing readable descriptors. 26 /// Failed to decode protocol messages. 27 #[error("failed to decode fuse message: {0}")] 28 DecodeMessage(io::Error), 29 /// Failed to encode protocol messages. 30 #[error("failed to encode fuse message: {0}")] 31 EncodeMessage(io::Error), 32 /// Failed to flush protocol messages. 33 #[error("failed to flush fuse message: {0}")] 34 FlushMessage(io::Error), 35 /// Failed to set up FUSE endpoint to talk with. 36 #[error("failed to set up FUSE endpoint to talk with: {0}")] 37 EndpointSetup(io::Error), 38 /// One or more parameters are missing. 39 #[error("one or more parameters are missing")] 40 MissingParameter, 41 /// A C string parameter is invalid. 42 #[error("a c string parameter is invalid: {0}")] 43 InvalidCString(FromBytesWithNulError), 44 /// The `len` field of the header is too small. 45 #[error("the `len` field of the header is too small")] 46 InvalidHeaderLength, 47 /// The `size` field of the `SetxattrIn` message does not match the length 48 /// of the decoded value. 49 #[error( 50 "The `size` field of the `SetxattrIn` message does not match the\ 51 length of the decoded value: size = {0}, value.len() = {1}" 52 )] 53 InvalidXattrSize(u32, usize), 54 /// Requested too many `iovec`s for an `ioctl` retry. 55 #[error( 56 "requested too many `iovec`s for an `ioctl` retry reply: requested\ 57 {0}, max: {1}" 58 )] 59 TooManyIovecs(usize, usize), 60 } 61 62 pub type Result<T> = ::std::result::Result<T, Error>; 63