Re: getmntent wrapper?

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

 



On Tue, Sep 27, 2016 at 12:25:32AM +0200, Andreas Fenkart wrote:
> Hi,
> 
> Parsing /etc/fstab or /proc/mount with sed/awk is awful and platform
> dependent. Would it be acceptable to add a wrapper for getmntent to
> parse those files and make the content available to shell scripts?
> 
> Typical use is to check if a given device is already mounted and
> returning its mountpoint. In case a device is mounted twice or more,
> several mountpoints will be listed
> 
> $ getmntent -f /proc/mounts /dev/sda4
> /mnt/
> /home/user/bind
> 
> Playing around with mount parsing the output with awk seems to work
> pretty well. It avoids to handle the whitespace separately.
> 
> $ mount -l  | awk  '/\/dev\/sda4/ { print $3; }'
> 
> negative:
> - I can't use the a different filesystem description file (small minus)
> - Is the output from 'mount' stable?
> 
> Is it worth to add a utility wrapper for getmntent to util-linux?

This sort of functionality already exists in findmnt(1).

$ findmnt -rno TARGET /dev/sdc1
/mnt/Haven
/srv/nfs/pkgs
/srv/nfs/vmbin
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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