Skip to content

Commit 6d1361f

Browse files
committed
Skip virtual file systems
1 parent 3006228 commit 6d1361f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::io::BufReader;
1515
use std::process;
1616

1717
use stats::Stats;
18-
use util::{bargraph, iec};
18+
use util::{bargraph, iec, is_virtual};
1919

2020
const FS_SPEC: usize = 0;
2121
const FS_FILE: usize = 1;
@@ -48,6 +48,9 @@ fn main() {
4848
match line {
4949
Ok(line) => {
5050
let fields: Vec<&str> = line.split_whitespace().collect();
51+
if !matches.is_present("all") && is_virtual(fields[FS_SPEC]) {
52+
continue;
53+
}
5154
let statvfs = match statvfs(fields[FS_FILE]) {
5255
Ok(s) => s,
5356
Err(err) => {

src/util.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ pub fn bargraph(mut percent: f64) -> String {
4646
format!("{}{}", bar1, bar2)
4747
}
4848

49+
pub fn is_virtual(fs: &str) -> bool {
50+
match fs {
51+
"devtmpfs" | "portal" | "tmpfs" => true,
52+
_ => fs.starts_with("/dev/loop") || fs.starts_with("systemd-"),
53+
}
54+
}
55+
4956
#[cfg(test)]
5057
mod tests {
5158
use super::shorten_lv;

0 commit comments

Comments
 (0)