diff options
author | Canop <cano.petrole@gmail.com> | 2022-03-02 13:31:27 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2022-03-02 15:08:22 +0100 |
commit | 09b2d9d9826693c750df139422cf6ee0fff98d35 (patch) | |
tree | 1209297a5e4dd9c8680b0ac4fd6ee6ace5e80218 | |
parent | a96c971430e26586d7e3b4f3e32e88616b3e8c2b (diff) |
add 'unreachable' information in json and table
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | src/col.rs | 8 | ||||
-rw-r--r-- | src/cols.rs | 12 | ||||
-rw-r--r-- | src/json.rs | 3 | ||||
-rw-r--r-- | src/normal.rs | 5 | ||||
-rw-r--r-- | src/table.rs | 6 | ||||
-rw-r--r-- | website/docs/json.md | 19 |
9 files changed, 39 insertions, 27 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 16503c5..6bc7358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### next +- 'unreachable' information available in JSON and in the table (in the 'use' column). This mostly concerns disconnected remote filesystems. + <a name="v2.3.1"></a> ### v2.3.1 - 2022/03/01 - don't consider volumes of size 0 as normal - Fix #49 @@ -243,7 +243,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lfs" -version = "2.3.1" +version = "2.3.2-dev" dependencies = [ "argh", "crossterm", @@ -256,9 +256,9 @@ dependencies = [ [[package]] name = "lfs-core" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c1f252564182b5880ebf0a870c6deff0346454db9f37af4ee37627c841534e" +checksum = "ec3e0aa8084f3ffcf29e701228fd720a7aee41111bc90b6bac38ed9b5cc33e3c" dependencies = [ "lazy-regex", "libc", @@ -1,6 +1,6 @@ [package] name = "lfs" -version = "2.3.1" +version = "2.3.2-dev" authors = ["dystroy <denys.seguret@gmail.com>"] edition = "2021" keywords = ["linux", "filesystem", "fs"] @@ -15,7 +15,7 @@ rust-version = "1.56" argh = "0.1.7" crossterm = "0.22.1" file-size = "1.0.3" -lfs-core = "0.10.1" +lfs-core = "0.10.2" serde = "1.0" serde_json = "1.0" termimad = "0.20.0" @@ -175,26 +175,26 @@ impl Col { (None, Some(_)) => Ordering::Less, (None, None) => Ordering::Equal, }, - Self::Used => |a: &Mount, b: &Mount| match (&a.stats, &b.stats) { + Self::Used => |a: &Mount, b: &Mount| match (&a.stats(), &b.stats()) { (Some(a), Some(b)) => a.used().cmp(&b.used()), (Some(_), None) => Ordering::Greater, (None, Some(_)) => Ordering::Less, (None, None) => Ordering::Equal, }, - Self::Use | Self::UsePercent => |a: &Mount, b: &Mount| match (&a.stats, &b.stats) { + Self::Use | Self::UsePercent => |a: &Mount, b: &Mount| match (&a.stats(), &b.stats()) { // SAFETY: use_share() doesn't return NaN (Some(a), Some(b)) => a.use_share().partial_cmp(&b.use_share()).unwrap(), (Some(_), None) => Ordering::Greater, (None, Some(_)) => Ordering::Less, (None, None) => Ordering::Equal, }, - Self::Free => |a: &Mount, b: &Mount| match (&a.stats, &b.stats) { + Self::Free => |a: &Mount, b: &Mount| match (&a.stats(), &b.stats()) { (Some(a), Some(b)) => a.available().cmp(&b.available()), (Some(_), None) => Ordering::Greater, (None, Some(_)) => Ordering::Less, (None, None) => Ordering::Equal, }, - Self::Size => |a: &Mount, b: &Mount| match (&a.stats, &b.stats) { + Self::Size => |a: &Mount, b: &Mount| match (&a.stats(), &b.stats()) { (Some(a), Some(b)) => a.size().cmp(&b.size()), (Some(_), None) => Ordering::Greater, (None, Some(_)) => Ordering::Less, diff --git a/src/cols.rs b/src/cols.rs index d9a40a8..47826d2 100644 --- a/src/cols.rs +++ b/src/cols.rs @@ -201,7 +201,7 @@ mod cols_parsing { fn algebraic_cols() { check( "all - dev -inodes + label", - vec![Id, Filesystem, Type, Disk, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUsePercent, InodesFree, InodesCount, MountPoint, Label], + vec![Id, Filesystem, Type, Remote, Disk, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUsePercent, InodesFree, InodesCount, MountPoint, Label], ); check( "dev + dev +disk - use + size", @@ -209,19 +209,19 @@ mod cols_parsing { ); check( "all-default+use", - vec![Id, Dev, Label, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, Use], + vec![Id, Dev, Label, Remote, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, Use], ); check( "all+default", // special: all but default at the end - vec![Id, Dev, Label, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, Filesystem, Type, Disk, Used, Use, Free, Size, MountPoint] + vec![Id, Dev, Label, Remote, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, Filesystem, Type, Disk, Used, Use, Free, Size, MountPoint] ); check( "fs dev all", // we want all column but fs and dev at the start - vec![Filesystem, Dev, Id, Label, Type, Disk, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, MountPoint], + vec![Filesystem, Dev, Id, Label, Type, Remote, Disk, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, MountPoint], ); check( "fs dev all -id-disk", - vec![Filesystem, Dev, Label, Type, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, MountPoint], + vec![Filesystem, Dev, Label, Type, Remote, Used, Use, UsePercent, Free, Size, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount, MountPoint], ); } @@ -257,7 +257,7 @@ mod cols_parsing { ); check( "all-", - vec![Id, Dev, Label, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount], + vec![Id, Dev, Label, Remote, UsePercent, InodesUsed, InodesUse, InodesUsePercent, InodesFree, InodesCount], ); check( "-size+inodes_free+", diff --git a/src/json.rs b/src/json.rs index 988c22c..6fe2088 100644 --- a/src/json.rs +++ b/src/json.rs @@ -9,7 +9,7 @@ pub fn output_value(mounts: &[Mount], units: Units) -> Value { mounts .iter() .map(|mount| { - let stats = mount.stats.as_ref().map(|s| { + let stats = mount.stats().map(|s| { let inodes = s.inodes.as_ref().map(|inodes| { json!({ "files": inodes.files, @@ -53,6 +53,7 @@ pub fn output_value(mounts: &[Mount], units: Units) -> Value { "stats": stats, "bound": mount.info.bound, "remote": mount.info.is_remote(), + "unreachable": mount.is_unreachable(), }) }) .collect(), diff --git a/src/normal.rs b/src/normal.rs index 5b6c9be..2c81510 100644 --- a/src/normal.rs +++ b/src/normal.rs @@ -3,7 +3,10 @@ use lfs_core::Mount; /// Determine whether the mounted filesystem is "normal", which /// means it should be listed in standard pub fn is_normal(m: &Mount) -> bool { - m.stats.is_some() + ( + m.stats().is_some() + || m.is_unreachable() + ) && ( m.disk.is_some() // by default only fs with disks are shown || m.info.fs_type == "zfs" // unless it's zfs - see https://github.com/Canop/lfs/issues/32 diff --git a/src/table.rs b/src/table.rs index 8f9deb0..07e1c9d 100644 --- a/src/table.rs +++ b/src/table.rs @@ -43,7 +43,7 @@ pub fn print(mounts: &[Mount], color: bool, args: &Args) { if mount.info.is_remote() { sub.set("remote", "x"); } - if let Some(stats) = mount.stats.as_ref().filter(|s| s.size() > 0) { + if let Some(stats) = mount.stats() { let use_share = stats.use_share(); let pb = ProgressBar::new(use_share as f32, BAR_WIDTH); sub @@ -62,6 +62,8 @@ pub fn print(mounts: &[Mount], color: bool, args: &Args) { .set("ibar", format!("{:<width$}", ipb, width = INODES_BAR_WIDTH)) .set("ifree", inodes.favail); } + } else if mount.is_unreachable() { + sub.set("use-error", "unreachable"); } } let skin = if color { @@ -84,7 +86,7 @@ pub fn print(mounts: &[Mount], color: bool, args: &Args) { Col::Type => "${type}", Col::Remote => "${remote}", Col::Used => "~~${used}~~", - Col::Use => "~~${use-percents}~~ `${bar}`", + Col::Use => "~~${use-percents}~~ `${bar}`~~${use-error}~~", Col::UsePercent => "~~${use-percents}~~", Col::Free => "*${free}*", Col::Size => "**${size}**", diff --git a/website/docs/json.md b/website/docs/json.md index 33a65fc..af93c52 100644 --- a/website/docs/json.md +++ b/website/docs/json.md @@ -34,26 +34,29 @@ Here it is: "mount-point": "/", "remote": false, "stats": { - "available": "82G", - "bavail": 19918995, - "bfree": 22945324, + "available": "81G", + "bavail": 19764035, + "bfree": 22790364, "blocks": 59233748, "bsize": 4096, "inodes": { - "avail": 13875011, + "avail": 13880393, "files": 15114240, - "free": 13875011, + "free": 13880393, "used-percent": "8%" }, "size": "243G", - "used": "161G", - "used-percent": "66%" - } + "used": "162G", + "used-percent": "67%" + }, + "unreachable": false } ``` The `disk`, `stats`, and `stats.inodes` structures, or the `fs-label`, may be `null` for some filesystems. +Note that fields may be *added* in any version. + # All filesystems As for the table view, the JSON is by default limited to "normal" storage devices. |