diff mbox series

overlay: avoid to use NULL OVL_BASE_FSTYP for mounting

Message ID 20221229134434.1513212-1-libaokun1@huawei.com (mailing list archive)
State New, archived
Headers show
Series overlay: avoid to use NULL OVL_BASE_FSTYP for mounting | expand

Commit Message

Baokun Li Dec. 29, 2022, 1:44 p.m. UTC
Generally, FSTYP is used to specify OVL_BASE_FSTYP. When we specify FSTYP
through an environment variable, it is not converted to OVL_BASE_FSTYP.
In addition, sometimes we do not even specify the file type. For example,
we only use `./check -n -overlay -g auto` to list overlay-related cases.
If OVL_BASE_FSTYP is NULL, mounting fails and the test fails.

To solve this problem, try to assign a value to OVL_BASE_FSTYP when
specifying -overlay. In addition, in the _overlay_base_mount function,
the basic file system type of the overlay is specified only when
OVL_BASE_FSTYP is not NULL.

Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 check          | 1 +
 common/overlay | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Zorro Lang Jan. 1, 2023, 1:29 p.m. UTC | #1
On Thu, Dec 29, 2022 at 09:44:34PM +0800, Baokun Li wrote:
> Generally, FSTYP is used to specify OVL_BASE_FSTYP. When we specify FSTYP
> through an environment variable, it is not converted to OVL_BASE_FSTYP.
> In addition, sometimes we do not even specify the file type. For example,
> we only use `./check -n -overlay -g auto` to list overlay-related cases.
> If OVL_BASE_FSTYP is NULL, mounting fails and the test fails.
> 
> To solve this problem, try to assign a value to OVL_BASE_FSTYP when
> specifying -overlay. In addition, in the _overlay_base_mount function,
> the basic file system type of the overlay is specified only when
> OVL_BASE_FSTYP is not NULL.
> 
> Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> ---

Hi Murphy,

Does this patch fix the problem you hit?

Thanks,
Zorro

>  check          | 1 +
>  common/overlay | 7 ++++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/check b/check
> index 1ff0f44a..22062935 100755
> --- a/check
> +++ b/check
> @@ -283,6 +283,7 @@ while [ $# -gt 0 ]; do
>  		FSTYP="${1:1}"
>  		;;
>  	-overlay)
> +		[ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
>  		FSTYP=overlay
>  		export OVERLAY=true
>  		;;
> diff --git a/common/overlay b/common/overlay
> index e35419d0..20cafeb1 100644
> --- a/common/overlay
> +++ b/common/overlay
> @@ -85,7 +85,12 @@ _overlay_base_mount()
>  		return 1
>  	fi
>  
> -	_mount -t $OVL_BASE_FSTYP $* $dev $mnt
> +	if [ $OVL_BASE_FSTYP ]; then
> +		_mount -t $OVL_BASE_FSTYP $* $dev $mnt
> +	else
> +		_mount $* $dev $mnt
> +	fi
> +
>  	_idmapped_mount $dev $mnt
>  }
>  
> -- 
> 2.31.1
>
Murphy Zhou Jan. 4, 2023, 12:33 a.m. UTC | #2
Thanks! This fixed my original issue.

On Thu, Dec 29, 2022 at 9:24 PM Baokun Li <libaokun1@huawei.com> wrote:
>
> Generally, FSTYP is used to specify OVL_BASE_FSTYP. When we specify FSTYP
> through an environment variable, it is not converted to OVL_BASE_FSTYP.
> In addition, sometimes we do not even specify the file type. For example,
> we only use `./check -n -overlay -g auto` to list overlay-related cases.
> If OVL_BASE_FSTYP is NULL, mounting fails and the test fails.
>
> To solve this problem, try to assign a value to OVL_BASE_FSTYP when
> specifying -overlay. In addition, in the _overlay_base_mount function,
> the basic file system type of the overlay is specified only when
> OVL_BASE_FSTYP is not NULL.
>
> Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> ---
>  check          | 1 +
>  common/overlay | 7 ++++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/check b/check
> index 1ff0f44a..22062935 100755
> --- a/check
> +++ b/check
> @@ -283,6 +283,7 @@ while [ $# -gt 0 ]; do
>                 FSTYP="${1:1}"
>                 ;;
>         -overlay)
> +               [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
>                 FSTYP=overlay
>                 export OVERLAY=true
>                 ;;
> diff --git a/common/overlay b/common/overlay
> index e35419d0..20cafeb1 100644
> --- a/common/overlay
> +++ b/common/overlay
> @@ -85,7 +85,12 @@ _overlay_base_mount()
>                 return 1
>         fi
>
> -       _mount -t $OVL_BASE_FSTYP $* $dev $mnt
> +       if [ $OVL_BASE_FSTYP ]; then
> +               _mount -t $OVL_BASE_FSTYP $* $dev $mnt
> +       else
> +               _mount $* $dev $mnt
> +       fi
> +
>         _idmapped_mount $dev $mnt
>  }
>
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/check b/check
index 1ff0f44a..22062935 100755
--- a/check
+++ b/check
@@ -283,6 +283,7 @@  while [ $# -gt 0 ]; do
 		FSTYP="${1:1}"
 		;;
 	-overlay)
+		[ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
 		FSTYP=overlay
 		export OVERLAY=true
 		;;
diff --git a/common/overlay b/common/overlay
index e35419d0..20cafeb1 100644
--- a/common/overlay
+++ b/common/overlay
@@ -85,7 +85,12 @@  _overlay_base_mount()
 		return 1
 	fi
 
-	_mount -t $OVL_BASE_FSTYP $* $dev $mnt
+	if [ $OVL_BASE_FSTYP ]; then
+		_mount -t $OVL_BASE_FSTYP $* $dev $mnt
+	else
+		_mount $* $dev $mnt
+	fi
+
 	_idmapped_mount $dev $mnt
 }