Re: [PATCH] [xfs_db:type] do nothing if 'current type' == 'the requested type'

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

 



On 8/17/20 4:00 AM, Jianhong Yin wrote:
> From: Jianhong Yin <yin-jianhong@xxxxxxx>
> 
> for power saving and also as a workaround of below issue:
>> xfs_db -r /dev/vda3 -c "inode 132" -c "type inode" -c "inode"
>> current inode number is 128
> 
> Reported-by: Jianhong Yin <jiyin@xxxxxxxxxx>
> Suggested-by: Eric Sandeen <esandeen@xxxxxxxxxx>
> Tested-by: Jianhong Yin <yin-jianhong@xxxxxxx>
> Signed-off-by: Jianhong Yin <yin-jianhong@xxxxxxx>
> ---
>  db/type.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/db/type.c b/db/type.c
> index 3cb1e868..679de1b0 100644
> --- a/db/type.c
> +++ b/db/type.c
> @@ -213,6 +213,9 @@ type_f(
>  
>  
>  	} else {
> +		if (cur_typ != NULL && strcmp(cur_typ->name, argv[1]) == 0)
> +			return 0;
> +
>  		tt = findtyp(argv[1]);
>  		if (tt == NULL) {
>  			dbprintf(_("no such type %s\n"), argv[1]);

Thanks for this - I had a patch on my stack to do the same thing,
but did I it this way:

diff --git a/db/type.c b/db/type.c
index 3cb1e868..5433bcfb 100644
--- a/db/type.c
+++ b/db/type.c
@@ -219,6 +219,8 @@ type_f(
 		} else {
 			if (iocur_top->typ == NULL)
 				dbprintf(_("no current object\n"));
+			else if (iocur_top->typ == tt)
+				return 0;
 			else {
 				cur_typ = tt;
 				set_iocur_type(tt);

which I guess I like a little better than using strcmp on the argument...
it compares the type structure directly, rather than comparing the names.

-Eric




[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