All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: usbip: add support for viewing imported devices
@ 2013-12-23 18:00 Valentina Manea
  2013-12-23 19:43 ` Ilija Hadzic
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Valentina Manea @ 2013-12-23 18:00 UTC (permalink / raw)
  To: gregkh
  Cc: ly80toro, standby24x7, alan, ihadzic, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover, Valentina Manea

As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)
       unknown vendor : unknown product (1687:6211)
       2-1 -> usbip://192.168.122.152:3240/1-1 (remote devid 00010002 (bus/dev 001/002))

Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
---
 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 59 ++++++++++++++++++++++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am    |  2 +-
 drivers/staging/usbip/userspace/src/usbip.c        |  6 +++
 drivers/staging/usbip/userspace/src/usbip.h        |  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 59 ++++++++++++++++++++++
 6 files changed, 128 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..5abc567 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include "usbip_common.h"
 #include "vhci_driver.h"
+#include <limits.h>
+#include <netdb.h>
 
 #undef  PROGNAME
 #define PROGNAME "libusbip"
@@ -337,6 +339,29 @@ err:
 	return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+	FILE *file;
+	char path[PATH_MAX+1];
+
+	snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
+
+	file = fopen(path, "r");
+	if (!file) {
+		err("fopen");
+		return -1;
+	}
+
+	if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
+		err("fscanf");
+		fclose(file);
+		return -1;
+	}
+
+	fclose(file);
+
+	return 0;
+}
 
 /* ---------------------------------------------------------------------- */
 
@@ -535,3 +560,37 @@ int usbip_vhci_detach_device(uint8_t port)
 
 	return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+	char product_name[100];
+	char host[NI_MAXHOST] = "unknown host";
+	char serv[NI_MAXSERV] = "unknown port";
+	char remote_busid[SYSFS_BUS_ID_SIZE];
+	int ret;
+
+	if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED)
+		return 0;
+
+	ret = read_record(idev->port, host, serv, remote_busid);
+	if (ret) {
+		err("read_record");
+		return -1;
+	}
+
+	printf("Port %02d: <%s> at %s\n", idev->port,
+	       usbip_status_string(idev->status),
+	       usbip_speed_string(idev->udev.speed));
+
+	usbip_names_get_product(product_name, sizeof(product_name),
+				idev->udev.idVendor, idev->udev.idProduct);
+
+	printf("       %s\n",  product_name);
+
+	printf("%10s -> usbip://%s:%s/%s (remote devid %08x (bus/dev %03d/%03d))\n",
+	       idev->udev.busid, host, serv, remote_busid,
+	       idev->devid,
+	       idev->busnum, idev->devnum);
+
+	return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 		 usbip_attach.c usbip_detach.c usbip_list.c \
-		 usbip_bind.c usbip_unbind.c
+		 usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
index 04a5f20..d7599d9 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/drivers/staging/usbip/userspace/src/usbip.c
@@ -93,6 +93,12 @@ static const struct command cmds[] = {
 		.help  = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
 		.usage = usbip_unbind_usage
 	},
+	{
+		.name  = "port",
+		.fn    = usbip_port_show,
+		.help  = "Show imported USB devices",
+		.usage = NULL
+	},
 	{ NULL, NULL, NULL, NULL }
 };
 
diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/drivers/staging/usbip/userspace/src/usbip.h
index 14d4a47..84fe66a 100644
--- a/drivers/staging/usbip/userspace/src/usbip.h
+++ b/drivers/staging/usbip/userspace/src/usbip.h
@@ -29,6 +29,7 @@ int usbip_detach(int argc, char *argv[]);
 int usbip_list(int argc, char *argv[]);
 int usbip_bind(int argc, char *argv[]);
 int usbip_unbind(int argc, char *argv[]);
+int usbip_port_show(int argc, char *argv[]);
 
 void usbip_attach_usage(void);
 void usbip_detach_usage(void);
diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c
new file mode 100644
index 0000000..e07dfe5
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/usbip_port.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
+ *               2005-2007 Takahiro Hirofuchi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "vhci_driver.h"
+#include "usbip_common.h"
+
+static int list_imported_devices()
+{
+	int i;
+	struct usbip_imported_device *idev;
+	int ret;
+
+	ret = usbip_vhci_driver_open();
+	if (ret < 0) {
+		err("open vhci_driver");
+		return -1;
+	}
+
+	printf("Imported USB devices\n");
+	printf("====================\n");
+
+	for (i = 0; i < vhci_driver->nports; i++) {
+		idev = &vhci_driver->idev[i];
+
+		if (usbip_vhci_imported_device_dump(idev) < 0)
+			ret = -1;
+	}
+
+	usbip_vhci_driver_close();
+
+	return ret;
+
+}
+
+int usbip_port_show(int argc, char *argv[])
+{
+	(void) argc;
+	(void) argv;
+
+	int ret;
+
+	ret = list_imported_devices();
+	if (ret < 0)
+		err("list imported devices");
+
+	return ret;
+}
-- 
1.8.1.2


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

* Re: [PATCH] staging: usbip: add support for viewing imported devices
  2013-12-23 18:00 [PATCH] staging: usbip: add support for viewing imported devices Valentina Manea
@ 2013-12-23 19:43 ` Ilija Hadzic
  2014-01-02 10:10   ` Dan Carpenter
  2013-12-23 23:24 ` [PATCH v2] " Valentina Manea
  2013-12-24  8:27 ` [PATCH v3] staging: usbip: userspace: " Valentina Manea
  2 siblings, 1 reply; 7+ messages in thread
From: Ilija Hadzic @ 2013-12-23 19:43 UTC (permalink / raw)
  To: Valentina Manea
  Cc: gregkh, ly80toro, standby24x7, alan, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover



On Mon, 23 Dec 2013, Valentina Manea wrote:

> As of Matt Mooney's major refactoring in 2011, usbip port
> option was left out. Add support for this option in
> a manner similar to the old implementation.
>

Yeah, I guess most people (incluing myself) have been just happy with
just cat-ing the files in /var/run/vhci_hcd. Anyway, I guess it doesn't 
hurt to have it in the tool.

> Sample output:
>
> Imported USB devices
> ====================
> Port 00: <Port in Use> at Full Speed(12Mbps)
>       unknown vendor : unknown product (1687:6211)
>       2-1 -> usbip://192.168.122.152:3240/1-1 (remote devid 00010002 (bus/dev 001/002))
>

I don't find devid very useful when you are already printing bus and 
device number; devid is just a different format for the same thing. Just 
bus number and device number should suffice.

>
> [SNIP]
>
>
> +int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
> +{
>
> [SNIP]
>
> +
> +	ret = read_record(idev->port, host, serv, remote_busid);
> +	if (ret) {
> +		err("read_record");
> +		return -1;
> +	}
> +

If the caller is looping over the ports and dumping one port fails because 
some bozo has rm-ed the record file, is it the right thing to bail out of 
completely? You may want to consider continuing with the loop and still 
show what can be shown (and mark unshowable ports as such).

In that sense, you probably don't want to return an error here.

>
> +	printf("Port %02d: <%s> at %s\n", idev->port,
> +	       usbip_status_string(idev->status),
> +	       usbip_speed_string(idev->udev.speed));
>
> [SNIP]
>
> +int usbip_port_show(int argc, char *argv[])
> +{
> +	(void) argc;
> +	(void) argv;
> +

This is an ugly way to suppress the warning. Consider using 
__attribute__((unused)) instead.


-- Ilija


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

* [PATCH v2] staging: usbip: add support for viewing imported devices
  2013-12-23 18:00 [PATCH] staging: usbip: add support for viewing imported devices Valentina Manea
  2013-12-23 19:43 ` Ilija Hadzic
