Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit f5aca9c

Browse files
authored
Cleanup (#69)
* Cleanup - Change lingering refs. - use latest stable rustfmt to cleanup files. - Update travis.yml to use distinct stages. - Bump some deps to latest. Signed-off-by: Joe Grund <jgrund@whamcloud.io> * bump deps in prep for update Signed-off-by: Joe Grund <jgrund@whamcloud.io> * fixups Signed-off-by: Joe Grund <jgrund@whamcloud.io>
1 parent f6e7c8c commit f5aca9c

17 files changed

Lines changed: 282 additions & 352 deletions

File tree

.travis.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@ services:
55
jobs:
66
include:
77
- stage: test
8-
env: Type='bindgen test'
8+
name: "bindgen test"
99
script:
1010
- docker run -d -it --name libzfs -v $(pwd):/rust-libzfs:rw imlteam/zfs
1111
- docker exec -i libzfs bash -c 'cd /rust-libzfs/node-libzfs && cargo build'
1212
- docker exec -i libzfs bash -c 'cd /rust-libzfs/libzfs-sys && cargo test bindgen_test_layout'
1313
- stage: test
14-
env: Type='mock build'
14+
name: "mock build"
1515
language: node_js
1616
node_js: "10"
1717
script:
1818
- cd node-libzfs
1919
- npm run mock
20-
- stage: deploy
21-
env: Type='libzfs-sys'
22-
if: branch =~ ^v.+libzfs-sys$
20+
- stage: deploy-libzfs-sys
21+
name: "libzfs-sys"
2322
script:
2423
- docker run -d -it --name libzfs -v $(pwd):/rust-libzfs:rw imlteam/zfs
2524
- docker exec -i libzfs bash -c "cd /rust-libzfs/libzfs-sys && cargo package && cargo publish --token $CARGO_TOKEN"
26-
- stage: deploy
27-
env: Type='libzfs'
28-
if: branch =~ ^v.+\dlibzfs$
25+
- stage: deploy-libzfs
26+
name: "libzfs"
2927
script:
3028
- docker run -d -it --name libzfs -v $(pwd):/rust-libzfs:rw imlteam/zfs
3129
- docker exec -i libzfs bash -c "cd /rust-libzfs/libzfs && cargo package && cargo publish --token $CARGO_TOKEN"
32-
- stage: deploy
33-
env: Type='@iml/node-libzfs'
30+
- stage: deploy-node-libzfs
31+
name: "@iml/node-libzfs"
3432
language: node_js
3533
node_js: "10"
36-
if: branch =~ ^v.+node-libzfs$
3734
before_deploy:
3835
- cd node-libzfs
3936
deploy:
@@ -43,9 +40,8 @@ jobs:
4340
skip_cleanup: true
4441
on:
4542
tags: true
46-
- stage: deploy
47-
if: branch =~ ^v\d+\.\d+\.\d+-.+node-libzfs$
48-
env: Type='Copr deploy'
43+
- stage: deploy-copr
44+
name: "Copr deploy"
4945
before_deploy:
5046
- include/travis/copr-deploy.sh prepare
5147
deploy:
@@ -54,3 +50,13 @@ jobs:
5450
script: ./travis_wait "./include/travis/run_in_centos7_docker.sh ./include/travis/copr-deploy.sh build"
5551
on:
5652
all_branches: true
53+
stages:
54+
- test
55+
- name: deploy-libzfs-sys
56+
if: branch =~ ^v\d+\.\d+\.\d+libzfs-sys$
57+
- name: deploy-libzfs
58+
if: branch =~ ^v\d+\.\d+\.\d+libzfs$
59+
- name: deploy-node-libzfs
60+
if: branch =~ ^v\d+\.\d+\.\d+node-libzfs$
61+
- name: deploy-copr
62+
if: branch =~ ^v\d+\.\d+\.\d+-.+node-libzfs$

Cargo.lock

Lines changed: 21 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libzfs-sys/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "libzfs-sys"
3-
version = "0.5.6"
3+
version = "0.5.7"
44
description = "Rust bindings to libzfs"
55
license = "MIT"
6-
repository = "https://github.com/intel-hpdd/rust-libzfs"
7-
authors = ["Iml Team <iml@intel.com>"]
6+
repository = "https://github.com/whamcloud/rust-libzfs"
7+
authors = ["Iml Team <iml@whamcloud.com>"]
88
links = "zfs"
99
build = "build.rs"
1010

libzfs-sys/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
//! to the src dir. To rebuild bindings run `cargo build`.
1616
//!
1717
//! ## ZFS version
18-
//! These bindings were compiled against ZFS 0.7.9. As `libzfs` is not a stable interface,
18+
//! These bindings were compiled against ZFS 0.7.11. As `libzfs` is not a stable interface,
1919
//! they should only be used against this version.
2020
//!
2121
//! ## OS
2222
//!
23-
//! These bindings were compiled on Centos 7.4.x. They are likely to work against other
23+
//! These bindings were compiled on Centos 7.5.x. They are likely to work against other
2424
//! OS, but make sure to test first.
2525
//!
2626
@@ -133,10 +133,10 @@ pub fn to_vdev_aux(n: u32) -> Option<vdev_aux_t> {
133133
#[cfg(test)]
134134
mod tests {
135135
use super::*;
136-
use std::ptr;
136+
use std::ffi::{CStr, CString};
137137
use std::mem;
138138
use std::os::raw::{c_int, c_void};
139-
use std::ffi::{CStr, CString};
139+
use std::ptr;
140140

141141
fn create_libzfs_handle() -> *mut libzfs_handle_t {
142142
unsafe { libzfs_init() }

libzfs/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[package]
22
name = "libzfs"
3-
version = "0.6.7"
4-
authors = ["IML Team <iml@intel.com>"]
3+
version = "0.6.8"
4+
authors = ["IML Team <iml@whamcloud.com>"]
55
description = "Rust wrapper around libzfs-sys"
66
license = "MIT"
77

88
[dependencies]
9-
libzfs-sys = { path = "../libzfs-sys", version = "0.5.6" }
9+
libzfs-sys = { path = "../libzfs-sys", version = "0.5.7" }
1010
nvpair-sys = "0.1"
1111
serde = "1.0"
1212
serde_derive = "1.0"
1313
foreign-types = "0.3"
14-
cstr-argument = "0.0"
15-
lazy_static = "1.0"
14+
cstr-argument = "0.1"
15+
lazy_static = "1.1"

libzfs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ extern crate lazy_static;
1616

1717
extern crate libzfs_sys as sys;
1818

19-
mod nvpair;
2019
mod libzfs_error;
20+
mod nvpair;
2121

2222
pub mod vdev;
2323
pub use vdev::VDev;

libzfs/src/libzfs_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
use std::{error, fmt, result, str};
6-
use std::io::Error;
75
use std::ffi::IntoStringError;
6+
use std::io::Error;
7+
use std::{error, fmt, result, str};
88

99
#[derive(Debug)]
1010
pub enum LibZfsError {

libzfs/src/nvpair.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
extern crate nvpair_sys as nv_sys;
21
extern crate cstr_argument;
2+
extern crate nvpair_sys as nv_sys;
33

44
use self::cstr_argument::CStrArgument;
5-
use std::mem;
6-
use std::io;
7-
use std::ptr;
5+
pub use foreign_types::{ForeignType, ForeignTypeRef, Opaque};
86
use std::ffi;
7+
use std::io;
8+
use std::mem;
99
use std::os::raw::{c_int, c_uint};
10-
pub use foreign_types::{Opaque, ForeignTypeRef, ForeignType};
10+
use std::ptr;
1111

1212
pub trait NvEncode {
1313
fn insert<S: CStrArgument>(&self, S, &mut NvListRef) -> io::Result<()>;
@@ -211,7 +211,7 @@ impl NvListRef {
211211
v != nv_sys::boolean::B_FALSE
212212
}
213213

214-
/*
214+
/*
215215
// not allowed because `pair` is borrowed from `self`. Need to fiddle around so that we can
216216
// check:
217217
// - `pair` is from `self`
@@ -291,7 +291,6 @@ impl NvListRef {
291291
}
292292
}
293293

294-
295294
pub fn lookup_nv_list_array<S: CStrArgument>(&self, name: S) -> io::Result<Vec<NvList>> {
296295
let name = name.into_cstr();
297296

libzfs/src/vdev.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
extern crate libzfs_sys as sys;
66

7+
use libzfs_error::{LibZfsError, Result};
78
use nvpair;
89
use std::ffi::CStr;
9-
use libzfs_error::{LibZfsError, Result};
1010
use std::io::{Error, ErrorKind};
1111

1212
/// Represents vdevs
@@ -90,12 +90,12 @@ pub fn enumerate_vdev_tree(tree: &nvpair::NvList) -> Result<VDev> {
9090
}
9191

9292
fn lookup_guid(tree: &nvpair::NvList) -> Option<u64> {
93-
tree.lookup_uint64(sys::zpool_config_guid())
94-
.ok()
93+
tree.lookup_uint64(sys::zpool_config_guid()).ok()
9594
}
9695

9796
fn lookup_state(tree: &nvpair::NvList) -> Result<String> {
98-
let vdev_stats = tree.lookup_uint64_array(sys::zpool_config_vdev_stats())
97+
let vdev_stats = tree
98+
.lookup_uint64_array(sys::zpool_config_vdev_stats())
9999
.map(sys::to_vdev_stat)?;
100100

101101
let state = unsafe {
@@ -116,10 +116,13 @@ pub fn enumerate_vdev_tree(tree: &nvpair::NvList) -> Result<VDev> {
116116

117117
match x {
118118
x if x == sys::VDEV_TYPE_DISK => {
119-
let path = tree.lookup_string(sys::zpool_config_path())?.into_string()?;
119+
let path = tree
120+
.lookup_string(sys::zpool_config_path())?
121+
.into_string()?;
120122
let dev_id = lookup_tree_str(tree, sys::zpool_config_dev_id())?;
121123
let phys_path = lookup_tree_str(tree, sys::zpool_config_phys_path())?;
122-
let whole_disk = tree.lookup_uint64(sys::zpool_config_whole_disk())
124+
let whole_disk = tree
125+
.lookup_uint64(sys::zpool_config_whole_disk())
123126
.map(|x| x == 1)
124127
.ok();
125128

@@ -134,7 +137,9 @@ pub fn enumerate_vdev_tree(tree: &nvpair::NvList) -> Result<VDev> {
134137
})
135138
}
136139
x if x == sys::VDEV_TYPE_FILE => {
137-
let path = tree.lookup_string(sys::zpool_config_path())?.into_string()?;
140+
let path = tree
141+
.lookup_string(sys::zpool_config_path())?
142+
.into_string()?;
138143

139144
Ok(VDev::File {
140145
guid: lookup_guid(tree),
@@ -145,7 +150,8 @@ pub fn enumerate_vdev_tree(tree: &nvpair::NvList) -> Result<VDev> {
145150
}
146151
x if x == sys::VDEV_TYPE_MIRROR => {
147152
let children = get_children(tree)?;
148-
let is_log = tree.lookup_uint64(sys::zpool_config_is_log())
153+
let is_log = tree
154+
.lookup_uint64(sys::zpool_config_is_log())
149155
.map(|x| x == 1)
150156
.ok();
151157

0 commit comments

Comments
 (0)