Skip to content

Commit

Permalink
fix(nix): revert back to h2 fork
Browse files Browse the repository at this point in the history
Unfortunately, we still need to carry one patch around. To keep with the
trend of not having to update cargoSha256 with every cargo update we now
only need to specify the sha256 of the crates we patch. Note that this
will only work if the follow what the nix implementation expects, which
is a tag (rev).
  • Loading branch information
gila committed Jul 5, 2021
1 parent 084124b commit 79d576a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 33 deletions.
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[patch.crates-io]
h2 = { git = "https://github.com/openebs/h2", rev = "0.3.3"}

[profile.dev]
panic = "abort"
Expand Down
1 change: 0 additions & 1 deletion csi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ path = "src/server.rs"
[build-dependencies]
tonic-build = "0.4"
prost-build = "0.7"

[dependencies]
async-trait = "0.1.36"
async-stream = "0.3.0"
Expand Down
33 changes: 18 additions & 15 deletions devinfo/src/blkid/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::blkid::{
blkid_probe_has_value,
blkid_probe_lookup_value,
};
use core::slice;
use std::{
ffi::{CStr, CString},
path::Path,
Expand Down Expand Up @@ -44,32 +45,34 @@ impl Probe {
unsafe { to_result(blkid_do_safeprobe(self.0)) }
}

pub fn has_value(self, name: &str) -> bool {
let name = CString::new(name).unwrap();
let ret = unsafe { blkid_probe_has_value(self.0, name.as_ptr()) };
ret == 1
}

/// Fetch a value by name.
pub fn lookup_value(self, name: &str) -> Result<String, DevInfoError> {
let name = CString::new(name).unwrap();
let data_ptr = std::ptr::null_mut();
let mut data_ptr = std::ptr::null();
let mut len = 0;
unsafe {
to_result::<i32>(blkid_probe_lookup_value(
self.0,
name.as_ptr(),
data_ptr,
&mut data_ptr,
&mut len,
))?;
Ok(CStr::from_ptr(data_ptr.cast())
.to_string_lossy()
.to_string())
}
}

/// Returns `true` if the value exists.
pub fn has_value(&self, name: &str) -> Result<bool, DevInfoError> {
let name =
CString::new(name).expect("provided path contained null bytes");

unsafe {
to_result(blkid_probe_has_value(self.0, name.as_ptr()))
.map(|v| v == 1)
let str = CStr::from_bytes_with_nul(slice::from_raw_parts(
data_ptr.cast(),
len as usize,
))
.map_err(|_e| DevInfoError::InvalidStr {})?
.to_str()
.map_err(|_e| DevInfoError::InvalidStr {})?
.to_string();
Ok(str)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions mayastor/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,12 @@ where
} else {
Style::new()
};

let scope = self
.span
.and_then(|id| self.context.span(id))
.or_else(|| self.context.lookup_current())
.into_iter()
.flat_map(|span| span.from_root().chain(std::iter::once(span)));
.flat_map(|span| span.scope().from_root());

for span in scope {
write!(f, ":{}", bold.paint(span.metadata().name()))?;
Expand Down
46 changes: 36 additions & 10 deletions nix/pkgs/mayastor/cargo-package.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
{ stdenv, clang_11, dockerTools, e2fsprogs, lib, libaio, libspdk, libspdk-dev
, libudev, liburing, makeRustPlatform, numactl, openssl, pkg-config, protobuf
, sources, xfsprogs, utillinux, llvmPackages_11, targetPackages, buildPackages
, targetPlatform, version, cargoBuildFlags ? [ ] }:
{ stdenv
, clang_11
, dockerTools
, e2fsprogs
, lib
, libaio
, libspdk
, libspdk-dev
, libudev
, liburing
, makeRustPlatform
, numactl
, openssl
, pkg-config
, protobuf
, sources
, xfsprogs
, utillinux
, llvmPackages_11
, targetPackages
, buildPackages
, targetPlatform
, version
, cargoBuildFlags ? [ ]
}:
let
channel = import ../../lib/rust.nix { inherit sources; };
rustPlatform = makeRustPlatform {
rustc = channel.stable.rust;
cargo = channel.stable.cargo;
};
whitelistSource = src: allowedPrefixes:
builtins.filterSource (path: type:
lib.any
(allowedPrefix: lib.hasPrefix (toString (src + "/${allowedPrefix}")) path)
allowedPrefixes) src;
builtins.filterSource
(path: type:
lib.any
(allowedPrefix: lib.hasPrefix (toString (src + "/${allowedPrefix}")) path)
allowedPrefixes)
src;
src_list = [
".git"
"Cargo.lock"
Expand Down Expand Up @@ -50,12 +73,15 @@ let
];
cargoLock = {
lockFile = ../../../Cargo.lock;
outputHashes = { };
outputHashes = {
"h2-0.3.3" = "sha256-Y4AaBj10ZOutI37sVRY4yVUYmVWj5dwPbPhBhPWHNiQ=";
};
};
doCheck = false;
meta = { platforms = lib.platforms.linux; };
};
in {
in
{
release = rustPlatform.buildRustPackage (buildProps // {
buildType = "release";
buildInputs = buildProps.buildInputs ++ [ libspdk ];
Expand Down
1 change: 0 additions & 1 deletion test/grpc/test_csi.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ describe('csi', function () {
});
});

csiProtocolTest('NBD', enums.NEXUS_NBD, 10000);
csiProtocolTest('iSCSI', enums.NEXUS_ISCSI, 120000);
csiProtocolTest('NVMF', enums.NEXUS_NVMF, 120000);
});
Expand Down

0 comments on commit 79d576a

Please sign in to comment.