diff mbox series

[1/4] xfs: check that the mountpoint is actually mounted in _supports_xfs_scrub

Message ID 20240112050833.2255899-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/4] xfs: check that the mountpoint is actually mounted in _supports_xfs_scrub | expand

Commit Message

Christoph Hellwig Jan. 12, 2024, 5:08 a.m. UTC
Add a sanity check that the passed in mount point is actually mounted
to guard against actually calling _supports_xfs_scrub before
$SCRATCH_MNT is mounted.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 common/xfs | 3 +++
 1 file changed, 3 insertions(+)

Comments

Zorro Lang Jan. 12, 2024, 1:20 p.m. UTC | #1
On Fri, Jan 12, 2024 at 06:08:30AM +0100, Christoph Hellwig wrote:
> Add a sanity check that the passed in mount point is actually mounted
> to guard against actually calling _supports_xfs_scrub before
> $SCRATCH_MNT is mounted.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

This version is good to me, thanks!

Reviewed-by: Zorro Lang <zlang@redhat.com>

>  common/xfs | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index f53b33fc5..4e54d75cc 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -649,6 +649,9 @@ _supports_xfs_scrub()
>  	test "$FSTYP" = "xfs" || return 1
>  	test -x "$XFS_SCRUB_PROG" || return 1
>  
> +	mountpoint $mountpoint >/dev/null || \
> +		_fail "$mountpoint is not mounted"
> +
>  	# Probe for kernel support...
>  	$XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1
>  	$XFS_IO_PROG -c "scrub probe" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1
> -- 
> 2.39.2
> 
>
Darrick J. Wong Jan. 12, 2024, 4:41 p.m. UTC | #2
On Fri, Jan 12, 2024 at 06:08:30AM +0100, Christoph Hellwig wrote:
> Add a sanity check that the passed in mount point is actually mounted
> to guard against actually calling _supports_xfs_scrub before
> $SCRATCH_MNT is mounted.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  common/xfs | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index f53b33fc5..4e54d75cc 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -649,6 +649,9 @@ _supports_xfs_scrub()
>  	test "$FSTYP" = "xfs" || return 1
>  	test -x "$XFS_SCRUB_PROG" || return 1
>  
> +	mountpoint $mountpoint >/dev/null || \
> +		_fail "$mountpoint is not mounted"

Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +
>  	# Probe for kernel support...
>  	$XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1
>  	$XFS_IO_PROG -c "scrub probe" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1
> -- 
> 2.39.2
> 
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index f53b33fc5..4e54d75cc 100644
--- a/common/xfs
+++ b/common/xfs
@@ -649,6 +649,9 @@  _supports_xfs_scrub()
 	test "$FSTYP" = "xfs" || return 1
 	test -x "$XFS_SCRUB_PROG" || return 1
 
+	mountpoint $mountpoint >/dev/null || \
+		_fail "$mountpoint is not mounted"
+
 	# Probe for kernel support...
 	$XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1
 	$XFS_IO_PROG -c "scrub probe" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1