Skip to content

Add --hide-fs to hide specific fs types #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2020
Merged

Conversation

RangerCD
Copy link
Contributor

Solves #12

Example:

duf --hide-fs=tmpfs,overlay

if len(fs) == 0 {
continue
}
hideMap[fs] = struct{}{}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth ensureing the inputted filetypes are converted to lowercase: e.g.

Suggested change
hideMap[fs] = struct{}{}
hideMap[strings.ToLower(fs)] = struct{}{}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not pretty sure whether this value is case-sensitive.

https://man7.org/linux/man-pages//man5/fs.5.html

FILESYSTEMS(5)             Linux Programmer's Manual            FILESYSTEMS(5)

NAME
       filesystems  -  Linux  filesystem  types:  ext, ext2, ext3, ext4, hpfs,
       iso9660, JFS, minix, msdos, ncpfs nfs, ntfs, proc, Reiserfs, smb, sysv,
       umsdos, vfat, XFS, xiafs,

It seems like fs types are case-sensitive according to the description.
But I'm confused now, since a XFS filesystem shows xfs in Fstype, but on that man page it says XFS.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you come to a conclusion here? Personally I think I agree, purely because users shouldn't be required to type XFS or JFS (all uppercase) on the command-line. This would probably cause a bunch of confusion, especially if the filtering doesn't apply silently: there wouldn't be an error or any indication that lowercase vs uppercase makes a difference here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After an experiment, I found out that the value of Fstype is case-sensitive. I've managed to create a mount point, with upper-case letter in its type name, by using hello example in libfuse. And this is how I tested:

  1. build hello example
  2. rename the output binary to Hello
  3. execute ./Hello /mnt, or any other mount point

Then duf --all shows:

...
│ MOUNTED ON               │ SIZE │ USED │ AVAIL │ USE% │ TYPE                   │ FILESYSTEM        │
├──────────────────────────┼──────┼──────┼───────┼──────┼────────────────────────┼───────────────────┤
│ /mnt                     │   0B │   0B │    0B │      │ fuse.Hello             │ Hello             │
...

I think it should not be a problem to make --hide-fs a case-sensitive flag. In a general scenario, user would specify --hide-fs after finding out there are too much unnecessary mount points listed, which means the actual type name is already printed on screen clearly.

Copy link
Owner

@muesli muesli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, almost there! Just a few tiny changes I'd appreciate.

if len(fs) == 0 {
continue
}
hideMap[fs] = struct{}{}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you come to a conclusion here? Personally I think I agree, purely because users shouldn't be required to type XFS or JFS (all uppercase) on the command-line. This would probably cause a bunch of confusion, especially if the filtering doesn't apply silently: there wouldn't be an error or any indication that lowercase vs uppercase makes a difference here.

@muesli muesli added the enhancement New feature or request label Oct 2, 2020
@muesli muesli merged commit 0a93666 into muesli:master Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants