Skip to content

Commit

Permalink
version 2.3.0 - Show remote FS by default
Browse files Browse the repository at this point in the history
Fix #33
  • Loading branch information
Canop committed Feb 27, 2022
1 parent e1fce37 commit 9d49c5b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/col.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions src/normal.rs
Original file line number Diff line number Diff line change
@@ -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...
}
4 changes: 4 additions & 0 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}~~",
Expand Down
23 changes: 18 additions & 5 deletions website/docs/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,22 +74,34 @@ 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`:

![screen](img/rows-all.png)

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.
Expand Down

0 comments on commit 9d49c5b

Please sign in to comment.