This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move shared types into their own crate. Currently, taking a dep on libzfs means your crate gets linked against libzfs.so.2 libzpool.so.2 and libnvpair.so.2. Take device-aggregator for instance, which only takes a dep on libzfs to get shared types: ```shell $ ldd /usr/bin/device-aggregator linux-vdso.so.1 => (0x00007ffdba5b8000) libzfs.so.2 => not found libzpool.so.2 => not found libnvpair.so.1 => not found libdl.so.2 => /lib64/libdl.so.2 (0x00007f49332af000) librt.so.1 => /lib64/librt.so.1 (0x00007f49330a7000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4932e8b000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4932c75000) libc.so.6 => /lib64/libc.so.6 (0x00007f49328a8000) /lib64/ld-linux-x86-64.so.2 (0x00007f4933905000) libm.so.6 => /lib64/libm.so.6 (0x00007f49325a6000) ``` We don't need libzfs to be linked in crates that only need type access. Instead, extract types to their own standalone crate that doesn't have a dep on libzfs-sys. This way we can get type access without linking to unneeded shared objects. Signed-off-by: Joe Grund <[email protected]> * Move shared types into their own crate. Currently, taking a dep on libzfs means your crate gets linked against libzfs.so.2 libzpool.so.2 and libnvpair.so.2. Take device-aggregator for instance, which only takes a dep on libzfs to get shared types: ```shell $ ldd /usr/bin/device-aggregator linux-vdso.so.1 => (0x00007ffdba5b8000) libzfs.so.2 => not found libzpool.so.2 => not found libnvpair.so.1 => not found libdl.so.2 => /lib64/libdl.so.2 (0x00007f49332af000) librt.so.1 => /lib64/librt.so.1 (0x00007f49330a7000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4932e8b000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4932c75000) libc.so.6 => /lib64/libc.so.6 (0x00007f49328a8000) /lib64/ld-linux-x86-64.so.2 (0x00007f4933905000) libm.so.6 => /lib64/libm.so.6 (0x00007f49325a6000) ``` We don't need libzfs to be linked in crates that only need type access. Instead, extract types to their own standalone crate that doesn't have a dep on libzfs-sys. This way we can get type access without linking to unneeded shared objects. Signed-off-by: Joe Grund <[email protected]>
- Loading branch information
Showing
13 changed files
with
153 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
members = ['libzfs-sys', 'libzfs'] | ||
exclude = ['node-libzfs'] | ||
members = ['libzfs-sys', 'libzfs', 'libzfs-types'] | ||
exclude = ['node-libzfs'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "libzfs-types" | ||
version = "0.1.0" | ||
authors = ["IML Team <[email protected]>"] | ||
description = "Shared types for libzfs" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
serde = "1.0" | ||
serde_derive = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) 2018 DDN. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//! libzfs-types — Shared types for libzfs | ||
//! | ||
|
||
extern crate serde_derive; | ||
|
||
use serde_derive::{Deserialize, Serialize}; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Clone)] | ||
pub enum VDev { | ||
Mirror { | ||
children: Vec<VDev>, | ||
is_log: Option<bool>, | ||
}, | ||
RaidZ { | ||
children: Vec<VDev>, | ||
}, | ||
Replacing { | ||
children: Vec<VDev>, | ||
}, | ||
Root { | ||
children: Vec<VDev>, | ||
spares: Vec<VDev>, | ||
cache: Vec<VDev>, | ||
}, | ||
Disk { | ||
guid: Option<u64>, | ||
state: String, | ||
path: PathBuf, | ||
dev_id: Option<String>, | ||
phys_path: Option<String>, | ||
whole_disk: Option<bool>, | ||
is_log: Option<bool>, | ||
}, | ||
File { | ||
guid: Option<u64>, | ||
state: String, | ||
path: PathBuf, | ||
is_log: Option<bool>, | ||
}, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Hash, Deserialize, Serialize, Clone)] | ||
pub struct ZProp { | ||
pub name: String, | ||
pub value: String, | ||
} | ||
|
||
/// A Pool at a point in time | ||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct Pool { | ||
pub name: String, | ||
pub guid: u64, | ||
pub health: String, | ||
pub hostname: String, | ||
pub hostid: Option<u64>, | ||
pub state: String, | ||
pub readonly: bool, | ||
pub size: String, | ||
pub vdev: VDev, | ||
pub props: Vec<ZProp>, | ||
pub datasets: Vec<Dataset>, | ||
} | ||
|
||
/// A Dataset at a point in time | ||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct Dataset { | ||
pub name: String, | ||
pub guid: String, | ||
pub kind: String, | ||
pub props: Vec<ZProp>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.