@ 2013-12-23 23:24 ` Valentina Manea
  2013-12-24  3:23   ` Ilija Hadzic
  2013-12-24  8:27 ` [PATCH v3] staging: usbip: userspace: " Valentina Manea
  2 siblings, 1 reply; 7+ messages in thread
From: Valentina Manea @ 2013-12-23 23:24 UTC (permalink / raw)
  To: gregkh
  Cc: ly80toro, standby24x7, alan, ihadzic, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover, Valentina Manea

As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)
       unknown vendor : unknown product (1687:6211)
       2-1 -> usbip://192.168.122.152:3240/1-1
           -> remote bus/dev 001/002

Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
---
Changes since v1:
	* remove devid from the printed info
	* arrange formatting a bit
	* don't bail out when port file doesn't exist, just print whatever info is available
	* replace void cast with __attribute__((unused)) 

 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++++++++++++++++++++++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am    |  2 +-
 drivers/staging/usbip/userspace/src/usbip.c        |  6 ++
 drivers/staging/usbip/userspace/src/usbip.h        |  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++++++++++++++++++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..65ea5cf 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include "usbip_common.h"
 #include "vhci_driver.h"
+#include <limits.h>
+#include <netdb.h>
 
 #undef  PROGNAME
 #define PROGNAME "libusbip"
@@ -337,6 +339,29 @@ err:
 	return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+	FILE *file;
+	char path[PATH_MAX+1];
+
+	snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
+
+	file = fopen(path, "r");
+	if (!file) {
+		err("fopen");
+		return -1;
+	}
+
+	if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
+		err("fscanf");
+		fclose(file);
+		return -1;
+	}
+
+	fclose(file);
+
+	return 0;
+}
 
 /* ---------------------------------------------------------------------- */
 
@@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
 
 	return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+	char product_name[100];
+	char host[NI_MAXHOST] = "unknown host";
+	char serv[NI_MAXSERV] = "unknown port";
+	char remote_busid[SYSFS_BUS_ID_SIZE];
+	int ret;
+	int read_record_error = 0;
+
+	if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED)
+		return 0;
+
+	ret = read_record(idev->port, host, serv, remote_busid);
+	if (ret) {
+		err("read_record");
+		read_record_error = 1;
+	}
+
+	printf("Port %02d: <%s> at %s\n", idev->port,
+	       usbip_status_string(idev->status),
+	       usbip_speed_string(idev->udev.speed));
+
+	usbip_names_get_product(product_name, sizeof(product_name),
+				idev->udev.idVendor, idev->udev.idProduct);
+
+	printf("       %s\n",  product_name);
+
+	if (!read_record_error) {
+		printf("%10s -> usbip://%s:%s/%s\n", idev->udev.busid,
+		       host, serv, remote_busid);
+		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
+		       idev->busnum, idev->devnum);
+	} else {
+		printf("%10s -> unknown host, remote port and remote busid\n",
+		       idev->udev.busid); 
+		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
+		       idev->busnum, idev->devnum);
+	}
+
+	return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 		 usbip_attach.c usbip_detach.c usbip_list.c \
-		 usbip_bind.c usbip_unbind.c
+		 usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
index 04a5f20..d7599d9 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/drivers/staging/usbip/userspace/src/usbip.c
@@ -93,6 +93,12 @@ static const struct command cmds[] = {
 		.help  = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
 		.usage = usbip_unbind_usage
 	},
+	{
+		.name  = "port",
+		.fn    = usbip_port_show,
+		.help  = "Show imported USB devices",
+		.usage = NULL
+	},
 	{ NULL, NULL, NULL, NULL }
 };
 
diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/drivers/staging/usbip/userspace/src/usbip.h
index 14d4a47..84fe66a 100644
--- a/drivers/staging/usbip/userspace/src/usbip.h
+++ b/drivers/staging/usbip/userspace/src/usbip.h
@@ -29,6 +29,7 @@ int usbip_detach(int argc, char *argv[]);
 int usbip_list(int argc, char *argv[]);
 int usbip_bind(int argc, char *argv[]);
 int usbip_unbind(int argc, char *argv[]);
+int usbip_port_show(int argc, char *argv[]);
 
 void usbip_attach_usage(void);
 void usbip_detach_usage(void);
diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c
new file mode 100644
index 0000000..52aa168
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/usbip_port.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
+ *               2005-2007 Takahiro Hirofuchi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "vhci_driver.h"
+#include "usbip_common.h"
+
+static int list_imported_devices()
+{
+	int i;
+	struct usbip_imported_device *idev;
+	int ret;
+
+	ret = usbip_vhci_driver_open();
+	if (ret < 0) {
+		err("open vhci_driver");
+		return -1;
+	}
+
+	printf("Imported USB devices\n");
+	printf("====================\n");
+
+	for (i = 0; i < vhci_driver->nports; i++) {
+		idev = &vhci_driver->idev[i];
+
+		if (usbip_vhci_imported_device_dump(idev) < 0)
+			ret = -1;
+	}
+
+	usbip_vhci_driver_close();
+
+	return ret;
+
+}
+
+int usbip_port_show(__attribute__((unused)) int argc,
+		    __attribute__((unused)) char *argv[])
+{
+	int ret;
+
+	ret = list_imported_devices();
+	if (ret < 0)
+		err("list imported devices");
+
+	return ret;
+}
-- 
1.8.1.2


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

* Re: [PATCH v2] staging: usbip: add support for viewing imported devices
  2013-12-23 23:24 ` [PATCH v2] " Valentina Manea
