diff mbox series

[1/6,v3] common/rc: _fs_sysfs_dname fetch fsid using btrfs tool

Message ID 6ac586f4697e84c846a36cbc42b005c254b83de1.1698674332.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs/219 cloned-device mount capability update | expand

Commit Message

Anand Jain Oct. 30, 2023, 2:15 p.m. UTC
Currently _fs_sysfs_dname gets fsid from the findmnt command however
this command provides the metadata_uuid in the context device is
mounted with temp-fsid. So instead, use btrfs filesystem show command to
know the temp-fsid.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---

v3: add local variable fsid

 common/rc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Filipe Manana Oct. 30, 2023, 4:16 p.m. UTC | #1
On Mon, Oct 30, 2023 at 2:15 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Currently _fs_sysfs_dname gets fsid from the findmnt command however
> this command provides the metadata_uuid in the context device is

in -> if

> mounted with temp-fsid. So instead, use btrfs filesystem show command to
> know the temp-fsid.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>
> v3: add local variable fsid
>
>  common/rc | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/common/rc b/common/rc
> index 259a1ffb09b9..18d2ddcf8e35 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4721,6 +4721,7 @@ _require_statx()
>  _fs_sysfs_dname()
>  {
>         local dev=$1
> +       local fsid
>
>         if [ ! -b "$dev" ]; then
>                 _fail "Usage: _fs_sysfs_dname <mounted_device>"
> @@ -4728,7 +4729,9 @@ _fs_sysfs_dname()
>
>         case "$FSTYP" in
>         btrfs)
> -               findmnt -n -o UUID ${dev} ;;
> +               fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \
> +                                                       awk '{print $NF}')

awk -> $AWK_PROG

Besides that, it looks fine, thanks.

Reviewed-by: Filipe Manana <fdmanana@suse.com>

> +               echo $fsid ;;
>         *)
>                 _short_dev $dev ;;
>         esac
> --
> 2.39.3
>
Anand Jain Oct. 30, 2023, 11:48 p.m. UTC | #2
On 10/31/23 00:16, Filipe Manana wrote:
> On Mon, Oct 30, 2023 at 2:15 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Currently _fs_sysfs_dname gets fsid from the findmnt command however
>> this command provides the metadata_uuid in the context device is
> 
> in -> if
> 
>> mounted with temp-fsid. So instead, use btrfs filesystem show command to
>> know the temp-fsid.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>
>> v3: add local variable fsid
>>
>>   common/rc | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/rc b/common/rc
>> index 259a1ffb09b9..18d2ddcf8e35 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -4721,6 +4721,7 @@ _require_statx()
>>   _fs_sysfs_dname()
>>   {
>>          local dev=$1
>> +       local fsid
>>
>>          if [ ! -b "$dev" ]; then
>>                  _fail "Usage: _fs_sysfs_dname <mounted_device>"
>> @@ -4728,7 +4729,9 @@ _fs_sysfs_dname()
>>
>>          case "$FSTYP" in
>>          btrfs)
>> -               findmnt -n -o UUID ${dev} ;;
>> +               fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \
>> +                                                       awk '{print $NF}')
> 
> awk -> $AWK_PROG
> 
> Besides that, it looks fine, thanks.
> 
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
> 

Fixed locally. Thx.

Anand

>> +               echo $fsid ;;
>>          *)
>>                  _short_dev $dev ;;
>>          esac
>> --
>> 2.39.3
>>
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 259a1ffb09b9..18d2ddcf8e35 100644
--- a/common/rc
+++ b/common/rc
@@ -4721,6 +4721,7 @@  _require_statx()
 _fs_sysfs_dname()
 {
 	local dev=$1
+	local fsid
 
 	if [ ! -b "$dev" ]; then
 		_fail "Usage: _fs_sysfs_dname <mounted_device>"
@@ -4728,7 +4729,9 @@  _fs_sysfs_dname()
 
 	case "$FSTYP" in
 	btrfs)
-		findmnt -n -o UUID ${dev} ;;
+		fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \
+							awk '{print $NF}')
+		echo $fsid ;;
 	*)
 		_short_dev $dev ;;
 	esac