Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6bb8752 authored by Harvey Yang's avatar Harvey Yang Committed by Greg Kroah-Hartman
Browse files

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: default avatarHarvey Yang <harvey.huawei.yang@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2a38e6fc
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <sysfs/libsysfs.h>
#include <sysfs/libsysfs.h>


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


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


	portnum = atoi(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();
	ret = usbip_vhci_driver_open();
	if (ret < 0) {
	if (ret < 0) {
		err("open vhci_driver");
		err("open vhci_driver");