@ 2013-12-24  3:23   ` Ilija Hadzic
  0 siblings, 0 replies; 7+ messages in thread
From: Ilija Hadzic @ 2013-12-24  3:23 UTC (permalink / raw)
  To: Valentina Manea
  Cc: gregkh, ly80toro, standby24x7, alan, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover


This looks better, but there are still two minor issues:

You have one trailing whtespace error. Please the scripts/checkpatch.pl 
script on the patch and correct the error.

The title of the commit message should indicate that this is an userspace 
patch (this seems to be the convention that other patches have adhered 
to). So:

'staging: usbip: userspace: <blah blah>'

not

'staging: usbip: <blah blah>;

-- Ilija


On Tue, 24 Dec 2013, Valentina Manea wrote:

> As of Matt Mooney's major refactoring in 2011, usbip port
> option was left out. Add support for this option in
> a manner similar to the old implementation.
>
> Sample output:
>
> Imported USB devices
> ====================
> Port 00: <Port in Use> at Full Speed(12Mbps)
>       unknown vendor : unknown product (1687:6211)
>       2-1 -> usbip://192.168.122.152:3240/1-1
>           -> remote bus/dev 001/002
>
> Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
> ---
> Changes since v1:
> 	* remove devid from the printed info
> 	* arrange formatting a bit
> 	* don't bail out when port file doesn't exist, just print whatever info is available
> 	* replace void cast with __attribute__((unused))
>
> .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++++++++++++++++++++++
> .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
> drivers/staging/usbip/userspace/src/Makefile.am    |  2 +-
> drivers/staging/usbip/userspace/src/usbip.c        |  6 ++
> drivers/staging/usbip/userspace/src/usbip.h        |  1 +
> drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++++++++++++++++++
> 6 files changed, 134 insertions(+), 1 deletion(-)
> create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c
>
> diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> index 241006a..65ea5cf 100644
> --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> @@ -4,6 +4,8 @@
>
> #include "usbip_common.h"
> #include "vhci_driver.h"
> +#include <limits.h>
> +#include <netdb.h>
>
> #undef  PROGNAME
> #define PROGNAME "libusbip"
> @@ -337,6 +339,29 @@ err:
> 	return -1;
> }
>
> +static int read_record(int rhport, char *host, char *port, char *busid)
> +{
> +	FILE *file;
> +	char path[PATH_MAX+1];
> +
> +	snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
> +
> +	file = fopen(path, "r");
> +	if (!file) {
> +		err("fopen");
> +		return -1;
> +	}
> +
> +	if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
> +		err("fscanf");
> +		fclose(file);
> +		return -1;
> +	}
> +
> +	fclose(file);
> +
> +	return 0;
> +}
>
> /* ---------------------------------------------------------------------- */
>
> @@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
>
> 	return 0;
> }
> +
> +int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
> +{
> +	char product_name[100];
> +	char host[NI_MAXHOST] = "unknown host";
> +	char serv[NI_MAXSERV] = "unknown port";
> +	char remote_busid[SYSFS_BUS_ID_SIZE];
> +	int ret;
> +	int read_record_error = 0;
> +
> +	if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED)
> +		return 0;
> +
> +	ret = read_record(idev->port, host, serv, remote_busid);
> +	if (ret) {
> +		err("read_record");
> +		read_record_error = 1;
> +	}
> +
> +	printf("Port %02d: <%s> at %s\n", idev->port,
> +	       usbip_status_string(idev->status),
> +	       usbip_speed_string(idev->udev.speed));
> +
> +	usbip_names_get_product(product_name, sizeof(product_name),
> +				idev->udev.idVendor, idev->udev.idProduct);
> +
> +	printf("       %s\n",  product_name);
> +
> +	if (!read_record_error) {
> +		printf("%10s -> usbip://%s:%s/%s\n", idev->udev.busid,
> +		       host, serv, remote_busid);
> +		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
> +		       idev->busnum, idev->devnum);
> +	} else {
> +		printf("%10s -> unknown host, remote port and remote busid\n",
> +		       idev->udev.busid);
> +		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
> +		       idev->busnum, idev->devnum);
> +	}
> +
> +	return 0;
> +}
> diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> index 89949aa..e071f80 100644
> --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> @@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
>
> int usbip_vhci_detach_device(uint8_t port);
>
> +int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
> +
> #endif /* __VHCI_DRIVER_H */
> diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
> index a113003..b4f8c4b 100644
> --- a/drivers/staging/usbip/userspace/src/Makefile.am
> +++ b/drivers/staging/usbip/userspace/src/Makefile.am
> @@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
>
> usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
> 		 usbip_attach.c usbip_detach.c usbip_list.c \
> -		 usbip_bind.c usbip_unbind.c
> +		 usbip_bind.c usbip_unbind.c usbip_port.c
>
>
> usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
> diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
> index 04a5f20..d7599d9 100644
> --- a/drivers/staging/usbip/userspace/src/usbip.c
> +++ b/drivers/staging/usbip/userspace/src/usbip.c
> @@ -93,6 +93,12 @@ static const struct command cmds[] = {
> 		.help  = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
> 		.usage = usbip_unbind_usage
> 	},
> +	{
> +		.name  = "port",
> +		.fn    = usbip_port_show,
> +		.help  = "Show imported USB devices",
> +		.usage = NULL
> +	},
> 	{ NULL, NULL, NULL, NULL }
> };
>
> diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/drivers/staging/usbip/userspace/src/usbip.h
> index 14d4a47..84fe66a 100644
> --- a/drivers/staging/usbip/userspace/src/usbip.h
> +++ b/drivers/staging/usbip/userspace/src/usbip.h
> @@ -29,6 +29,7 @@ int usbip_detach(int argc, char *argv[]);
> int usbip_list(int argc, char *argv[]);
> int usbip_bind(int argc, char *argv[]);
> int usbip_unbind(int argc, char *argv[]);
> +int usbip_port_show(int argc, char *argv[]);
>
> void usbip_attach_usage(void);
> void usbip_detach_usage(void);
> diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c
> new file mode 100644
> index 0000000..52aa168
> --- /dev/null
> +++ b/drivers/staging/usbip/userspace/src/usbip_port.c
> @@ -0,0 +1,57 @@
> +/*
> + * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
> + *               2005-2007 Takahiro Hirofuchi
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include "vhci_driver.h"
> +#include "usbip_common.h"
> +
> +static int list_imported_devices()
> +{
> +	int i;
> +	struct usbip_imported_device *idev;
> +	int ret;
> +
> +	ret = usbip_vhci_driver_open();
> +	if (ret < 0) {
> +		err("open vhci_driver");
> +		return -1;
> +	}
> +
> +	printf("Imported USB devices\n");
> +	printf("====================\n");
> +
> +	for (i = 0; i < vhci_driver->nports; i++) {
> +		idev = &vhci_driver->idev[i];
> +
> +		if (usbip_vhci_imported_device_dump(idev) < 0)
> +			ret = -1;
> +	}
> +
> +	usbip_vhci_driver_close();
> +
> +	return ret;
> +
> +}
> +
> +int usbip_port_show(__attribute__((unused)) int argc,
> +		    __attribute__((unused)) char *argv[])
> +{
> +	int ret;
> +
> +	ret = list_imported_devices();
> +	if (ret < 0)
> +		err("list imported devices");
> +
> +	return ret;
> +}
> -- 
> 1.8.1.2
>
>

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

* [PATCH v3] staging: usbip: userspace: add support for viewing imported devices
  2013-12-23 18:00 [PATCH] staging: usbip: add support for viewing imported devices Valentina Manea
  2013-12-23 19:43 ` Ilija Hadzic
  2013-12-23 23:24 ` [PATCH v2] " Valentina Manea
@ 2013-12-24  8:27 ` Valentina Manea
  2013-12-24 13:28   ` Ilija Hadzic
  2 siblings, 1 reply; 7+ messages in thread
From: Valentina Manea @ 2013-12-24  8:27 UTC (permalink / raw)
  To: gregkh
  Cc: ly80toro, standby24x7, alan, ihadzic, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover, Valentina Manea

As of Matt Mooney's major refactoring in 2011, usbip port
option was left out. Add support for this option in
a manner similar to the old implementation.

Sample output:

Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)
       unknown vendor : unknown product (1687:6211)
       2-1 -> usbip://192.168.122.152:3240/1-1
           -> remote bus/dev 001/002

Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
---
Changes since v2:
	* fix trailing whitespace error
	* change commit title to reflect that this is a userspace patch

 .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++++++++++++++++++++++
 .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
 drivers/staging/usbip/userspace/src/Makefile.am    |  2 +-
 drivers/staging/usbip/userspace/src/usbip.c        |  6 ++
 drivers/staging/usbip/userspace/src/usbip.h        |  1 +
 drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++++++++++++++++++
 6 files changed, 134 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c

diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 241006a..209df9b 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -4,6 +4,8 @@
 
 #include "usbip_common.h"
 #include "vhci_driver.h"
+#include <limits.h>
+#include <netdb.h>
 
 #undef  PROGNAME
 #define PROGNAME "libusbip"
@@ -337,6 +339,29 @@ err:
 	return -1;
 }
 
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+	FILE *file;
+	char path[PATH_MAX+1];
+
+	snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
+
+	file = fopen(path, "r");
+	if (!file) {
+		err("fopen");
+		return -1;
+	}
+
+	if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
+		err("fscanf");
+		fclose(file);
+		return -1;
+	}
+
+	fclose(file);
+
+	return 0;
+}
 
 /* ---------------------------------------------------------------------- */
 
@@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
 
 	return 0;
 }
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+	char product_name[100];
+	char host[NI_MAXHOST] = "unknown host";
+	char serv[NI_MAXSERV] = "unknown port";
+	char remote_busid[SYSFS_BUS_ID_SIZE];
+	int ret;
+	int read_record_error = 0;
+
+	if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED)
+		return 0;
+
+	ret = read_record(idev->port, host, serv, remote_busid);
+	if (ret) {
+		err("read_record");
+		read_record_error = 1;
+	}
+
+	printf("Port %02d: <%s> at %s\n", idev->port,
+	       usbip_status_string(idev->status),
+	       usbip_speed_string(idev->udev.speed));
+
+	usbip_names_get_product(product_name, sizeof(product_name),
+				idev->udev.idVendor, idev->udev.idProduct);
+
+	printf("       %s\n",  product_name);
+
+	if (!read_record_error) {
+		printf("%10s -> usbip://%s:%s/%s\n", idev->udev.busid,
+		       host, serv, remote_busid);
+		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
+		       idev->busnum, idev->devnum);
+	} else {
+		printf("%10s -> unknown host, remote port and remote busid\n",
+		       idev->udev.busid);
+		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
+		       idev->busnum, idev->devnum);
+	}
+
+	return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
index 89949aa..e071f80 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
@@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
+
 #endif /* __VHCI_DRIVER_H */
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
index a113003..b4f8c4b 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
 
 usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
 		 usbip_attach.c usbip_detach.c usbip_list.c \
-		 usbip_bind.c usbip_unbind.c
+		 usbip_bind.c usbip_unbind.c usbip_port.c
 
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
index 04a5f20..d7599d9 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/drivers/staging/usbip/userspace/src/usbip.c
@@ -93,6 +93,12 @@ static const struct command cmds[] = {
 		.help  = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
 		.usage = usbip_unbind_usage
 	},
+	{
+		.name  = "port",
+		.fn    = usbip_port_show,
+		.help  = "Show imported USB devices",
+		.usage = NULL
+	},
 	{ NULL, NULL, NULL, NULL }
 };
 
diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/drivers/staging/usbip/userspace/src/usbip.h
index 14d4a47..84fe66a 100644
--- a/drivers/staging/usbip/userspace/src/usbip.h
+++ b/drivers/staging/usbip/userspace/src/usbip.h
@@ -29,6 +29,7 @@ int usbip_detach(int argc, char *argv[]);
 int usbip_list(int argc, char *argv[]);
 int usbip_bind(int argc, char *argv[]);
 int usbip_unbind(int argc, char *argv[]);
+int usbip_port_show(int argc, char *argv[]);
 
 void usbip_attach_usage(void);
 void usbip_detach_usage(void);
diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c
new file mode 100644
index 0000000..52aa168
--- /dev/null
+++ b/drivers/staging/usbip/userspace/src/usbip_port.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
+ *               2005-2007 Takahiro Hirofuchi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "vhci_driver.h"
+#include "usbip_common.h"
+
+static int list_imported_devices()
+{
+	int i;
+	struct usbip_imported_device *idev;
+	int ret;
+
+	ret = usbip_vhci_driver_open();
+	if (ret < 0) {
+		err("open vhci_driver");
+		return -1;
+	}
+
+	printf("Imported USB devices\n");
+	printf("====================\n");
+
+	for (i = 0; i < vhci_driver->nports; i++) {
+		idev = &vhci_driver->idev[i];
+
+		if (usbip_vhci_imported_device_dump(idev) < 0)
+			ret = -1;
+	}
+
+	usbip_vhci_driver_close();
+
+	return ret;
+
+}
+
+int usbip_port_show(__attribute__((unused)) int argc,
+		    __attribute__((unused)) char *argv[])
+{
+	int ret;
+
+	ret = list_imported_devices();
+	if (ret < 0)
+		err("list imported devices");
+
+	return ret;
+}
-- 
1.8.1.2


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

* Re: [PATCH v3] staging: usbip: userspace: add support for viewing imported devices
  2013-12-24  8:27 ` [PATCH v3] staging: usbip: userspace: " Valentina Manea
