import peripety-0.1.2-3.el8
This commit is contained in:
commit
e7c23e3cd3
|
@ -0,0 +1,2 @@
|
||||||
|
SOURCES/peripety-0.1.2-vendor.tar.xz
|
||||||
|
SOURCES/peripety-0.1.2.tar.gz
|
|
@ -0,0 +1,2 @@
|
||||||
|
1a34f4b1ee0ff875b2d77ea8b2ae6e44711ac7f4 SOURCES/peripety-0.1.2-vendor.tar.xz
|
||||||
|
2c3dc16f2dc3ff61a8317990a2e57cb77e5e5a72 SOURCES/peripety-0.1.2.tar.gz
|
|
@ -0,0 +1,26 @@
|
||||||
|
From d87a21b3ac27bf8551d27c7887b76df383d2ddd0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Gris Ge <fge@redhat.com>
|
||||||
|
Date: Tue, 5 Jun 2018 23:13:10 +0800
|
||||||
|
Subject: [PATCH] Fix compile on rust 1.20.0
|
||||||
|
|
||||||
|
Signed-off-by: Gris Ge <fge@redhat.com>
|
||||||
|
---
|
||||||
|
src/peripety/src/scsi.rs | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/peripety/src/scsi.rs b/src/peripety/src/scsi.rs
|
||||||
|
index 8369681..bb1a9ad 100644
|
||||||
|
--- a/src/peripety/src/scsi.rs
|
||||||
|
+++ b/src/peripety/src/scsi.rs
|
||||||
|
@@ -91,7 +91,7 @@ pub(crate) fn blk_info_get_scsi(blk: &str) -> Result<BlkInfo, PeripetyError> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- let preferred_blk_path = if let Some(u) = &uuid {
|
||||||
|
+ let preferred_blk_path = if let Some(ref u) = uuid {
|
||||||
|
format!("/dev/disk/by-uuid/{}", u)
|
||||||
|
} else {
|
||||||
|
get_prefered_blk_path(&blk_path)
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
From 436ab6dfc07d6c1c7345fdea57aeed2e41a1d72f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Gris Ge <fge@redhat.com>
|
||||||
|
Date: Tue, 25 Dec 2018 19:38:12 +0800
|
||||||
|
Subject: [PATCH] Replace getmntent with thread-safe libmount.
|
||||||
|
|
||||||
|
Signed-off-by: Gris Ge <fge@redhat.com>
|
||||||
|
---
|
||||||
|
src/peripety/Cargo.toml | 2 +-
|
||||||
|
src/peripety/src/blk_info.rs | 56 ++++++++++++------------------------
|
||||||
|
src/peripety/src/lib.rs | 2 +-
|
||||||
|
3 files changed, 21 insertions(+), 39 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/peripety/Cargo.toml b/src/peripety/Cargo.toml
|
||||||
|
index 8694693..ae6ab4c 100644
|
||||||
|
--- a/src/peripety/Cargo.toml
|
||||||
|
+++ b/src/peripety/Cargo.toml
|
||||||
|
@@ -8,4 +8,4 @@ serde = "1.0"
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde_derive = "1.0"
|
||||||
|
regex = "0.2.10"
|
||||||
|
-libc = "0.2"
|
||||||
|
+libmount = ">=0.1.10"
|
||||||
|
diff --git a/src/peripety/src/blk_info.rs b/src/peripety/src/blk_info.rs
|
||||||
|
index 7f17a00..add54ed 100644
|
||||||
|
--- a/src/peripety/src/blk_info.rs
|
||||||
|
+++ b/src/peripety/src/blk_info.rs
|
||||||
|
@@ -3,14 +3,13 @@ use super::error::PeripetyError;
|
||||||
|
use super::scsi;
|
||||||
|
use super::sysfs::Sysfs;
|
||||||
|
|
||||||
|
-use libc;
|
||||||
|
use regex::Regex;
|
||||||
|
use serde_json;
|
||||||
|
-use std::ffi::CStr;
|
||||||
|
-use std::ffi::CString;
|
||||||
|
use std::fmt;
|
||||||
|
use std::fs;
|
||||||
|
+use std::io::Read;
|
||||||
|
use std::path::Path;
|
||||||
|
+use libmount::mountinfo;
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Debug, Serialize)]
|
||||||
|
pub enum BlkType {
|
||||||
|
@@ -231,44 +230,27 @@ impl BlkInfo {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_mount_point(blk_path: &str) -> Option<String> {
|
||||||
|
- let mut ret = String::new();
|
||||||
|
- let fd = unsafe {
|
||||||
|
- libc::setmntent(
|
||||||
|
- CStr::from_bytes_with_nul(b"/proc/mounts\0")
|
||||||
|
- .expect("BUG: get_mount_point()")
|
||||||
|
- // ^We never panic as it is null terminated.
|
||||||
|
- .as_ptr(),
|
||||||
|
- CStr::from_bytes_with_nul(b"r\0")
|
||||||
|
- .expect("BUG")
|
||||||
|
- .as_ptr(),
|
||||||
|
- // ^We never panic as it is null terminated.
|
||||||
|
- )
|
||||||
|
- };
|
||||||
|
- if fd.is_null() {
|
||||||
|
- return None;
|
||||||
|
- }
|
||||||
|
- let mut entry = unsafe { libc::getmntent(fd) };
|
||||||
|
- while !entry.is_null() {
|
||||||
|
- let table: libc::mntent = unsafe { *entry };
|
||||||
|
- if let Ok(mnt_fsname) =
|
||||||
|
- unsafe { CStr::from_ptr(table.mnt_fsname).to_str() }
|
||||||
|
- {
|
||||||
|
- if mnt_fsname == blk_path {
|
||||||
|
- if let Ok(s) = unsafe {
|
||||||
|
- CString::from_raw(table.mnt_dir).into_string()
|
||||||
|
- } {
|
||||||
|
- ret = s;
|
||||||
|
- break;
|
||||||
|
+ let mut fd = fs::File::open("/proc/self/mountinfo").unwrap();
|
||||||
|
+ let mut data = Vec::new();
|
||||||
|
+ fd.read_to_end(&mut data).unwrap();
|
||||||
|
+
|
||||||
|
+ for e in mountinfo::Parser::new(&data) {
|
||||||
|
+ if let Ok(m) = e {
|
||||||
|
+ // TODO(Gris Ge): we should use read_link() to compare blk_path
|
||||||
|
+ // and mount_source.
|
||||||
|
+ if let Some(mount_source) = m.mount_source.into_owned().to_str()
|
||||||
|
+ {
|
||||||
|
+ if let Some(mount_point) =
|
||||||
|
+ m.mount_point.into_owned().to_str()
|
||||||
|
+ {
|
||||||
|
+ if mount_source == blk_path {
|
||||||
|
+ return Some(format!("{}", mount_point));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- entry = unsafe { libc::getmntent(fd) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- unsafe { libc::endmntent(fd) };
|
||||||
|
- if ret.is_empty() {
|
||||||
|
- return None;
|
||||||
|
- }
|
||||||
|
- Some(ret)
|
||||||
|
+ None
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn major_minor_to_blk_name(
|
||||||
|
diff --git a/src/peripety/src/lib.rs b/src/peripety/src/lib.rs
|
||||||
|
index ebd5412..8936656 100644
|
||||||
|
--- a/src/peripety/src/lib.rs
|
||||||
|
+++ b/src/peripety/src/lib.rs
|
||||||
|
@@ -29,7 +29,7 @@
|
||||||
|
extern crate serde;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde_derive;
|
||||||
|
-extern crate libc;
|
||||||
|
+extern crate libmount;
|
||||||
|
extern crate regex;
|
||||||
|
extern crate serde_json;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
Name: peripety
|
||||||
|
Version: 0.1.2
|
||||||
|
Release: 3%{?dist}
|
||||||
|
Summary: Storage event notification daemon
|
||||||
|
|
||||||
|
Group: System Environment/Daemons
|
||||||
|
License: MIT
|
||||||
|
URL: https://github.com/cathay4t/peripety
|
||||||
|
Source0: https://github.com/cathay4t/peripety/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||||
|
Source1: %{name}-%{version}-vendor.tar.xz
|
||||||
|
Patch0: 0001-Fix-compile-on-rust-1.20.0.patch
|
||||||
|
Patch1: BZ_1656060_Replace-getmntent-with-thread-safe-libmount.patch
|
||||||
|
BuildRequires: rust-toolset
|
||||||
|
BuildRequires: systemd systemd-devel
|
||||||
|
|
||||||
|
%description
|
||||||
|
Peripety is designed to parse system storage logging into structured storage
|
||||||
|
event helping user investigate storage issues.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
%patch0 -p1
|
||||||
|
%patch1 -p1
|
||||||
|
|
||||||
|
# Source1 is vendored dependencies
|
||||||
|
%cargo_prep -V 1
|
||||||
|
|
||||||
|
%build
|
||||||
|
make
|
||||||
|
|
||||||
|
%post
|
||||||
|
%systemd_post peripetyd.service
|
||||||
|
|
||||||
|
%preun
|
||||||
|
%systemd_preun peripetyd.service
|
||||||
|
|
||||||
|
%postun
|
||||||
|
%systemd_postun_with_restart peripetyd.service
|
||||||
|
|
||||||
|
%install
|
||||||
|
%make_install
|
||||||
|
|
||||||
|
%files
|
||||||
|
%doc
|
||||||
|
%{_bindir}/prpt
|
||||||
|
%{_bindir}/peripetyd
|
||||||
|
%{_mandir}/man1/prpt.1*
|
||||||
|
%{_sysconfdir}/peripetyd.conf
|
||||||
|
%{_unitdir}/peripetyd.service
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Jan 14 2019 Gris Ge <fge@redhat.com> - 0.1.2-3
|
||||||
|
- Fix daemon crash casued by getmntent (RHBZ #1656060)
|
||||||
|
|
||||||
|
* Sat Dec 08 2018 Gris Ge <fge@redhat.com> - 0.1.2-2
|
||||||
|
- Use non-SCL way. (RHBZ #1657444)
|
||||||
|
|
||||||
|
* Tue Jun 05 2018 Gris Ge <fge@redhat.com> - 0.1.2-1
|
||||||
|
- Initial release.
|
Loading…
Reference in New Issue