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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
#include <sysfs/libsysfs.h>
#include <ctype.h>
+#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
{
int ret;
uint8_t portnum;
+ char path[PATH_MAX+1];
for (unsigned int i=0; i < strlen(port); i++)
if (!isdigit(port[i])) {
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");