diff mbox

fcoe-utils: Fix get_ctlr_num() for large ctlr_* indices

Message ID 20170918143508.4659-1-Andrey.Grafin@acronis.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andrey Grafin Sept. 18, 2017, 2:35 p.m. UTC
Each creation of a FCoE device increases counter which is used as a suffix
in a FCoE device name in sysfs (i.e. /sys/bus/fcoe/devices/ctlr_1).
Once this counter reaches the value of two digits (10 and larger),
get_ctlr_num() stopped working properly and a command like `fcoeadm -i`
which depends on get_ctlr_num() call doesn't show anything.
This patch solves this problem.

Signed-off-by: Andrey Grafin <Andrey.Grafin@acronis.com>
---
 lib/sysfs_hba.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hannes Reinecke Sept. 19, 2017, 9:50 a.m. UTC | #1
On 09/18/2017 04:35 PM, Andrey Grafin wrote:
> Each creation of a FCoE device increases counter which is used as a suffix
> in a FCoE device name in sysfs (i.e. /sys/bus/fcoe/devices/ctlr_1).
> Once this counter reaches the value of two digits (10 and larger),
> get_ctlr_num() stopped working properly and a command like `fcoeadm -i`
> which depends on get_ctlr_num() call doesn't show anything.
> This patch solves this problem.
> 
> Signed-off-by: Andrey Grafin <Andrey.Grafin@acronis.com>
> ---
>  lib/sysfs_hba.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/sysfs_hba.c b/lib/sysfs_hba.c
> index 5cb7fd3fa5d..786215440ba 100644
> --- a/lib/sysfs_hba.c
> +++ b/lib/sysfs_hba.c
> @@ -606,7 +606,7 @@ static int get_ctlr_num(const char *netdev)
>  		if (!ctlr)
>  			continue;
>  
> -		ctlr_num = atoi(&ctlr[strlen(ctlr) - 1]);
> +		ctlr_num = atoi(&ctlr[sizeof("ctlr_") - 1]);
>  		break;
>  	}
>  
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Johannes Thumshirn Sept. 20, 2017, 10:23 a.m. UTC | #2
Applied, thanks.
diff mbox

Patch

diff --git a/lib/sysfs_hba.c b/lib/sysfs_hba.c
index 5cb7fd3fa5d..786215440ba 100644
--- a/lib/sysfs_hba.c
+++ b/lib/sysfs_hba.c
@@ -606,7 +606,7 @@  static int get_ctlr_num(const char *netdev)
 		if (!ctlr)
 			continue;
 
-		ctlr_num = atoi(&ctlr[strlen(ctlr) - 1]);
+		ctlr_num = atoi(&ctlr[sizeof("ctlr_") - 1]);
 		break;
 	}