lkml.org 
[lkml]   [2012]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] usb: usbip: userspace: remove the port state file when detaching port.
Date
with the last detached port state file remaining , usbip reports error on attaching. So clean up the state files on detaching.

Signed-off-by: Harvey Yang <harvey.huawei.yang@gmail.com>
---
drivers/staging/usbip/userspace/src/usbip_detach.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c b/drivers/staging/usbip/userspace/src/usbip_detach.c
index 89bf3c1..312745d 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_detach.c
@@ -19,6 +19,7 @@
#include <sysfs/libsysfs.h>

#include <ctype.h>
+#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,6 +47,7 @@ static int detach_port(char *port)
{
int ret;
uint8_t portnum;
+ char path[PATH_MAX+1];

for (unsigned int i=0; i < strlen(port); i++)
if (!isdigit(port[i])) {
@@ -56,6 +58,13 @@ static int detach_port(char *port)
/* check max port */

portnum = atoi(port);
+
+ /* remove the port state file */
+
+ snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", portnum);
+
+ remove(path);
+ rmdir(VHCI_STATE_PATH);

ret = usbip_vhci_driver_open();
if (ret < 0) {
--
1.7.1


\
 
 \ /
  Last update: 2012-11-15 10:01    [W:0.069 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site