On 04/13/15 at 04:23pm, Baoquan He wrote:
On 04/10/15 at 09:31pm, Minfei Huang wrote:
> findmnt uses the option "-v, --nofsroot" to exclude the [/dir] in the
> SOURCE column for bind-mounts, then if $_mntpoint equals to
> $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
>
> the value of $_mntpoint may be
> /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
> directory is bind mounted. The former part represents the device path, the
> rest part is the bind mounted directory which quotes by bracket "[]".
>
> Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> ---
> kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index f24f08d..4ca0587 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -86,6 +86,38 @@ get_root_fs_device()
> return
> }
>
> +# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
~ exclude.
Thanks for correcting it again.
> +# in the SOURCE column for bind-mounts, then if $_mntpoint
equals to
> +# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
> +is_bind_mount()
> +{
> + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
> + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print
$2}')
> +
> + if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then
> + return 1
> + else
> + return 0
> + fi
> +}
> +
> +# the value of $_mntpoint will be
This is not for sure. Below is just an example happening very likely.
Will change in next patches.
Thanks
Minfei
> +#
/dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
> +# directory is bind mounted. The former part represents the device path, rest
> +# part is the bind mounted directory which quotes by bracket "[]".
> +get_bind_mount_directory()
> +{
> + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
> + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print
$2}')
> +
> + _mntpoint=${_mntpoint#*$_mntpoint_nofsroot}
> +
> + _mntpoint=${_mntpoint#[}
> + _mntpoint=${_mntpoint%]}
> +
> + echo $_mntpoint
> +}
> +
> get_mntpoint_from_path()
> {
> echo $(df $1 | tail -1 | awk '{print $NF}')
> --
> 1.9.3
>