Re: is there a util, or can findmnt be enhanced...(RFE?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 12, 2021 at 08:48:39PM -0800, L A Walsh wrote:
> On 2021/03/11 23:55, Karel Zak wrote:
> > $ pwd
> >  /home/projects/util-linux
> > 
> >  $ findmnt --target .
> >  TARGET SOURCE         FSTYPE OPTIONS
> >  /home  /dev/nvme0n1p2 ext4   rw,relatime
> ----
>    Hmmm.  Didn't know about that.  Thanks for the info!  Why does it
> produce no output when a non-mount-point is entered?  I.e. -- is that
> behavior something that is currently relied upon?

Do you mean the default output (when --target is not specified)?

The problem is that findmnt follows mount(8) behavior when search for
filesystem. It means you do not have to be explicit and you can use
source as well as target:

 $ findmnt /dev/sda2
 TARGET SOURCE    FSTYPE OPTIONS
 /boot  /dev/sda2 ext4   rw,relatime

 $ findmnt /boot
 TARGET SOURCE    FSTYPE OPTIONS
 /boot  /dev/sda2 ext4   rw,relatime


and if you try it with device which is not mounted

 $ findmnt /dev/sda3

you get nothing, but the same situation with --target:

 $ findmnt --target /dev/sda3
 TARGET SOURCE   FSTYPE   OPTIONS
 /dev   devtmpfs devtmpfs rw,nosuid,noexec,size=8144964k,nr_inodes=2036241,mode=755,inode64

now try to imagine --target is the default, you will get always any
answer for arbitrary path ... IMHO very confusing for many users.


I have doubts we can change this default behavior due to backward
compatibility (yes, the proper way how to use findmnt in scripts is to
use --target, --sources or --mountpoint, but people do not use it
...).

It would be probably better to introduce a small new util "path2fs" to
get mountpoint (or source), but without any other findmnt functionality.

We have mountpoint(1), but it returns TRUE/FALSE if the given path is
a mountpoint.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux