Newer
Older
/*
* Copyright (c) 2021, Luca Fulchir <luker@fenrirproject.org>
*
* This file is part of dfim.
*
* dfim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* dfim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with dfim. If not, see <https://www.gnu.org/licenses/>.
*/
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum Checksum {
Crc32c,
Xxhash,
Sha256,
Blake2,
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum Profile {
Raid0,
Raid1,
Raid1c3,
Raid1c4,
Raid5,
Raid6,
Raid10,
Single,
Dup,
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum HasFeature {
Enabled(Feature),
Disable(Feature),
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum Feature {
MixedBg,
Extrer,
Raid56,
SkinnyMetadata,
NoHole,
Raid1c34,
Zoned,
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum HasRuntimeFeature {
Enabled(Feature),
Disable(Feature),
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum RuntimeFeatures {
Quota,
FreeSpaceTree,
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub enum Options {
ByteCount(u64),
CheckSum(Checksum),
Data(Profile),
Metadata(Profile),
Mixed,
NodeSize(u16),
SectorSize(u64),
NoDiscard,
RootDir(::std::path::PathBuf),
Shrink,
Features(Vec<HasFeature>),
RuntimeFeatures(Vec<HasRuntimeFeature>),
Force,
Custom(String),
}
#[derive(::serde::Deserialize, ::serde::Serialize, Clone)]
pub struct BTRFS {
id: String,
label: Option<String>,
UUID: Option<::uuid::Uuid>,
fn id(&self) -> &str {
self.id.as_str()
}
fn create(&self) -> Result<(), ::std::io::Error> {
Ok(())
}
}
impl crate::config::CfgVerify for BTRFS {
fn standardize(&mut self) {}
fn check_consistency(
&self,
logger: &slog::Logger,
) -> Result<(), errors::ConfigError> {
Ok(())
}
}
impl PartialEq<BTRFS> for BTRFS {
fn eq(&self, other: &Self) -> bool {
match &self.label {
Some(self_label) => match &other.label {
Some(other_label) => {
if self_label != other_label {
return false;
}
}
_ => {}
},
_ => {}
}
// FIXME
true
}
}