summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-02-27 15:22:29 +0100
committerCanop <cano.petrole@gmail.com>2022-02-27 15:22:29 +0100
commit9d49c5b643caa8b279399177da44b293a9a44128 (patch)
treea4cb12b70219992cbb6b50e6b2a653f5784f500f
parente1fce37165aabb8fdbd016c69044262125f814d3 (diff)
version 2.3.0 - Show remote FS by defaultv2.3.0
Fix #33
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml4
-rw-r--r--src/col.rs5
-rw-r--r--src/json.rs1
-rw-r--r--src/main.rs15
-rw-r--r--src/normal.rs13
-rw-r--r--src/table.rs4
-rw-r--r--website/docs/table.md23
9 files changed, 56 insertions, 19 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d17180c..4f97412 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+<a name="v2.3.0"></a>
+### v2.3.0 - 2022/02/27
+- "remote" column. Remote filesystems included by default - Fix #33
+
<a name="v2.2.0"></a>
### v2.2.0 - 2022/02/26
- `--sort` launch argument for sorting rows in table - Fix #37
diff --git a/Cargo.lock b/Cargo.lock
index 2860e52..f72151d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -243,7 +243,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lfs"
-version = "2.2.0"
+version = "2.3.0"
dependencies = [
"argh",
"crossterm",
@@ -256,9 +256,9 @@ dependencies = [
[[package]]
name = "lfs-core"
-version = "0.9.1"
+version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39bbfb9f99dd92414b005d727b770f0f1c5a81a9f63809743294e6d1dc5d8ca2"
+checksum = "c1629c9c61167ae4b422a458828367f80dfa8a3858e73d8e131d8377ae2fde36"
dependencies = [
"lazy-regex",
"libc",
diff --git a/Cargo.toml b/Cargo.toml
index 828a2df..a8ea693 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "lfs"
-version = "2.2.0"
+version = "2.3.0"
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.9.1"
+lfs-core = "0.10.0"
serde = "1.0"
serde_json = "1.0"
termimad = "0.20.0"
diff --git a/src/col.rs b/src/col.rs
index c9a5fba..633bdb9 100644
--- a/src/col.rs
+++ b/src/col.rs
@@ -89,6 +89,7 @@ col_enum!(
Filesystem "fs" "filesystem": "filesystem" default,
Label "label": "label",
Type "type": "type" default,
+ Remote "remote" "rem": "remote",
Disk "disk" "dsk": "disk" default,
Used "used": "used" default,
Use "use": "use%" default,
@@ -118,6 +119,7 @@ impl Col {
Self::Filesystem => Alignment::Left,
Self::Label => Alignment::Left,
Self::Type => Alignment::Center,
+ Self::Remote => Alignment::Center,
Self::Disk => Alignment::Center,
Self::Used => Alignment::Right,
Self::Use => Alignment::Right,
@@ -139,6 +141,7 @@ impl Col {
Self::Filesystem => "filesystem",
Self::Label => "volume label",
Self::Type => "filesystem type",
+ Self::Remote => "whether it's a remote filesystem",
Self::Disk => "storage type",
Self::Used => "size used",
Self::Use => "usage graphical view",
@@ -165,6 +168,7 @@ impl Col {
(None, None) => Ordering::Equal,
},
Self::Type => |a: &Mount, b: &Mount| a.info.fs_type.cmp(&b.info.fs_type),
+ Self::Remote => |a: &Mount, b: &Mount| a.info.is_remote().cmp(&b.info.is_remote()),
Self::Disk => |a: &Mount, b: &Mount| match (&a.disk, &b.disk) {
(Some(a), Some(b)) => a.disk_type().to_lowercase().cmp(&b.disk_type().to_lowercase()),
(Some(_), None) => Ordering::Greater,
@@ -231,6 +235,7 @@ impl Col {
Self::Filesystem => Order::Asc,
Self::Label => Order::Asc,
Self::Type => Order::Asc,
+ Self::Remote => Order::Desc,
Self::Disk => Order::Asc,
Self::Used => Order::Asc,
Self::Use => Order::Desc,
diff --git a/src/json.rs b/src/json.rs
index 08f15cd..988c22c 100644
--- a/src/json.rs
+++ b/src/json.rs
@@ -52,6 +52,7 @@ pub fn output_value(mounts: &[Mount], units: Units) -> Value {
"disk": disk,
"stats": stats,
"bound": mount.info.bound,
+ "remote": mount.info.is_remote(),
})
})
.collect(),
diff --git a/src/main.rs b/src/main.rs
index ee82617..7e3b7a3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,13 +3,17 @@ mod col;
mod cols;
mod json;
mod list_cols;
+mod normal;
mod order;
mod sorting;
mod table;
mod units;
use {
- crate::args::*,
+ crate::{
+ args::*,
+ normal::*,
+ },
std::{
fs,
os::unix::fs::MetadataExt,
@@ -34,14 +38,7 @@ fn main() {
}
};
if !args.all {
- mounts.retain(|m|
- (
- 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
- )
- && !m.info.bound // removing bound mounts
- && m.info.fs_type != "squashfs", // quite ad-hoc...
- );
+ mounts.retain(is_normal);
}
if let Some(path) = &args.path {
let md = match fs::metadata(path) {
diff --git a/src/normal.rs b/src/normal.rs
new file mode 100644
index 0000000..e39d80f
--- /dev/null
+++ b/src/normal.rs
@@ -0,0 +1,13 @@
+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.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
+ || m.info.is_remote()
+ )
+ && !m.info.bound // removing bound mounts
+ && m.info.fs_type != "squashfs" // quite ad-hoc...
+}
diff --git a/src/table.rs b/src/table.rs
index 5d4a10b..8f9deb0 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -40,6 +40,9 @@ pub fn print(mounts: &[Mount], color: bool, args: &Args) {
if let Some(label) = &mount.fs_label {
sub.set("label", label);
}
+ if mount.info.is_remote() {
+ sub.set("remote", "x");
+ }
if let Some(stats) = mount.stats.as_ref().filter(|s| s.size() > 0) {
let use_share = stats.use_share();
let pb = ProgressBar::new(use_share as f32, BAR_WIDTH);
@@ -79,6 +82,7 @@ pub fn print(mounts: &[Mount], color: bool, args: &Args) {
Col::Label => "${label}",
Col::Disk => "${disk}",
Col::Type => "${type}",
+ Col::Remote => "${remote}",
Col::Used => "~~${used}~~",
Col::Use => "~~${use-percents}~~ `${bar}`",
Col::UsePercent => "~~${use-percents}~~",
diff --git a/website/docs/table.md b/website/docs/table.md
index 2d1b9ab..8b49aaf 100644
--- a/website/docs/table.md
+++ b/website/docs/table.md
@@ -15,6 +15,7 @@ dev | | device id
filesystem | ✓ | filesystem
label | | label
type | ✓ | filesystem type
+remote | | whether it's a remote filesystem
disk | ✓ | short tag of the underlying storage identified
used | ✓ | cumulated size of the occupied blocks
use | ✓ | graphical view of the use share
@@ -73,15 +74,19 @@ Here's removing the `fs` column and moving the `type` column to the end, with `l
# Rows
-The default selection of filesystems showcases your storage, avoiding any filesystem with no "disk", bound to another filesystem, etc.
+## Normality
-![screen](img/rows-standard.png)
+The default selection of filesystems showcases your storage, avoiding any filesystem which both have no "disk" and aren't remote ones, bound to another filesystem, etc.
-If you're only interested in the device on which some file is, give the path as argument.
+![screen](img/rows-standard.png)
-For example, for the current device, use `lfs .`:
+Here are the rules of the current heuristics, in order: a filesystem
-![screen](img/rows-current.png)
+1. is excluded when it's bound to a previous one
+1. is excluded when it's of type `squashfs`
+1. is included when it's of type `zfs`
+1. is included when it's remote
+1. is excluded when no underlying disk was found
To see *all* filesystems of your system, do `lfs --all`:
@@ -89,6 +94,14 @@ To see *all* filesystems of your system, do `lfs --all`:
This list can be quite big with virtual file systems, docker use, etc.
+## Current filesystem
+
+If you're only interested in the device on which some file is, give the path as argument.
+
+For example, for the current device, use `lfs .`:
+
+![screen](img/rows-current.png)
+
## Sort
With the `--sort` launch argument, shortened as `-s`, you can specify the order of displayed rows.