* [PATCH 0/7] staging: usbip: rebased userspace patches
@ 2011-07-07 7:31 matt mooney
2011-07-07 7:31 ` [PATCH 1/7] staging: usbip: userspace: usbipd: major cleanup of daemon matt mooney
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Hi greg,
Here are the patches that didn't apply rebased onto your staging-next
branch. There were only three, but I have included a few other small
patches.
Thanks,
matt
matt mooney (7):
staging: usbip: userspace: usbipd: major cleanup of daemon
staging: usbip: userspace: add new prefix for usbip network code
staging: usbip: userspace: fix header installation bug
staging: usbip: userspace: usbip_list.c: modify exportable device
output
staging: usbip: userspace: usbip: modify `list' help message
staging: usbip: userspace: README: update example output
staging: usbip: userspace: usbip-utils 1.1.1
drivers/staging/usbip/userspace/Makefile.am | 2 +-
drivers/staging/usbip/userspace/README | 53 +-
drivers/staging/usbip/userspace/configure.ac | 4 +-
drivers/staging/usbip/userspace/libsrc/Makefile.am | 6 +-
drivers/staging/usbip/userspace/src/Makefile.am | 6 +-
drivers/staging/usbip/userspace/src/usbip.c | 2 +-
drivers/staging/usbip/userspace/src/usbip_attach.c | 10 +-
drivers/staging/usbip/userspace/src/usbip_list.c | 36 +-
.../staging/usbip/userspace/src/usbip_network.c | 56 +-
.../staging/usbip/userspace/src/usbip_network.h | 39 +-
drivers/staging/usbip/userspace/src/usbipd.c | 695 ++++++++++----------
11 files changed, 456 insertions(+), 453 deletions(-)
--
1.7.6
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/7] staging: usbip: userspace: usbipd: major cleanup of daemon
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 2/7] staging: usbip: userspace: add new prefix for usbip network code matt mooney
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Reorganize, rename [for clarity and to remove stub_driver
references], modify output messages, and cleanup coding style;
nevertheless, the actual implementation is pretty much untouched.
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/src/usbipd.c | 691 +++++++++++++-------------
1 files changed, 344 insertions(+), 347 deletions(-)
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
index ef92f3b..aa92623 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -1,6 +1,19 @@
/*
+ * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
+ * 2005-2007 Takahiro Hirofuchi
*
- * Copyright (C) 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
@@ -31,62 +44,153 @@
#include "usbip_common.h"
#include "usbip_network.h"
-static const char version[] = PACKAGE_STRING;
+#undef PROGNAME
+#define PROGNAME "usbipd"
+#define MAXSOCKFD 20
+
+GMainLoop *main_loop;
-static int send_reply_devlist(int sockfd)
+static const char usbip_version_string[] = PACKAGE_STRING;
+
+static const char usbipd_help_string[] =
+ "usage: usbipd [options] \n"
+ " -D, --daemon \n"
+ " Run as a daemon process. \n"
+ " \n"
+ " -d, --debug \n"
+ " Print debugging information. \n"
+ " \n"
+ " -h, --help \n"
+ " Print this help. \n"
+ " \n"
+ " -v, --version \n"
+ " Show version. \n";
+
+static void usbipd_help(void)
{
- int ret;
+ printf("%s\n", usbipd_help_string);
+}
+
+static int recv_request_import(int sockfd)
+{
+ struct op_import_request req;
+ struct op_common reply;
struct usbip_exported_device *edev;
- struct op_devlist_reply reply;
+ struct usbip_usb_device pdu_udev;
+ int found = 0;
+ int error = 0;
+ int rc;
+ memset(&req, 0, sizeof(req));
+ memset(&reply, 0, sizeof(reply));
- reply.ndev = 0;
+ rc = usbip_recv(sockfd, &req, sizeof(req));
+ if (rc < 0) {
+ dbg("usbip_recv failed: import request");
+ return -1;
+ }
+ PACK_OP_IMPORT_REQUEST(0, &req);
- /* how many devices are exported ? */
- dlist_for_each_data(host_driver->edev_list, edev, struct usbip_exported_device) {
- reply.ndev += 1;
+ dlist_for_each_data(host_driver->edev_list, edev,
+ struct usbip_exported_device) {
+ if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) {
+ info("found requested device: %s", req.busid);
+ found = 1;
+ break;
+ }
}
- dbg("%d devices are exported", reply.ndev);
+ if (found) {
+ /* should set TCP_NODELAY for usbip */
+ usbip_set_nodelay(sockfd);
- ret = usbip_send_op_common(sockfd, OP_REP_DEVLIST, ST_OK);
- if (ret < 0) {
- err("send op_common");
- return ret;
+ /* export device needs a TCP/IP socket descriptor */
+ rc = usbip_host_export_device(edev, sockfd);
+ if (rc < 0)
+ error = 1;
+ } else {
+ info("requested device not found: %s", req.busid);
+ error = 1;
}
- PACK_OP_DEVLIST_REPLY(1, &reply);
- ret = usbip_send(sockfd, (void *) &reply, sizeof(reply));
- if (ret < 0) {
- err("send op_devlist_reply");
- return ret;
+ rc = usbip_send_op_common(sockfd, OP_REP_IMPORT,
+ (!error ? ST_OK : ST_NA));
+ if (rc < 0) {
+ dbg("usbip_send_op_common failed: %#0x", OP_REP_IMPORT);
+ return -1;
+ }
+
+ if (error) {
+ dbg("import request busid %s: failed", req.busid);
+ return -1;
+ }
+
+ memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
+ pack_usb_device(1, &pdu_udev);
+
+ rc = usbip_send(sockfd, &pdu_udev, sizeof(pdu_udev));
+ if (rc < 0) {
+ dbg("usbip_send failed: devinfo");
+ return -1;
}
- dlist_for_each_data(host_driver->edev_list, edev, struct usbip_exported_device) {
- struct usbip_usb_device pdu_udev;
+ dbg("import request busid %s: complete", req.busid);
+
+ return 0;
+}
+static int send_reply_devlist(int connfd)
+{
+ struct usbip_exported_device *edev;
+ struct usbip_usb_device pdu_udev;
+ struct usbip_usb_interface pdu_uinf;
+ struct op_devlist_reply reply;
+ int i;
+ int rc;
+
+ reply.ndev = 0;
+ /* number of exported devices */
+ dlist_for_each_data(host_driver->edev_list, edev,
+ struct usbip_exported_device) {
+ reply.ndev += 1;
+ }
+ info("exportable devices: %d", reply.ndev);
+
+ rc = usbip_send_op_common(connfd, OP_REP_DEVLIST, ST_OK);
+ if (rc < 0) {
+ dbg("usbip_send_op_common failed: %#0x", OP_REP_DEVLIST);
+ return -1;
+ }
+ PACK_OP_DEVLIST_REPLY(1, &reply);
+
+ rc = usbip_send(connfd, &reply, sizeof(reply));
+ if (rc < 0) {
+ dbg("usbip_send failed: %#0x", OP_REP_DEVLIST);
+ return -1;
+ }
+
+ dlist_for_each_data(host_driver->edev_list, edev,
+ struct usbip_exported_device) {
dump_usb_device(&edev->udev);
memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
pack_usb_device(1, &pdu_udev);
- ret = usbip_send(sockfd, (void *) &pdu_udev, sizeof(pdu_udev));
- if (ret < 0) {
- err("send pdu_udev");
- return ret;
+ rc = usbip_send(connfd, &pdu_udev, sizeof(pdu_udev));
+ if (rc < 0) {
+ dbg("usbip_send failed: pdu_udev");
+ return -1;
}
- for (int i=0; i < edev->udev.bNumInterfaces; i++) {
- struct usbip_usb_interface pdu_uinf;
-
+ for (i = 0; i < edev->udev.bNumInterfaces; i++) {
dump_usb_interface(&edev->uinf[i]);
memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
pack_usb_interface(1, &pdu_uinf);
- ret = usbip_send(sockfd, (void *) &pdu_uinf, sizeof(pdu_uinf));
- if (ret < 0) {
- err("send pdu_uinf");
- return ret;
+ rc = usbip_send(connfd, &pdu_uinf, sizeof(pdu_uinf));
+ if (rc < 0) {
+ dbg("usbip_send failed: pdu_uinf");
+ return -1;
}
}
}
@@ -94,283 +198,227 @@ static int send_reply_devlist(int sockfd)
return 0;
}
-
-static int recv_request_devlist(int sockfd)
+static int recv_request_devlist(int connfd)
{
- int ret;
struct op_devlist_request req;
+ int rc;
memset(&req, 0, sizeof(req));
- ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
- if (ret < 0) {
- err("recv devlist request");
+ rc = usbip_recv(connfd, &req, sizeof(req));
+ if (rc < 0) {
+ dbg("usbip_recv failed: devlist request");
return -1;
}
- ret = send_reply_devlist(sockfd);
- if (ret < 0) {
- err("send devlist reply");
+ rc = send_reply_devlist(connfd);
+ if (rc < 0) {
+ dbg("send_reply_devlist failed");
return -1;
}
return 0;
}
-
-static int recv_request_import(int sockfd)
+static int recv_pdu(int connfd)
{
+ uint16_t code = OP_UNSPEC;
int ret;
- struct op_import_request req;
- struct op_common reply;
- struct usbip_exported_device *edev;
- int found = 0;
- int error = 0;
- memset(&req, 0, sizeof(req));
- memset(&reply, 0, sizeof(reply));
-
- ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
+ ret = usbip_recv_op_common(connfd, &code);
if (ret < 0) {
- err("recv import request");
+ dbg("could not receive opcode: %#0x", code);
return -1;
}
- PACK_OP_IMPORT_REQUEST(0, &req);
-
- dlist_for_each_data(host_driver->edev_list, edev, struct usbip_exported_device) {
- if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) {
- dbg("found requested device %s", req.busid);
- found = 1;
- break;
- }
+ ret = usbip_host_refresh_device_list();
+ if (ret < 0) {
+ dbg("could not refresh device list: %d", ret);
+ return -1;
}
- if (found) {
- /* should set TCP_NODELAY for usbip */
- usbip_set_nodelay(sockfd);
-
- /* export_device needs a TCP/IP socket descriptor */
- ret = usbip_host_export_device(edev, sockfd);
- if (ret < 0)
- error = 1;
- } else {
- info("not found requested device %s", req.busid);
- error = 1;
+ info("received request: %#0x(%d)", code, connfd);
+ switch (code) {
+ case OP_REQ_DEVLIST:
+ ret = recv_request_devlist(connfd);
+ break;
+ case OP_REQ_IMPORT:
+ ret = recv_request_import(connfd);
+ break;
+ case OP_REQ_DEVINFO:
+ case OP_REQ_CRYPKEY:
+ default:
+ err("received an unknown opcode: %#0x", code);
+ ret = -1;
}
+ if (ret == 0)
+ info("request %#0x(%d): complete", code, connfd);
+ else
+ info("request %#0x(%d): failed", code, connfd);
- ret = usbip_send_op_common(sockfd, OP_REP_IMPORT, (!error ? ST_OK : ST_NA));
- if (ret < 0) {
- err("send import reply");
- return -1;
- }
-
- if (!error) {
- struct usbip_usb_device pdu_udev;
+ return ret;
+}
- memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
- pack_usb_device(1, &pdu_udev);
+#ifdef HAVE_LIBWRAP
+static int tcpd_auth(int connfd)
+{
+ struct request_info request;
+ int rc;
- ret = usbip_send(sockfd, (void *) &pdu_udev, sizeof(pdu_udev));
- if (ret < 0) {
- err("send devinfo");
- return -1;
- }
- }
+ request_init(&request, RQ_DAEMON, PROGNAME, RQ_FILE, connfd, 0);
+ fromhost(&request);
+ rc = hosts_access(&request);
+ if (rc == 0)
+ return -1;
return 0;
}
+#endif
-
-
-static int recv_pdu(int sockfd)
+static int do_accept(int listenfd)
{
- int ret;
- uint16_t code = OP_UNSPEC;
+ int connfd;
+ struct sockaddr_storage ss;
+ socklen_t len = sizeof(ss);
+ char host[NI_MAXHOST], port[NI_MAXSERV];
+ int rc;
+ memset(&ss, 0, sizeof(ss));
- ret = usbip_recv_op_common(sockfd, &code);
- if (ret < 0) {
- err("recv op_common, %d", ret);
- return ret;
+ connfd = accept(listenfd, (struct sockaddr *) &ss, &len);
+ if (connfd < 0) {
+ err("failed to accept connection");
+ return -1;
}
+ rc = getnameinfo((struct sockaddr *) &ss, len, host, sizeof(host),
+ port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
+ if (rc)
+ err("getnameinfo: %s", gai_strerror(rc));
- ret = usbip_host_refresh_device_list();
- if (ret < 0)
+#ifdef HAVE_LIBWRAP
+ rc = tcpd_auth(connfd);
+ if (rc < 0) {
+ info("denied access from %s", host);
+ close(connfd);
return -1;
+ }
+#endif
+ info("connection from %s:%s", host, port);
- switch(code) {
- case OP_REQ_DEVLIST:
- ret = recv_request_devlist(sockfd);
- break;
+ return connfd;
+}
- case OP_REQ_IMPORT:
- ret = recv_request_import(sockfd);
- break;
+gboolean process_request(GIOChannel *gio, GIOCondition condition,
+ gpointer unused_data)
+{
+ int listenfd;
+ int connfd;
- case OP_REQ_DEVINFO:
- case OP_REQ_CRYPKEY:
+ (void) unused_data;
- default:
- err("unknown op_code, %d", code);
- ret = -1;
+ if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
+ err("unknown condition");
+ BUG();
}
+ if (condition & G_IO_IN) {
+ listenfd = g_io_channel_unix_get_fd(gio);
+ connfd = do_accept(listenfd);
+ if (connfd < 0)
+ return TRUE;
- return ret;
-}
-
-
+ recv_pdu(connfd);
+ close(connfd);
+ }
+ return TRUE;
+}
static void log_addrinfo(struct addrinfo *ai)
{
- int ret;
char hbuf[NI_MAXHOST];
char sbuf[NI_MAXSERV];
+ int rc;
- ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf),
- sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
- if (ret)
- err("getnameinfo, %s", gai_strerror(ret));
-
- info("listen at [%s]:%s", hbuf, sbuf);
-}
-
-static struct addrinfo *my_getaddrinfo(char *host, int ai_family)
-{
- int ret;
- struct addrinfo hints, *ai_head;
-
- memset(&hints, 0, sizeof(hints));
-
- hints.ai_family = ai_family;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE;
-
- ret = getaddrinfo(host, USBIP_PORT_STRING, &hints, &ai_head);
- if (ret) {
- err("%s: %s", USBIP_PORT_STRING, gai_strerror(ret));
- return NULL;
- }
+ rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf),
+ sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
+ if (rc)
+ err("getnameinfo: %s", gai_strerror(rc));
- return ai_head;
+ info("listening on %s:%s", hbuf, sbuf);
}
-#define MAXSOCK 20
-static int listen_all_addrinfo(struct addrinfo *ai_head, int lsock[])
+static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[])
{
struct addrinfo *ai;
- int n = 0; /* number of sockets */
-
- for (ai = ai_head; ai && n < MAXSOCK; ai = ai->ai_next) {
- int ret;
+ int ret, nsockfd = 0;
- lsock[n] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (lsock[n] < 0)
+ for (ai = ai_head; ai && nsockfd < MAXSOCKFD; ai = ai->ai_next) {
+ sockfdlist[nsockfd] = socket(ai->ai_family, ai->ai_socktype,
+ ai->ai_protocol);
+ if (sockfdlist[nsockfd] < 0)
continue;
- usbip_set_reuseaddr(lsock[n]);
- usbip_set_nodelay(lsock[n]);
+ usbip_set_reuseaddr(sockfdlist[nsockfd]);
+ usbip_set_nodelay(sockfdlist[nsockfd]);
- if (lsock[n] >= FD_SETSIZE) {
- close(lsock[n]);
- lsock[n] = -1;
+ if (sockfdlist[nsockfd] >= FD_SETSIZE) {
+ close(sockfdlist[nsockfd]);
+ sockfdlist[nsockfd] = -1;
continue;
}
- ret = bind(lsock[n], ai->ai_addr, ai->ai_addrlen);
+ ret = bind(sockfdlist[nsockfd], ai->ai_addr, ai->ai_addrlen);
if (ret < 0) {
- close(lsock[n]);
- lsock[n] = -1;
+ close(sockfdlist[nsockfd]);
+ sockfdlist[nsockfd] = -1;
continue;
}
- ret = listen(lsock[n], SOMAXCONN);
+ ret = listen(sockfdlist[nsockfd], SOMAXCONN);
if (ret < 0) {
- close(lsock[n]);
- lsock[n] = -1;
+ close(sockfdlist[nsockfd]);
+ sockfdlist[nsockfd] = -1;
continue;
}
log_addrinfo(ai);
-
- /* next if succeed */
- n++;
+ nsockfd++;
}
- if (n == 0) {
- err("no socket to listen to");
+ if (nsockfd == 0)
return -1;
- }
-
- dbg("listen %d address%s", n, (n==1)?"":"es");
-
- return n;
-}
-
-#ifdef HAVE_LIBWRAP
-static int tcpd_auth(int csock)
-{
- int ret;
- struct request_info request;
-
- request_init(&request, RQ_DAEMON, "usbipd", RQ_FILE, csock, 0);
-
- fromhost(&request);
- ret = hosts_access(&request);
- if (!ret)
- return -1;
+ dbg("listening on %d address%s", nsockfd, (nsockfd == 1) ? "" : "es");
- return 0;
+ return nsockfd;
}
-#endif
-static int my_accept(int lsock)
+static struct addrinfo *do_getaddrinfo(char *host, int ai_family)
{
- int csock;
- struct sockaddr_storage ss;
- socklen_t len = sizeof(ss);
- char host[NI_MAXHOST], port[NI_MAXSERV];
- int ret;
-
- memset(&ss, 0, sizeof(ss));
-
- csock = accept(lsock, (struct sockaddr *) &ss, &len);
- if (csock < 0) {
- err("accept");
- return -1;
- }
+ struct addrinfo hints, *ai_head;
+ int rc;
- ret = getnameinfo((struct sockaddr *) &ss, len,
- host, sizeof(host), port, sizeof(port),
- (NI_NUMERICHOST | NI_NUMERICSERV));
- if (ret)
- err("getnameinfo, %s", gai_strerror(ret));
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = ai_family;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE;
-#ifdef HAVE_LIBWRAP
- ret = tcpd_auth(csock);
- if (ret < 0) {
- info("deny access from %s", host);
- close(csock);
- return -1;
+ rc = getaddrinfo(host, USBIP_PORT_STRING, &hints, &ai_head);
+ if (rc) {
+ err("failed to get a network address %s: %s", USBIP_PORT_STRING,
+ gai_strerror(rc));
+ return NULL;
}
-#endif
- info("connected from %s:%s", host, port);
-
- return csock;
+ return ai_head;
}
-
-GMainLoop *main_loop;
-
static void signal_handler(int i)
{
- dbg("signal catched, code %d", i);
+ dbg("received signal: code %d", i);
if (main_loop)
g_main_loop_quit(main_loop);
@@ -387,184 +435,133 @@ static void set_signal(void)
sigaction(SIGINT, &act, NULL);
}
-
-gboolean process_comming_request(GIOChannel *gio, GIOCondition condition,
- gpointer data __attribute__((unused)))
-{
- int ret;
-
- if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
- g_error("unknown condition");
-
-
- if (condition & G_IO_IN) {
- int lsock;
- int csock;
-
- lsock = g_io_channel_unix_get_fd(gio);
-
- csock = my_accept(lsock);
- if (csock < 0)
- return TRUE;
-
- ret = recv_pdu(csock);
- if (ret < 0)
- err("process received pdu");
-
- close(csock);
- }
-
- return TRUE;
-}
-
-
-static void do_standalone_mode(gboolean daemonize)
+static int do_standalone_mode(gboolean daemonize)
{
- int ret;
- int lsock[MAXSOCK];
struct addrinfo *ai_head;
- int n;
+ int sockfdlist[MAXSOCKFD];
+ int nsockfd;
+ int i;
+ if (usbip_names_init(USBIDS_FILE))
+ err("failed to open %s", USBIDS_FILE);
-
- ret = usbip_names_init(USBIDS_FILE);
- if (ret)
- err("open usb.ids");
-
- ret = usbip_host_driver_open();
- if (ret < 0)
- g_error("driver open failed");
+ if (usbip_host_driver_open()) {
+ err("please load " USBIP_CORE_MOD_NAME ".ko and "
+ USBIP_HOST_DRV_NAME ".ko!");
+ return -1;
+ }
if (daemonize) {
- if (daemon(0,0) < 0)
- g_error("daemonizing failed: %s", g_strerror(errno));
+ if (daemon(0,0) < 0) {
+ err("daemonizing failed: %s", strerror(errno));
+ return -1;
+ }
usbip_use_syslog = 1;
}
-
set_signal();
- ai_head = my_getaddrinfo(NULL, PF_UNSPEC);
+ ai_head = do_getaddrinfo(NULL, PF_UNSPEC);
if (!ai_head)
- return;
+ return -1;
- n = listen_all_addrinfo(ai_head, lsock);
- if (n <= 0)
- g_error("no socket to listen to");
+ info("starting " PROGNAME " (%s)", usbip_version_string);
- for (int i = 0; i < n; i++) {
+ nsockfd = listen_all_addrinfo(ai_head, sockfdlist);
+ if (nsockfd <= 0) {
+ err("failed to open a listening socket");
+ return -1;
+ }
+
+ for (i = 0; i < nsockfd; i++) {
GIOChannel *gio;
- gio = g_io_channel_unix_new(lsock[i]);
+ gio = g_io_channel_unix_new(sockfdlist[i]);
g_io_add_watch(gio, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
- process_comming_request, NULL);
+ process_request, NULL);
}
-
- info("usbipd start (%s)", version);
-
-
main_loop = g_main_loop_new(FALSE, FALSE);
g_main_loop_run(main_loop);
- info("shutdown");
+ info("shutting down " PROGNAME);
freeaddrinfo(ai_head);
- usbip_names_free();
usbip_host_driver_close();
+ usbip_names_free();
- return;
-}
-
-
-static const char help_message[] = "\
-Usage: usbipd [options] \n\
- -D, --daemon \n\
- Run as a daemon process. \n\
- \n\
- -d, --debug \n\
- Print debugging information. \n\
- \n\
- -v, --version \n\
- Show version. \n\
- \n\
- -h, --help \n\
- Print this help. \n";
-
-static void show_help(void)
-{
- printf("%s", help_message);
+ return 0;
}
-static const struct option longopts[] = {
- {"daemon", no_argument, NULL, 'D'},
- {"debug", no_argument, NULL, 'd'},
- {"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
-};
-
int main(int argc, char *argv[])
{
- gboolean daemonize = FALSE;
+ static const struct option longopts[] = {
+ { "daemon", no_argument, NULL, 'D' },
+ { "debug", no_argument, NULL, 'd' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
+ { NULL, 0, NULL, 0 }
+ };
enum {
cmd_standalone_mode = 1,
cmd_help,
cmd_version
- } cmd = cmd_standalone_mode;
+ } cmd;
+ gboolean daemonize = FALSE;
+ int opt, rc = -1;
usbip_use_stderr = 1;
usbip_use_syslog = 0;
if (geteuid() != 0)
- g_warning("running non-root?");
+ err("not running as root?");
+ cmd = cmd_standalone_mode;
for (;;) {
- int c;
- int index = 0;
+ opt = getopt_long(argc, argv, "Ddhv", longopts, NULL);
- c = getopt_long(argc, argv, "vhdD", longopts, &index);
-
- if (c == -1)
+ if (opt == -1)
break;
- switch (c) {
- case 'd':
- usbip_use_debug = 1;
- continue;
- case 'v':
- cmd = cmd_version;
- break;
- case 'h':
- cmd = cmd_help;
- break;
- case 'D':
- daemonize = TRUE;
- break;
- case '?':
- show_help();
- exit(EXIT_FAILURE);
- default:
- err("getopt");
- }
- }
-
- switch (cmd) {
- case cmd_standalone_mode:
- do_standalone_mode(daemonize);
+ switch (opt) {
+ case 'D':
+ daemonize = TRUE;
+ break;
+ case 'd':
+ usbip_use_debug = 1;
break;
- case cmd_version:
- printf("%s\n", version);
+ case 'h':
+ cmd = cmd_help;
break;
- case cmd_help:
- show_help();
+ case 'v':
+ cmd = cmd_version;
break;
+ case '?':
+ usbipd_help();
default:
- info("unknown cmd");
- show_help();
+ goto err_out;
+ }
}
- return 0;
+ switch (cmd) {
+ case cmd_standalone_mode:
+ rc = do_standalone_mode(daemonize);
+ break;
+ case cmd_version:
+ printf(PROGNAME " (%s)\n", usbip_version_string);
+ rc = 0;
+ break;
+ case cmd_help:
+ usbipd_help();
+ rc = 0;
+ break;
+ default:
+ usbipd_help();
+ goto err_out;
+ }
+
+err_out:
+ return (rc > -1 ? EXIT_SUCCESS : EXIT_FAILURE);
}
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] staging: usbip: userspace: add new prefix for usbip network code
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
2011-07-07 7:31 ` [PATCH 1/7] staging: usbip: userspace: usbipd: major cleanup of daemon matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 3/7] staging: usbip: userspace: fix header installation bug matt mooney
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Change and add new usbip_net_ prefix to every function in the network
code for easier identification.
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/src/usbip_attach.c | 10 ++--
drivers/staging/usbip/userspace/src/usbip_list.c | 26 +++++----
.../staging/usbip/userspace/src/usbip_network.c | 56 ++++++++++---------
.../staging/usbip/userspace/src/usbip_network.h | 39 +++++++-------
drivers/staging/usbip/userspace/src/usbipd.c | 50 +++++++++---------
5 files changed, 92 insertions(+), 89 deletions(-)
diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c
index 06640b2..b7885a2 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_attach.c
@@ -115,7 +115,7 @@ static int query_import_device(int sockfd, char *busid)
memset(&reply, 0, sizeof(reply));
/* send a request */
- rc = usbip_send_op_common(sockfd, OP_REQ_IMPORT, 0);
+ rc = usbip_net_send_op_common(sockfd, OP_REQ_IMPORT, 0);
if (rc < 0) {
err("send op_common");
return -1;
@@ -125,20 +125,20 @@ static int query_import_device(int sockfd, char *busid)
PACK_OP_IMPORT_REQUEST(0, &request);
- rc = usbip_send(sockfd, (void *) &request, sizeof(request));
+ rc = usbip_net_send(sockfd, (void *) &request, sizeof(request));
if (rc < 0) {
err("send op_import_request");
return -1;
}
- /* receive a reply */
- rc = usbip_recv_op_common(sockfd, &code);
+ /* recieve a reply */
+ rc = usbip_net_recv_op_common(sockfd, &code);
if (rc < 0) {
err("recv op_common");
return -1;
}
- rc = usbip_recv(sockfd, (void *) &reply, sizeof(reply));
+ rc = usbip_net_recv(sockfd, (void *) &reply, sizeof(reply));
if (rc < 0) {
err("recv op_import_reply");
return -1;
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 973bf8c..3edf5d1 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -56,22 +56,22 @@ static int get_exported_devices(char *host, int sockfd)
unsigned int i;
int j, rc;
- rc = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
+ rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
if (rc < 0) {
- dbg("usbip_send_op_common failed");
+ dbg("usbip_net_send_op_common failed");
return -1;
}
- rc = usbip_recv_op_common(sockfd, &code);
+ rc = usbip_net_recv_op_common(sockfd, &code);
if (rc < 0) {
- dbg("usbip_recv_op_common failed");
+ dbg("usbip_net_recv_op_common failed");
return -1;
}
memset(&reply, 0, sizeof(reply));
- rc = usbip_recv(sockfd, &reply, sizeof(reply));
+ rc = usbip_net_recv(sockfd, &reply, sizeof(reply));
if (rc < 0) {
- dbg("usbip_recv_op_devlist failed");
+ dbg("usbip_net_recv_op_devlist failed");
return -1;
}
PACK_OP_DEVLIST_REPLY(0, &reply);
@@ -88,12 +88,12 @@ static int get_exported_devices(char *host, int sockfd)
for (i = 0; i < reply.ndev; i++) {
memset(&udev, 0, sizeof(udev));
- rc = usbip_recv(sockfd, &udev, sizeof(udev));
+ rc = usbip_net_recv(sockfd, &udev, sizeof(udev));
if (rc < 0) {
- dbg("usbip_recv failed: usbip_usb_device[%d]", i);
+ dbg("usbip_net_recv failed: usbip_usb_device[%d]", i);
return -1;
}
- pack_usb_device(0, &udev);
+ usbip_net_pack_usb_device(0, &udev);
usbip_names_get_product(product_name, sizeof(product_name),
udev.idVendor, udev.idProduct);
@@ -105,12 +105,14 @@ static int get_exported_devices(char *host, int sockfd)
printf("%8s: %s\n", "", class_name);
for (j = 0; j < udev.bNumInterfaces; j++) {
- rc = usbip_recv(sockfd, &uintf, sizeof(uintf));
+ rc = usbip_net_recv(sockfd, &uintf, sizeof(uintf));
if (rc < 0) {
- dbg("usbip_recv failed: usbip_usb_intf[%d]", j);
+ dbg("usbip_net_recv failed: usbip_usb_intf[%d]",
+ j);
+
return -1;
}
- pack_usb_interface(0, &uintf);
+ usbip_net_pack_usb_interface(0, &uintf);
usbip_names_get_class(class_name, sizeof(class_name),
uintf.bInterfaceClass,
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c
index a3833ff..1a84dd3 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.c
+++ b/drivers/staging/usbip/userspace/src/usbip_network.c
@@ -28,7 +28,7 @@
#include "usbip_common.h"
#include "usbip_network.h"
-void pack_uint32_t(int pack, uint32_t *num)
+void usbip_net_pack_uint32_t(int pack, uint32_t *num)
{
uint32_t i;
@@ -40,7 +40,7 @@ void pack_uint32_t(int pack, uint32_t *num)
*num = i;
}
-void pack_uint16_t(int pack, uint16_t *num)
+void usbip_net_pack_uint16_t(int pack, uint16_t *num)
{
uint16_t i;
@@ -52,24 +52,26 @@ void pack_uint16_t(int pack, uint16_t *num)
*num = i;
}
-void pack_usb_device(int pack, struct usbip_usb_device *udev)
+void usbip_net_pack_usb_device(int pack, struct usbip_usb_device *udev)
{
- pack_uint32_t(pack, &udev->busnum);
- pack_uint32_t(pack, &udev->devnum);
- pack_uint32_t(pack, &udev->speed );
+ usbip_net_pack_uint32_t(pack, &udev->busnum);
+ usbip_net_pack_uint32_t(pack, &udev->devnum);
+ usbip_net_pack_uint32_t(pack, &udev->speed );
- pack_uint16_t(pack, &udev->idVendor );
- pack_uint16_t(pack, &udev->idProduct);
- pack_uint16_t(pack, &udev->bcdDevice);
+ usbip_net_pack_uint16_t(pack, &udev->idVendor);
+ usbip_net_pack_uint16_t(pack, &udev->idProduct);
+ usbip_net_pack_uint16_t(pack, &udev->bcdDevice);
}
-void pack_usb_interface(int pack __attribute__((unused)),
- struct usbip_usb_interface *udev __attribute__((unused)))
+void usbip_net_pack_usb_interface(int pack __attribute__((unused)),
+ struct usbip_usb_interface *udev
+ __attribute__((unused)))
{
/* uint8_t members need nothing */
}
-static ssize_t usbip_xmit(int sockfd, void *buff, size_t bufflen, int sending)
+static ssize_t usbip_net_xmit(int sockfd, void *buff, size_t bufflen,
+ int sending)
{
ssize_t nbytes;
ssize_t total = 0;
@@ -95,17 +97,17 @@ static ssize_t usbip_xmit(int sockfd, void *buff, size_t bufflen, int sending)
return total;
}
-ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen)
+ssize_t usbip_net_recv(int sockfd, void *buff, size_t bufflen)
{
- return usbip_xmit(sockfd, buff, bufflen, 0);
+ return usbip_net_xmit(sockfd, buff, bufflen, 0);
}
-ssize_t usbip_send(int sockfd, void *buff, size_t bufflen)
+ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen)
{
- return usbip_xmit(sockfd, buff, bufflen, 1);
+ return usbip_net_xmit(sockfd, buff, bufflen, 1);
}
-int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status)
+int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status)
{
struct op_common op_common;
int rc;
@@ -118,25 +120,25 @@ int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status)
PACK_OP_COMMON(1, &op_common);
- rc = usbip_send(sockfd, &op_common, sizeof(op_common));
+ rc = usbip_net_send(sockfd, &op_common, sizeof(op_common));
if (rc < 0) {
- dbg("usbip_send failed: %d", rc);
+ dbg("usbip_net_send failed: %d", rc);
return -1;
}
return 0;
}
-int usbip_recv_op_common(int sockfd, uint16_t *code)
+int usbip_net_recv_op_common(int sockfd, uint16_t *code)
{
struct op_common op_common;
int rc;
memset(&op_common, 0, sizeof(op_common));
- rc = usbip_recv(sockfd, &op_common, sizeof(op_common));
+ rc = usbip_net_recv(sockfd, &op_common, sizeof(op_common));
if (rc < 0) {
- dbg("usbip_recv failed: %d", rc);
+ dbg("usbip_net_recv failed: %d", rc);
goto err;
}
@@ -171,7 +173,7 @@ err:
return -1;
}
-int usbip_set_reuseaddr(int sockfd)
+int usbip_net_set_reuseaddr(int sockfd)
{
const int val = 1;
int ret;
@@ -183,7 +185,7 @@ int usbip_set_reuseaddr(int sockfd)
return ret;
}
-int usbip_set_nodelay(int sockfd)
+int usbip_net_set_nodelay(int sockfd)
{
const int val = 1;
int ret;
@@ -195,7 +197,7 @@ int usbip_set_nodelay(int sockfd)
return ret;
}
-int usbip_set_keepalive(int sockfd)
+int usbip_net_set_keepalive(int sockfd)
{
const int val = 1;
int ret;
@@ -236,9 +238,9 @@ int usbip_net_tcp_connect(char *hostname, char *service)
continue;
/* should set TCP_NODELAY for usbip */
- usbip_set_nodelay(sockfd);
+ usbip_net_set_nodelay(sockfd);
/* TODO: write code for heartbeat */
- usbip_set_keepalive(sockfd);
+ usbip_net_set_keepalive(sockfd);
if (connect(sockfd, rp->ai_addr, rp->ai_addrlen) == 0)
break;
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h
index 07274df..2d1e070 100644
--- a/drivers/staging/usbip/userspace/src/usbip_network.h
+++ b/drivers/staging/usbip/userspace/src/usbip_network.h
@@ -34,9 +34,9 @@ struct op_common {
} __attribute__((packed));
#define PACK_OP_COMMON(pack, op_common) do {\
- pack_uint16_t(pack, &(op_common)->version);\
- pack_uint16_t(pack, &(op_common)->code );\
- pack_uint32_t(pack, &(op_common)->status );\
+ usbip_net_pack_uint16_t(pack, &(op_common)->version);\
+ usbip_net_pack_uint16_t(pack, &(op_common)->code );\
+ usbip_net_pack_uint32_t(pack, &(op_common)->status );\
} while (0)
/* ---------------------------------------------------------------------- */
@@ -79,7 +79,7 @@ struct op_import_reply {
} while (0)
#define PACK_OP_IMPORT_REPLY(pack, reply) do {\
- pack_usb_device(pack, &(reply)->udev);\
+ usbip_net_pack_usb_device(pack, &(reply)->udev);\
} while (0)
/* ---------------------------------------------------------------------- */
@@ -98,7 +98,7 @@ struct op_export_reply {
#define PACK_OP_EXPORT_REQUEST(pack, request) do {\
- pack_usb_device(pack, &(request)->udev);\
+ usbip_net_pack_usb_device(pack, &(request)->udev);\
} while (0)
#define PACK_OP_EXPORT_REPLY(pack, reply) do {\
@@ -119,7 +119,7 @@ struct op_unexport_reply {
} __attribute__((packed));
#define PACK_OP_UNEXPORT_REQUEST(pack, request) do {\
- pack_usb_device(pack, &(request)->udev);\
+ usbip_net_pack_usb_device(pack, &(request)->udev);\
} while (0)
#define PACK_OP_UNEXPORT_REPLY(pack, reply) do {\
@@ -164,22 +164,21 @@ struct op_devlist_reply_extra {
} while (0)
#define PACK_OP_DEVLIST_REPLY(pack, reply) do {\
- pack_uint32_t(pack, &(reply)->ndev);\
+ usbip_net_pack_uint32_t(pack, &(reply)->ndev);\
} while (0)
-void pack_uint32_t(int pack, uint32_t *num);
-void pack_uint16_t(int pack, uint16_t *num);
-void pack_usb_device(int pack, struct usbip_usb_device *udev);
-void pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
-
-ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen);
-ssize_t usbip_send(int sockfd, void *buff, size_t bufflen);
-int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status);
-int usbip_recv_op_common(int sockfd, uint16_t *code);
-int usbip_set_reuseaddr(int sockfd);
-int usbip_set_nodelay(int sockfd);
-int usbip_set_keepalive(int sockfd);
-
+void usbip_net_pack_uint32_t(int pack, uint32_t *num);
+void usbip_net_pack_uint16_t(int pack, uint16_t *num);
+void usbip_net_pack_usb_device(int pack, struct usbip_usb_device *udev);
+void usbip_net_pack_usb_interface(int pack, struct usbip_usb_interface *uinf);
+
+ssize_t usbip_net_recv(int sockfd, void *buff, size_t bufflen);
+ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen);
+int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status);
+int usbip_net_recv_op_common(int sockfd, uint16_t *code);
+int usbip_net_set_reuseaddr(int sockfd);
+int usbip_net_set_nodelay(int sockfd);
+int usbip_net_set_keepalive(int sockfd);
int usbip_net_tcp_connect(char *hostname, char *port);
#endif /* __USBIP_NETWORK_H */
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
index aa92623..8668a80 100644
--- a/drivers/staging/usbip/userspace/src/usbipd.c
+++ b/drivers/staging/usbip/userspace/src/usbipd.c
@@ -84,9 +84,9 @@ static int recv_request_import(int sockfd)
memset(&req, 0, sizeof(req));
memset(&reply, 0, sizeof(reply));
- rc = usbip_recv(sockfd, &req, sizeof(req));
+ rc = usbip_net_recv(sockfd, &req, sizeof(req));
if (rc < 0) {
- dbg("usbip_recv failed: import request");
+ dbg("usbip_net_recv failed: import request");
return -1;
}
PACK_OP_IMPORT_REQUEST(0, &req);
@@ -102,7 +102,7 @@ static int recv_request_import(int sockfd)
if (found) {
/* should set TCP_NODELAY for usbip */
- usbip_set_nodelay(sockfd);
+ usbip_net_set_nodelay(sockfd);
/* export device needs a TCP/IP socket descriptor */
rc = usbip_host_export_device(edev, sockfd);
@@ -113,11 +113,10 @@ static int recv_request_import(int sockfd)
error = 1;
}
-
- rc = usbip_send_op_common(sockfd, OP_REP_IMPORT,
- (!error ? ST_OK : ST_NA));
+ rc = usbip_net_send_op_common(sockfd, OP_REP_IMPORT,
+ (!error ? ST_OK : ST_NA));
if (rc < 0) {
- dbg("usbip_send_op_common failed: %#0x", OP_REP_IMPORT);
+ dbg("usbip_net_send_op_common failed: %#0x", OP_REP_IMPORT);
return -1;
}
@@ -127,11 +126,11 @@ static int recv_request_import(int sockfd)
}
memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
- pack_usb_device(1, &pdu_udev);
+ usbip_net_pack_usb_device(1, &pdu_udev);
- rc = usbip_send(sockfd, &pdu_udev, sizeof(pdu_udev));
+ rc = usbip_net_send(sockfd, &pdu_udev, sizeof(pdu_udev));
if (rc < 0) {
- dbg("usbip_send failed: devinfo");
+ dbg("usbip_net_send failed: devinfo");
return -1;
}
@@ -157,16 +156,16 @@ static int send_reply_devlist(int connfd)
}
info("exportable devices: %d", reply.ndev);
- rc = usbip_send_op_common(connfd, OP_REP_DEVLIST, ST_OK);
+ rc = usbip_net_send_op_common(connfd, OP_REP_DEVLIST, ST_OK);
if (rc < 0) {
- dbg("usbip_send_op_common failed: %#0x", OP_REP_DEVLIST);
+ dbg("usbip_net_send_op_common failed: %#0x", OP_REP_DEVLIST);
return -1;
}
PACK_OP_DEVLIST_REPLY(1, &reply);
- rc = usbip_send(connfd, &reply, sizeof(reply));
+ rc = usbip_net_send(connfd, &reply, sizeof(reply));
if (rc < 0) {
- dbg("usbip_send failed: %#0x", OP_REP_DEVLIST);
+ dbg("usbip_net_send failed: %#0x", OP_REP_DEVLIST);
return -1;
}
@@ -174,22 +173,23 @@ static int send_reply_devlist(int connfd)
struct usbip_exported_device) {
dump_usb_device(&edev->udev);
memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
- pack_usb_device(1, &pdu_udev);
+ usbip_net_pack_usb_device(1, &pdu_udev);
- rc = usbip_send(connfd, &pdu_udev, sizeof(pdu_udev));
+ rc = usbip_net_send(connfd, &pdu_udev, sizeof(pdu_udev));
if (rc < 0) {
- dbg("usbip_send failed: pdu_udev");
+ dbg("usbip_net_send failed: pdu_udev");
return -1;
}
for (i = 0; i < edev->udev.bNumInterfaces; i++) {
dump_usb_interface(&edev->uinf[i]);
memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
- pack_usb_interface(1, &pdu_uinf);
+ usbip_net_pack_usb_interface(1, &pdu_uinf);
- rc = usbip_send(connfd, &pdu_uinf, sizeof(pdu_uinf));
+ rc = usbip_net_send(connfd, &pdu_uinf,
+ sizeof(pdu_uinf));
if (rc < 0) {
- dbg("usbip_send failed: pdu_uinf");
+ dbg("usbip_net_send failed: pdu_uinf");
return -1;
}
}
@@ -205,9 +205,9 @@ static int recv_request_devlist(int connfd)
memset(&req, 0, sizeof(req));
- rc = usbip_recv(connfd, &req, sizeof(req));
+ rc = usbip_net_recv(connfd, &req, sizeof(req));
if (rc < 0) {
- dbg("usbip_recv failed: devlist request");
+ dbg("usbip_net_recv failed: devlist request");
return -1;
}
@@ -225,7 +225,7 @@ static int recv_pdu(int connfd)
uint16_t code = OP_UNSPEC;
int ret;
- ret = usbip_recv_op_common(connfd, &code);
+ ret = usbip_net_recv_op_common(connfd, &code);
if (ret < 0) {
dbg("could not receive opcode: %#0x", code);
return -1;
@@ -361,8 +361,8 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[])
if (sockfdlist[nsockfd] < 0)
continue;
- usbip_set_reuseaddr(sockfdlist[nsockfd]);
- usbip_set_nodelay(sockfdlist[nsockfd]);
+ usbip_net_set_reuseaddr(sockfdlist[nsockfd]);
+ usbip_net_set_nodelay(sockfdlist[nsockfd]);
if (sockfdlist[nsockfd] >= FD_SETSIZE) {
close(sockfdlist[nsockfd]);
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] staging: usbip: userspace: fix header installation bug
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
2011-07-07 7:31 ` [PATCH 1/7] staging: usbip: userspace: usbipd: major cleanup of daemon matt mooney
2011-07-07 7:31 ` [PATCH 2/7] staging: usbip: userspace: add new prefix for usbip network code matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 4/7] staging: usbip: userspace: usbip_list.c: modify exportable device output matt mooney
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
A bug that I created due to using simply expanding variables in the
makefiles. Although only unexpanded paths are at issue here, I decided
to use recursively expanding variables on all of the parameterized
values.
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/Makefile.am | 2 +-
drivers/staging/usbip/userspace/libsrc/Makefile.am | 6 +++---
drivers/staging/usbip/userspace/src/Makefile.am | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/usbip/userspace/Makefile.am b/drivers/staging/usbip/userspace/Makefile.am
index fbdeef3..9ab1949 100644
--- a/drivers/staging/usbip/userspace/Makefile.am
+++ b/drivers/staging/usbip/userspace/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS := libsrc src
-includedir := @includedir@/usbip
+includedir = @includedir@/usbip
include_HEADERS := $(addprefix libsrc/, \
usbip_common.h vhci_driver.h usbip_host_driver.h)
diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/drivers/staging/usbip/userspace/libsrc/Makefile.am
index 9b663a4..4921189 100644
--- a/drivers/staging/usbip/userspace/libsrc/Makefile.am
+++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am
@@ -1,6 +1,6 @@
-libusbip_la_CPPFLAGS := -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
-libusbip_la_CFLAGS := @EXTRA_CFLAGS@
-libusbip_la_LDFLAGS := -version-info @LIBUSBIP_VERSION@
+libusbip_la_CPPFLAGS = -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
+libusbip_la_CFLAGS = @EXTRA_CFLAGS@
+libusbip_la_LDFLAGS = -version-info @LIBUSBIP_VERSION@
lib_LTLIBRARIES := libusbip.la
libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
index 44ff0ca..3f09f6a 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -1,6 +1,6 @@
-AM_CPPFLAGS := -I$(top_srcdir)/libsrc -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
-AM_CFLAGS := @EXTRA_CFLAGS@ @PACKAGE_CFLAGS@
-LDADD := $(top_builddir)/libsrc/libusbip.la @PACKAGE_LIBS@
+AM_CPPFLAGS = -I$(top_srcdir)/libsrc -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
+AM_CFLAGS = @EXTRA_CFLAGS@ @PACKAGE_CFLAGS@
+LDADD = $(top_builddir)/libsrc/libusbip.la @PACKAGE_LIBS@
sbin_PROGRAMS := usbip usbipd
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] staging: usbip: userspace: usbip_list.c: modify exportable device output
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
` (2 preceding siblings ...)
2011-07-07 7:31 ` [PATCH 3/7] staging: usbip: userspace: fix header installation bug matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 5/7] staging: usbip: userspace: usbip: modify `list' help message matt mooney
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Change spacing to provide better indentation for readability.
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/src/usbip_list.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 3edf5d1..6349638 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -100,9 +100,9 @@ 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("%8s: %s\n", udev.busid, product_name);
- printf("%8s: %s\n", "", udev.path);
- printf("%8s: %s\n", "", class_name);
+ 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));
@@ -118,7 +118,7 @@ static int get_exported_devices(char *host, int sockfd)
uintf.bInterfaceClass,
uintf.bInterfaceSubClass,
uintf.bInterfaceProtocol);
- printf("%8s: %2d - %s\n", "", j, class_name);
+ printf("%11s: %2d - %s\n", "", j, class_name);
}
printf("\n");
}
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] staging: usbip: userspace: usbip: modify `list' help message
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
` (3 preceding siblings ...)
2011-07-07 7:31 ` [PATCH 4/7] staging: usbip: userspace: usbip_list.c: modify exportable device output matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 6/7] staging: usbip: userspace: README: update example output matt mooney
2011-07-07 7:31 ` [PATCH 7/7] staging: usbip: userspace: usbip-utils 1.1.1 matt mooney
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
The remote devices listed are, technically, exportable and not
necessarily exported.
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/src/usbip.c | 2 +-
drivers/staging/usbip/userspace/src/usbip_list.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
index 583b179..fff4b76 100644
--- a/drivers/staging/usbip/userspace/src/usbip.c
+++ b/drivers/staging/usbip/userspace/src/usbip.c
@@ -77,7 +77,7 @@ static const struct command cmds[] = {
{
.name = "list",
.fn = usbip_list,
- .help = "List exported or local USB devices",
+ .help = "List exportable or local USB devices",
.usage = usbip_list_usage
},
{
diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 6349638..ed30d91 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -37,7 +37,7 @@
static const char usbip_list_usage_string[] =
"usbip list [-p|--parsable] <args>\n"
" -p, --parsable Parsable list format\n"
- " -r, --remote=<host> List the exported USB devices on <host>\n"
+ " -r, --remote=<host> List the exportable USB devices on <host>\n"
" -l, --local List the local USB devices\n";
void usbip_list_usage(void)
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] staging: usbip: userspace: README: update example output
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
` (4 preceding siblings ...)
2011-07-07 7:31 ` [PATCH 5/7] staging: usbip: userspace: usbip: modify `list' help message matt mooney
@ 2011-07-07 7:31 ` matt mooney
2011-07-07 7:31 ` [PATCH 7/7] staging: usbip: userspace: usbip-utils 1.1.1 matt mooney
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Change a missed reference to the `list' command, and update the output
from `usbip bind ...' and `usbip list -r ...'
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/README | 53 +++++++++++++++++---------------
1 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/usbip/userspace/README b/drivers/staging/usbip/userspace/README
index aafab102..63cd107 100644
--- a/drivers/staging/usbip/userspace/README
+++ b/drivers/staging/usbip/userspace/README
@@ -79,7 +79,7 @@ Physically attach your USB devices to this host.
In another terminal, let's look up what USB devices are physically
attached to this host.
- trois:# usbip_bind_driver --list
+ trois:# usbip list -l
Local USB devices
=================
- busid 1-1 (05a9:a511)
@@ -115,8 +115,9 @@ Mark the device of busid 3-3.2 as exportable:
trois:# usbip --debug bind --busid 3-3.2
...
- usbip dbg: utils.c: 52 (modify_match_busid) write "add 3-3.2" to...
- usbip dbg: usbip_bind.c: 231 (use_device_by_usbip) bind 3-3.2 complete!
+ usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage
+ ...
+ bind device on busid 3-3.2: complete
trois:# usbip list -l
Local USB devices
@@ -137,28 +138,30 @@ exportable on the host.
deux:# insmod path/to/vhci-hcd.ko
deux:# usbip list --remote 10.0.0.3
- - 10.0.0.3
- 1-1: Prolific Technology, Inc. : unknown product (067b:3507)
- : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
- : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
- : 0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
-
- 1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
- : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
- : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
- : 0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
-
- 1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
- : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
- : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
- : 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
-
- 3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
- : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
- : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
- : 0 - Data / unknown subclass / unknown protocol (0a/ff/00)
- : 1 - Audio / Control Device / unknown protocol (01/01/00)
- : 2 - Audio / Streaming / unknown protocol (01/02/00)
+ Exportable USB devices
+ ======================
+ - 10.0.0.3
+ 1-1: Prolific Technology, Inc. : unknown product (067b:3507)
+ : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
+ : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+ : 0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
+
+ 1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
+ : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
+ : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+ : 0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
+
+ 1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
+ : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
+ : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+ : 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
+
+ 3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
+ : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
+ : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+ : 0 - Data / unknown subclass / unknown protocol (0a/ff/00)
+ : 1 - Audio / Control Device / unknown protocol (01/01/00)
+ : 2 - Audio / Streaming / unknown protocol (01/02/00)
Attach a remote USB device:
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] staging: usbip: userspace: usbip-utils 1.1.1
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
` (5 preceding siblings ...)
2011-07-07 7:31 ` [PATCH 6/7] staging: usbip: userspace: README: update example output matt mooney
@ 2011-07-07 7:31 ` matt mooney
6 siblings, 0 replies; 8+ messages in thread
From: matt mooney @ 2011-07-07 7:31 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Bump package revision number!
Signed-off-by: matt mooney <mfm@muteddisk.com>
---
drivers/staging/usbip/userspace/configure.ac | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac
index 89fefd5..bf5cf49 100644
--- a/drivers/staging/usbip/userspace/configure.ac
+++ b/drivers/staging/usbip/userspace/configure.ac
@@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([usbip-utils], [1.1.0], [linux-usb@vger.kernel.org])
-AC_DEFINE([USBIP_VERSION], [0x00000100], [binary-coded decimal version number])
+AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org])
+AC_DEFINE([USBIP_VERSION], [0x00000111], [binary-coded decimal version number])
CURRENT=0
REVISION=1
--
1.7.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-07-07 8:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 7:31 [PATCH 0/7] staging: usbip: rebased userspace patches matt mooney
2011-07-07 7:31 ` [PATCH 1/7] staging: usbip: userspace: usbipd: major cleanup of daemon matt mooney
2011-07-07 7:31 ` [PATCH 2/7] staging: usbip: userspace: add new prefix for usbip network code matt mooney
2011-07-07 7:31 ` [PATCH 3/7] staging: usbip: userspace: fix header installation bug matt mooney
2011-07-07 7:31 ` [PATCH 4/7] staging: usbip: userspace: usbip_list.c: modify exportable device output matt mooney
2011-07-07 7:31 ` [PATCH 5/7] staging: usbip: userspace: usbip: modify `list' help message matt mooney
2011-07-07 7:31 ` [PATCH 6/7] staging: usbip: userspace: README: update example output matt mooney
2011-07-07 7:31 ` [PATCH 7/7] staging: usbip: userspace: usbip-utils 1.1.1 matt mooney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).