All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output
@ 2026-08-12  6:39 Jason Colapietro
  2026-08-12  6:39 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Jason Colapietro
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jason Colapietro @ 2026-08-12  6:39 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Shuah Khan
  Cc: Hongren Zheng, Greg KH, linux-usb, linux-kernel

The -p option only affects local devices and gadgets. Remote lists still
print their human-readable headings and details, so scripts cannot parse
them using the documented option.

Pass the parsable flag through the remote listing path. Emit the same busid
and usbid record used for local devices while continuing to consume every
interface record from the server.

Fixes: e9837bbb3e69 ("staging: usbip: userspace tools v1.0.0")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219502
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5
Signed-off-by: Jason Colapietro <jasoncola1@gmail.com>
---
 tools/usb/usbip/src/usbip_list.c | 33 ++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index 3d810bcca..b9d60b87e 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -41,7 +41,7 @@ void usbip_list_usage(void)
 	printf("usage: %s", usbip_list_usage_string);
 }
 
-static int get_exported_devices(char *host, int sockfd)
+static int get_exported_devices(char *host, int sockfd, bool parsable)
 {
 	char product_name[100];
 	char class_name[100];
@@ -80,9 +80,11 @@ static int get_exported_devices(char *host, int sockfd)
 		return 0;
 	}
 
-	printf("Exportable USB devices\n");
-	printf("======================\n");
-	printf(" - %s\n", host);
+	if (!parsable) {
+		printf("Exportable USB devices\n");
+		printf("======================\n");
+		printf(" - %s\n", host);
+	}
 
 	for (i = 0; i < reply.ndev; i++) {
 		memset(&udev, 0, sizeof(udev));
@@ -98,9 +100,14 @@ static int get_exported_devices(char *host, int sockfd)
 		usbip_names_get_class(class_name, sizeof(class_name),
 				      udev.bDeviceClass, udev.bDeviceSubClass,
 				      udev.bDeviceProtocol);
-		printf("%11s: %s\n", udev.busid, product_name);
-		printf("%11s: %s\n", "", udev.path);
-		printf("%11s: %s\n", "", class_name);
+		if (parsable) {
+			printf("busid=%s#usbid=%04x:%04x#\n", udev.busid,
+			       udev.idVendor, udev.idProduct);
+		} else {
+			printf("%11s: %s\n", udev.busid, product_name);
+			printf("%11s: %s\n", "", udev.path);
+			printf("%11s: %s\n", "", class_name);
+		}
 
 		for (j = 0; j < udev.bNumInterfaces; j++) {
 			rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
@@ -116,16 +123,18 @@ static int get_exported_devices(char *host, int sockfd)
 					uintf.bInterfaceClass,
 					uintf.bInterfaceSubClass,
 					uintf.bInterfaceProtocol);
-			printf("%11s: %2d - %s\n", "", j, class_name);
+			if (!parsable)
+				printf("%11s: %2d - %s\n", "", j, class_name);
 		}
 
-		printf("\n");
+		if (!parsable)
+			printf("\n");
 	}
 
 	return 0;
 }
 
-static int list_exported_devices(char *host)
+static int list_exported_devices(char *host, bool parsable)
 {
 	int rc;
 	int sockfd;
@@ -138,7 +147,7 @@ static int list_exported_devices(char *host)
 	}
 	dbg("connected to %s:%s", host, usbip_port_string);
 
-	rc = get_exported_devices(host, sockfd);
+	rc = get_exported_devices(host, sockfd, parsable);
 	if (rc < 0) {
 		err("failed to get device list from %s", host);
 		return -1;
@@ -351,7 +360,7 @@ int usbip_list(int argc, char *argv[])
 			parsable = true;
 			break;
 		case 'r':
-			ret = list_exported_devices(optarg);
+			ret = list_exported_devices(optarg, parsable);
 			goto out;
 		case 'l':
 			ret = list_devices(parsable);
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order
  2026-08-12  6:39 [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Jason Colapietro
@ 2026-08-12  6:39 ` Jason Colapietro
  2026-08-12  7:24   ` Greg KH
  2026-08-12  7:22 ` [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Greg KH
  2026-08-12  7:23 ` Greg KH
  2 siblings, 1 reply; 5+ messages in thread
From: Jason Colapietro @ 2026-08-12  6:39 UTC (permalink / raw)
  To: Valentina Manea, Shuah Khan, Shuah Khan
  Cc: Hongren Zheng, Greg KH, linux-usb, linux-kernel

usbip_list() acts on -r, -l and -d as soon as getopt_long() returns them,
so any option parsed afterwards is never seen. -p therefore only takes
effect when it precedes the mode selector: "usbip list -p -r <host>" is
parsable while "usbip list -r <host> -p" is not, and -l and -d behave the
same way. Nothing in the usage text suggests the order matters.

Record the requested mode during the option loop and run it once parsing
has finished, so -p applies wherever it appears on the command line. When
several mode selectors are given the first one still wins, as before.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Jason Colapietro <jasoncola1@gmail.com>
---
 tools/usb/usbip/src/usbip_list.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index b9d60b87e..632a968a0 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -343,6 +343,8 @@ int usbip_list(int argc, char *argv[])
 	};
 
 	bool parsable = false;
+	char *remote_host = NULL;
+	int action = 0;
 	int opt;
 	int ret = -1;
 
@@ -360,19 +362,36 @@ int usbip_list(int argc, char *argv[])
 			parsable = true;
 			break;
 		case 'r':
-			ret = list_exported_devices(optarg, parsable);
-			goto out;
+			if (!action) {
+				action = opt;
+				remote_host = optarg;
+			}
+			break;
 		case 'l':
-			ret = list_devices(parsable);
-			goto out;
 		case 'd':
-			ret = list_gadget_devices(parsable);
-			goto out;
+			if (!action)
+				action = opt;
+			break;
 		default:
 			goto err_out;
 		}
 	}
 
