Re: [PATCH 1/3] xfs: check that the mountpoint is actually mounted in _supports_xfs_scrub

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

 



On Thu, Jan 11, 2024 at 03:24:05PM +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@xxxxxx>
> ---
>  common/xfs | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index f53b33fc5..9db998837 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -649,6 +649,8 @@ _supports_xfs_scrub()
>  	test "$FSTYP" = "xfs" || return 1
>  	test -x "$XFS_SCRUB_PROG" || return 1
>  
> +	mountpoint $mountpoint >/dev/null || echo "$mountpoint is not mounted"

The helper needs to return nonzero on failure, e.g.

	if ! mountpoint -q $mountpoint; then
		echo "$mountpoint is not mounted"
		return 1
	fi

> +
>  	# Probe for kernel support...
>  	$XFS_IO_PROG -c 'help scrub' 2>&1 | grep -q 'types are:.*probe' || return 1

Like it already does down here.

--D

>  	$XFS_IO_PROG -c "scrub probe" "$mountpoint" 2>&1 | grep -q "Inappropriate ioctl" && return 1
> -- 
> 2.39.2
> 




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux