Re: [PATCH] dracut-lib.sh: add find_mount()

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

 



On Tue, May 22, 2012 at 05:56:09PM -0400, Will Woods wrote:
> Add a function to find the mount point for a given device.
> ---
>  modules.d/99base/dracut-lib.sh |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
> index 8a54a7a..b6168df 100755
> --- a/modules.d/99base/dracut-lib.sh
> +++ b/modules.d/99base/dracut-lib.sh
> @@ -402,6 +402,7 @@ udevproperty() {
>      fi
>  }
>  
> +# check if a given directory is a mounted filesystem
>  ismounted() {
>      while read a m a; do
>          [ "$m" = "$1" ] && return 0
> @@ -409,6 +410,16 @@ ismounted() {
>      return 1
>  }
>  
> +# find mountpoint for the given device
> +find_mount() {
> +    local wanted_dev="$1"; [ -b "$1" ] && wanted_dev=$(readlink -e -q "$1")
> +    local dev mnt etc
> +    while read -r dev mnt etc; do
> +        [ "$dev" = "$wanted_dev" ] && echo $mnt && return 0
> +    done < /proc/mounts
> +    return 1
> +}

 or

    findmnt -n --source $1 -o TARGET


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux