Re: [PATCH v2 3/5] common/rc: introduce new helper function _fs_type_dev_dir()

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

 



On Fri, Feb 14, 2020 at 5:18 PM Mauricio Faria de Oliveira
<mfo@xxxxxxxxxxxxx> wrote:
>
> In order to determine the fs type on fuse-overlayfs (coming)
> we need to search for the mount point/directory; the device
> is not enough. (details in the next patch.)
>
> Thus the _fs_type() function is insufficient to determine
> the filesystem type, as it only searches for mount device.
>
> So, introduce the _fs_type_dev_dir() function, which also
> searches for the mountpoint/dir in addition to the device.
>
> The fs type fix-up sed script goes into a common function.
>
> P.S.: there might be other sites that need similar changes,
> since the mount device is also checked elsewhere, but just
> with this bit tests can run, so it is good enough for now.)
>
> Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxxxxx>

Looks ok.
You may add:
Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>

> ---
>  common/rc | 36 ++++++++++++++++++++++++++++--------
>  1 file changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index 1feae1a94f9e..5711eca2a1d2 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1262,6 +1262,19 @@ _used()
>      _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
>  }
>
> +# fix filesystem type up
> +#
> +_fix_fs_type()
> +{
> +    #
> +    # The Linux kernel shows NFSv4 filesystems in df output as
> +    # filesystem type nfs4, although we mounted it as nfs earlier.
> +    # Fix the filesystem type up here so that the callers don't
> +    # have to bother with this quirk.
> +    #
> +    sed -e 's/nfs4/nfs/' -e 's/fuse.glusterfs/glusterfs/'
> +}
> +
>  # return the FS type of a mounted device
>  #
>  _fs_type()
> @@ -1272,14 +1285,21 @@ _fs_type()
>         exit 1
>      fi
>
> -    #
> -    # The Linux kernel shows NFSv4 filesystems in df output as
> -    # filesystem type nfs4, although we mounted it as nfs earlier.
> -    # Fix the filesystem type up here so that the callers don't
> -    # have to bother with this quirk.
> -    #
> -    _df_device $1 | $AWK_PROG '{ print $2 }' | \
> -        sed -e 's/nfs4/nfs/' -e 's/fuse.glusterfs/glusterfs/'
> +    _df_device $1 | $AWK_PROG '{ print $2 }' | _fix_fs_type
> +}
> +
> +# return the FS type of a mounted device
> +# on a mount point directory (check both)
> +#
> +_fs_type_dev_dir()
> +{
> +    if [ $# -ne 2 ]
> +    then
> +       echo "Usage: _fs_type_dev_dir device directory" 1>&2
> +       exit 1
> +    fi
> +
> +    _df_dir $2 | $AWK_PROG -v what=$1 '($1==what) { print $2 }' | _fix_fs_type
>  }
>
>  # return the FS mount options of a mounted device
> --
> 2.20.1
>



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux