On 04/09/15 at 10:46am, Dave Young wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
> The filesystem support the device to be mounted different mount points.
> The root path in the device may be different, if the mount point is
> mounted by bind mode. In order to dump core correctly, we should find
> the root path in the device.
>
> Following is the case that device is mounted by bind mode.
>
> TARGET SOURCE FSTYPE OPTIONS
> /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache
> TARGET SOURCE FSTYPE OPTIONS
> /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
>
> We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in
> the other word, the /mnt/bind-dir points to the /var directory in the
> /dev/vda.
> The /mnt/ext4 is the root path in the device.
>
> Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> ---
> kdump-lib.sh | 11 ++++++++++-
> mkdumprd | 8 ++------
> 2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 2ad528e..75d7673 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -135,7 +135,16 @@ get_fs_type_from_target()
>
> get_mntpoint_from_target()
> {
> - echo $(findmnt -k -f -n -r -o TARGET $1)
> + for _mnt in $(findmnt -k -n -r -o TARGET $1)
> + do
> + if ! is_bind_mount $_mnt; then
> + echo $_mnt
> + return
> + fi
> + done
> +
> + echo "Mount $1 firstly, without the bind mode" >&2
> + exit 1
Per discussion, we should limit the function only to atomic case.
So it should be like below:
get_mntpoint_from_target(){
if (!atomic)
echo $(findmnt -k -f -n -r -o TARGET $1)
else {
...
}
}
It does not impact on the general system, so there is no limitation
for this function.
Thanks
Minfei
> }
>
> # get_option_value <option_name>
> diff --git a/mkdumprd b/mkdumprd
> index a8f9cbb..7fdcebf 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -100,7 +100,7 @@ to_mount() {
> local _dev=$1 _source _target _fstype _options _mntopts _pdev
>
> _source=$(findmnt -k -f -n -r -o SOURCE $_dev)
> - _target=$(findmnt -k -f -n -r -o TARGET $_dev)
> + _target=$(get_mntpoint_from_target $_dev)
> # mount under /sysroot if dump to root disk or mount under
> #/kdumproot/$_target in other cases in 2nd kernel. systemd
> #will be in charge to umount it.
> @@ -144,10 +144,6 @@ to_mount() {
> echo "$_pdev $_mntopts"
> }
>
> -to_mount_point() {
> - echo $(findmnt -k -f -n -r -o TARGET $1)
> -}
> -
> is_readonly_mount() {
> local _mnt
> _mnt=$(findmnt -k -f -n -r -o OPTIONS $1)
> @@ -201,7 +197,7 @@ mkdir_save_path_ssh()
> #Function: get_fs_size
> #$1=dump target
> get_fs_size() {
> - local _mnt=$(to_mount_point $1)
> + local _mnt=$(get_mntpoint_from_target $1)
> echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print
$4}')
> }
>
> --
> 1.9.3
>