update to nix 0.14, use code from proxmox:tools

This commit is contained in:
Dietmar Maurer
2019-08-03 13:05:38 +02:00
parent b86f263ced
commit e18a6c9ee5
21 changed files with 104 additions and 294 deletions

View File

@ -220,8 +220,6 @@ where
}
}
use nix::{convert_ioctl_res, request_code_read, request_code_write, ioc};
// /usr/include/linux/fs.h: #define FS_IOC_GETFLAGS _IOR('f', 1, long)
// read Linux file system attributes (see man chattr)
nix::ioctl_read!(read_attr_fd, b'f', 1, usize);

View File

@ -6,7 +6,7 @@ use std::io::{BufRead, BufReader};
use std::collections::HashSet;
use std::process;
use std::net::{Ipv4Addr, Ipv6Addr};
use crate::tools;
use proxmox::tools::fs::file_read_firstline;
use lazy_static::lazy_static;
use regex::Regex;
use libc;
@ -32,7 +32,7 @@ pub struct ProcFsPidStat {
pub fn read_proc_pid_stat(pid: libc::pid_t) -> Result<ProcFsPidStat, Error> {
let statstr = tools::file_read_firstline(format!("/proc/{}/stat", pid))?;
let statstr = file_read_firstline(format!("/proc/{}/stat", pid))?;
lazy_static! {
static ref REGEX: Regex = Regex::new(concat!(
@ -89,7 +89,7 @@ pub fn check_process_running_pstart(pid: libc::pid_t, pstart: u64) -> Option<Pro
pub fn read_proc_uptime() -> Result<(f64, f64), Error> {
let path = "/proc/uptime";
let line = tools::file_read_firstline(&path)?;
let line = file_read_firstline(&path)?;
let mut values = line.split_whitespace().map(|v| v.parse::<f64>());
match (values.next(), values.next()) {
@ -152,7 +152,7 @@ pub fn read_meminfo() -> Result<ProcFsMemInfo, Error> {
meminfo.swapused = meminfo.swaptotal - meminfo.swapfree;
let spages_line = tools::file_read_firstline("/sys/kernel/mm/ksm/pages_sharing")?;
let spages_line = file_read_firstline("/sys/kernel/mm/ksm/pages_sharing")?;
meminfo.memshared = spages_line.trim_end().parse::<u64>()? * 4096;
Ok(meminfo)
@ -221,7 +221,7 @@ pub struct ProcFsMemUsage {
pub fn read_memory_usage() -> Result<ProcFsMemUsage, Error> {
let path = format!("/proc/{}/statm", process::id());
let line = tools::file_read_firstline(&path)?;
let line = file_read_firstline(&path)?;
let mut values = line.split_whitespace().map(|v| v.parse::<u64>());
let ps = 4096;

View File

@ -5,7 +5,7 @@ use std::os::unix::io::AsRawFd;
use failure::*;
use crate::try_block;
use proxmox::tools::try_block;
/// Returns whether the current stdin is a tty .
pub fn stdin_isatty() -> bool {