@ 2013-12-24 13:28   ` Ilija Hadzic
  0 siblings, 0 replies; 7+ messages in thread
From: Ilija Hadzic @ 2013-12-24 13:28 UTC (permalink / raw)
  To: Valentina Manea
  Cc: gregkh, ly80toro, standby24x7, alan, anthony.foiani,
	linux-kernel, linux-usb, devel, andy.grover



Reviewed-by: Ilija Hadzic <ihadzic@research.bell-labs.com>


On Tue, 24 Dec 2013, Valentina Manea wrote:

> As of Matt Mooney's major refactoring in 2011, usbip port
> option was left out. Add support for this option in
> a manner similar to the old implementation.
>
> Sample output:
>
> Imported USB devices
> ====================
> Port 00: <Port in Use> at Full Speed(12Mbps)
>       unknown vendor : unknown product (1687:6211)
>       2-1 -> usbip://192.168.122.152:3240/1-1
>           -> remote bus/dev 001/002
>
> Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
> ---
> Changes since v2:
> 	* fix trailing whitespace error
> 	* change commit title to reflect that this is a userspace patch
>
> .../staging/usbip/userspace/libsrc/vhci_driver.c   | 67 ++++++++++++++++++++++
> .../staging/usbip/userspace/libsrc/vhci_driver.h   |  2 +
> drivers/staging/usbip/userspace/src/Makefile.am    |  2 +-
> drivers/staging/usbip/userspace/src/usbip.c        |  6 ++
> drivers/staging/usbip/userspace/src/usbip.h        |  1 +
> drivers/staging/usbip/userspace/src/usbip_port.c   | 57 ++++++++++++++++++
> 6 files changed, 134 insertions(+), 1 deletion(-)
> create mode 100644 drivers/staging/usbip/userspace/src/usbip_port.c
>
> diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> index 241006a..209df9b 100644
> --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
> @@ -4,6 +4,8 @@
>
> #include "usbip_common.h"
> #include "vhci_driver.h"
> +#include <limits.h>
> +#include <netdb.h>
>
> #undef  PROGNAME
> #define PROGNAME "libusbip"
> @@ -337,6 +339,29 @@ err:
> 	return -1;
> }
>
> +static int read_record(int rhport, char *host, char *port, char *busid)
> +{
> +	FILE *file;
> +	char path[PATH_MAX+1];
> +
> +	snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
> +
> +	file = fopen(path, "r");
> +	if (!file) {
> +		err("fopen");
> +		return -1;
> +	}
> +
> +	if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
> +		err("fscanf");
> +		fclose(file);
> +		return -1;
> +	}
> +
> +	fclose(file);
> +
> +	return 0;
> +}
>
> /* ---------------------------------------------------------------------- */
>
> @@ -535,3 +560,45 @@ int usbip_vhci_detach_device(uint8_t port)
>
> 	return 0;
> }
> +
> +int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
> +{
> +	char product_name[100];
> +	char host[NI_MAXHOST] = "unknown host";
> +	char serv[NI_MAXSERV] = "unknown port";
> +	char remote_busid[SYSFS_BUS_ID_SIZE];
> +	int ret;
> +	int read_record_error = 0;
> +
> +	if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED)
> +		return 0;
> +
> +	ret = read_record(idev->port, host, serv, remote_busid);
> +	if (ret) {
> +		err("read_record");
> +		read_record_error = 1;
> +	}
> +
> +	printf("Port %02d: <%s> at %s\n", idev->port,
> +	       usbip_status_string(idev->status),
> +	       usbip_speed_string(idev->udev.speed));
> +
> +	usbip_names_get_product(product_name, sizeof(product_name),
> +				idev->udev.idVendor, idev->udev.idProduct);
> +
> +	printf("       %s\n",  product_name);
> +
> +	if (!read_record_error) {
> +		printf("%10s -> usbip://%s:%s/%s\n", idev->udev.busid,
> +		       host, serv, remote_busid);
> +		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
> +		       idev->busnum, idev->devnum);
> +	} else {
> +		printf("%10s -> unknown host, remote port and remote busid\n",
> +		       idev->udev.busid);
> +		printf("%10s -> remote bus/dev %03d/%03d\n", " ",
> +		       idev->busnum, idev->devnum);
> +	}
> +
> +	return 0;
> +}
> diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> index 89949aa..e071f80 100644
> --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
> @@ -64,4 +64,6 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
>
> int usbip_vhci_detach_device(uint8_t port);
>
> +int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
> +
> #endif /* __VHCI_DRIVER_H */
> diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
> index a113003..b4f8c4b 100644
> --- a/drivers/staging/usbip/userspace/src/Makefile.am
> +++ b/drivers/staging/usbip/userspace/src/Makefile.am
> @@ -6,7 +6,7 @@ sbin_PROGRAMS := usbip usbipd
>
> usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
> 		 usbip_attach.c usbip_detach.c usbip_list.c \
> -		 usbip_bind.c usbip_unbind.c
> +		 usbip_bind.c usbip_unbind.c usbip_port.c
>
>
> usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
> diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
> index 04a5f20..d7599d9 100644
> --- a/drivers/staging/usbip/userspace/src/usbip.c
> +++ b/drivers/staging/usbip/userspace/src/usbip.c
> @@ -93,6 +93,12 @@ static const struct command cmds[] = {
> 		.help  = "Unbind device from " USBIP_HOST_DRV_NAME ".ko",
> 		.usage = usbip_unbind_usage
> 	},
> +	{
> +		.name  = "port",
> +		.fn    = usbip_port_show,
> +		.help  = "Show imported USB devices",
> +		.usage = NULL
> +	},
> 	{ NULL, NULL, NULL, NULL }
> };
>
> diff --git a/drivers/staging/usbip/userspace/src/usbip.h b/drivers/staging/usbip/userspace/src/usbip.h
> index 14d4a47..84fe66a 100644
> --- a/drivers/staging/usbip/userspace/src/usbip.h
> +++ b/drivers/staging/usbip/userspace/src/usbip.h
> @@ -29,6 +29,7 @@ int usbip_detach(int argc, char *argv[]);
> int usbip_list(int argc, char *argv[]);
> int usbip_bind(int argc, char *argv[]);
> int usbip_unbind(int argc, char *argv[]);
> +int usbip_port_show(int argc, char *argv[]);
>
> void usbip_attach_usage(void);
> void usbip_detach_usage(void);
> diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c
> new file mode 100644
> index 0000000..52aa168
> --- /dev/null
> +++ b/drivers/staging/usbip/userspace/src/usbip_port.c
> @@ -0,0 +1,57 @@
> +/*
> + * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
> + *               2005-2007 Takahiro Hirofuchi
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include "vhci_driver.h"
> +#include "usbip_common.h"
> +
> +static int list_imported_devices()
> +{
> +	int i;
> +	struct usbip_imported_device *idev;
> +	int ret;
> +
> +	ret = usbip_vhci_driver_open();
> +	if (ret < 0) {
> +		err("open vhci_driver");
> +		return -1;
> +	}
> +
> +	printf("Imported USB devices\n");
> +	printf("====================\n");
> +
> +	for (i = 0; i < vhci_driver->nports; i++) {
> +		idev = &vhci_driver->idev[i];
> +
> +		if (usbip_vhci_imported_device_dump(idev) < 0)
> +			ret = -1;
> +	}
> +
> +	usbip_vhci_driver_close();
> +
> +	return ret;
> +
> +}
> +
> +int usbip_port_show(__attribute__((unused)) int argc,
> +		    __attribute__((unused)) char *argv[])
> +{
> +	int ret;
> +
> +	ret = list_imported_devices();
> +	if (ret < 0)
> +		err("list imported devices");
> +
> +	return ret;
> +}
> -- 
> 1.8.1.2
>
>

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

* Re: [PATCH] staging: usbip: add support for viewing imported devices
  2013-12-23 19:43 ` Ilija Hadzic
@ 2014-01-02 10:10   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2014-01-02 10:10 UTC (permalink / raw)
  To: Ilija Hadzic
  Cc: Valentina Manea, anthony.foiani, devel, gregkh, linux-usb,
	ly80toro, linux-kernel, andy.grover, alan


-Werror=unused-parameter is stupid.  Better to turn it off instead of
ugly work arounds.

regards,
dan carpenter


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

end of thread, other threads:[~2014-01-02 10:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-23 18:00 [PATCH] staging: usbip: add support for viewing imported devices Valentina Manea
2013-12-23 19:43 ` Ilija Hadzic
2014-01-02 10:10   ` Dan Carpenter
2013-12-23 23:24 ` [PATCH v2] " Valentina Manea
2013-12-24  3:23   ` Ilija Hadzic
2013-12-24  8:27 ` [PATCH v3] staging: usbip: userspace: " Valentina Manea
2013-12-24 13:28   ` Ilija Hadzic

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.