From: Harvey Yang Date: Thu, 15 Nov 2012 08:32:49 +0000 (+0800) Subject: usb: usbip: userspace: remove the port state file when detaching port. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a6bb87522f42aea056585282a70de7512d297323;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git usb: usbip: userspace: remove the port state file when detaching port. 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c b/drivers/staging/usbip/userspace/src/usbip_detach.c index 89bf3c195c28..dac5f065755a 100644 --- a/drivers/staging/usbip/userspace/src/usbip_detach.c +++ b/drivers/staging/usbip/userspace/src/usbip_detach.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -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])) { @@ -57,6 +59,13 @@ static int detach_port(char *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) { err("open vhci_driver");