+	switch (action) {
+	case 'r':
+		ret = list_exported_devices(remote_host, parsable);
+		break;
+	case 'l':
+		ret = list_devices(parsable);
+		break;
+	case 'd':
+		ret = list_gadget_devices(parsable);
+		break;
+	default:
+		goto err_out;
+	}
+	goto out;
+
 err_out:
 	usbip_list_usage();
 out:
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output
  2026-08-12  6:39 [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Jason Colapietro
  2026-08-12  6:39 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Jason Colapietro
@ 2026-08-12  7:22 ` Greg KH
  2026-08-12  7:23 ` Greg KH
  2 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-08-12  7:22 UTC (permalink / raw)
  To: Jason Colapietro
  Cc: Valentina Manea, Shuah Khan, Shuah Khan, Hongren Zheng, linux-usb,
	linux-kernel

On Wed, Aug 12, 2026 at 02:39:09AM -0400, Jason Colapietro wrote:
> The -p option only affects local devices and gadgets. Remote lists still
> print their human-readable headings and details, so scripts cannot parse
> them using the documented option.
> 
> Pass the parsable flag through the remote listing path. Emit the same busid
> and usbid record used for local devices while continuing to consume every
> interface record from the server.
> 
> Fixes: e9837bbb3e69 ("staging: usbip: userspace tools v1.0.0")
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219502
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jason Colapietro <jasoncola1@gmail.com>
> ---
>  tools/usb/usbip/src/usbip_list.c | 33 ++++++++++++++++++++------------
>  1 file changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
> index 3d810bcca..b9d60b87e 100644
> --- a/tools/usb/usbip/src/usbip_list.c
> +++ b/tools/usb/usbip/src/usbip_list.c
> @@ -41,7 +41,7 @@ void usbip_list_usage(void)
>  	printf("usage: %s", usbip_list_usage_string);
>  }
>  
> -static int get_exported_devices(char *host, int sockfd)
> +static int get_exported_devices(char *host, int sockfd, bool parsable)
>  {
>  	char product_name[100];
>  	char class_name[100];
> @@ -80,9 +80,11 @@ static int get_exported_devices(char *host, int sockfd)
>  		return 0;
>  	}
>  
> -	printf("Exportable USB devices\n");
> -	printf("======================\n");
> -	printf(" - %s\n", host);
> +	if (!parsable) {
> +		printf("Exportable USB devices\n");
> +		printf("======================\n");
> +		printf(" - %s\n", host);
> +	}
>  
>  	for (i = 0; i < reply.ndev; i++) {
>  		memset(&udev, 0, sizeof(udev));
> @@ -98,9 +100,14 @@ static int get_exported_devices(char *host, int sockfd)
>  		usbip_names_get_class(class_name, sizeof(class_name),
>  				      udev.bDeviceClass, udev.bDeviceSubClass,
>  				      udev.bDeviceProtocol);
> -		printf("%11s: %s\n", udev.busid, product_name);
> -		printf("%11s: %s\n", "", udev.path);
> -		printf("%11s: %s\n", "", class_name);
> +		if (parsable) {
> +			printf("busid=%s#usbid=%04x:%04x#\n", udev.busid,
> +			       udev.idVendor, udev.idProduct);
> +		} else {
> +			printf("%11s: %s\n", udev.busid, product_name);
> +			printf("%11s: %s\n", "", udev.path);
> +			printf("%11s: %s\n", "", class_name);
> +		}
>  
>  		for (j = 0; j < udev.bNumInterfaces; j++) {
>  			rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
> @@ -116,16 +123,18 @@ static int get_exported_devices(char *host, int sockfd)
>  					uintf.bInterfaceClass,
>  					uintf.bInterfaceSubClass,
>  					uintf.bInterfaceProtocol);
> -			printf("%11s: %2d - %s\n", "", j, class_name);
> +			if (!parsable)
> +				printf("%11s: %2d - %s\n", "", j, class_name);
>  		}
>  
> -		printf("\n");
> +		if (!parsable)
> +			printf("\n");
>  	}
>  
>  	return 0;
>  }
>  
> -static int list_exported_devices(char *host)
> +static int list_exported_devices(char *host, bool parsable)
>  {
>  	int rc;
>  	int sockfd;
> @@ -138,7 +147,7 @@ static int list_exported_devices(char *host)
>  	}
>  	dbg("connected to %s:%s", host, usbip_port_string);
>  
> -	rc = get_exported_devices(host, sockfd);
> +	rc = get_exported_devices(host, sockfd, parsable);
>  	if (rc < 0) {
>  		err("failed to get device list from %s", host);
>  		return -1;
> @@ -351,7 +360,7 @@ int usbip_list(int argc, char *argv[])
>  			parsable = true;
>  			break;
>  		case 'r':
> -			ret = list_exported_devices(optarg);
> +			ret = list_exported_devices(optarg, parsable);
>  			goto out;
>  		case 'l':
>  			ret = list_devices(parsable);
> -- 
> 2.50.1 (Apple Git-155)
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output
  2026-08-12  6:39 [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Jason Colapietro
  2026-08-12  6:39 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Jason Colapietro
  2026-08-12  7:22 ` [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Greg KH
@ 2026-08-12  7:23 ` Greg KH
  2 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-08-12  7:23 UTC (permalink / raw)
  To: Jason Colapietro
  Cc: Valentina Manea, Shuah Khan, Shuah Khan, Hongren Zheng, linux-usb,
	linux-kernel

On Wed, Aug 12, 2026 at 02:39:09AM -0400, Jason Colapietro wrote:
> The -p option only affects local devices and gadgets. Remote lists still
> print their human-readable headings and details, so scripts cannot parse
> them using the documented option.
> 
> Pass the parsable flag through the remote listing path. Emit the same busid
> and usbid record used for local devices while continuing to consume every
> interface record from the server.
> 
> Fixes: e9837bbb3e69 ("staging: usbip: userspace tools v1.0.0")
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219502
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jason Colapietro <jasoncola1@gmail.com>
> ---
>  tools/usb/usbip/src/usbip_list.c | 33 ++++++++++++++++++++------------
>  1 file changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
> index 3d810bcca..b9d60b87e 100644
> --- a/tools/usb/usbip/src/usbip_list.c
> +++ b/tools/usb/usbip/src/usbip_list.c
> @@ -41,7 +41,7 @@ void usbip_list_usage(void)
>  	printf("usage: %s", usbip_list_usage_string);
>  }
>  
> -static int get_exported_devices(char *host, int sockfd)
> +static int get_exported_devices(char *host, int sockfd, bool parsable)

Why is "parsable" not just a global variable for the program?  Passing
it around like this is odd.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order
  2026-08-12  6:39 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Jason Colapietro
@ 2026-08-12  7:24   ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-08-12  7:24 UTC (permalink / raw)
  To: Jason Colapietro
  Cc: Valentina Manea, Shuah Khan, Shuah Khan, Hongren Zheng, linux-usb,
	linux-kernel

On Wed, Aug 12, 2026 at 02:39:10AM -0400, Jason Colapietro wrote:
> usbip_list() acts on -r, -l and -d as soon as getopt_long() returns them,
> so any option parsed afterwards is never seen. -p therefore only takes
> effect when it precedes the mode selector: "usbip list -p -r <host>" is
> parsable while "usbip list -r <host> -p" is not, and -l and -d behave the
> same way. Nothing in the usage text suggests the order matters.
> 
> Record the requested mode during the option loop and run it once parsing
> has finished, so -p applies wherever it appears on the command line. When
> several mode selectors are given the first one still wins, as before.

This changes how the program works, so this might break existing
systems.

Is this a real problem as-is?  If not, I'd be very careful in changing
anything here...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-12  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12  6:39 [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Jason Colapietro
2026-08-12  6:39 ` [PATCH v3 RESEND 2/2] usbip: apply list options regardless of order Jason Colapietro
2026-08-12  7:24   ` Greg KH
2026-08-12  7:22 ` [PATCH v3 RESEND 1/2] usbip: make remote list honor parsable output Greg KH
2026-08-12  7:23 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.