usbip: tools: change to use new error codes in server reply messages
Changed usbip_network, usbip_attach, usbip_list, and usbipd to use and propagate the new error codes in server reply messages. usbip_net_recv_op_common() is changed to take a pointer to status return the status returned in the op_common.status to callers. usbip_attach and usbip_list use the common interface to print error messages to indicate why the request failed. With this change the messages say why a request failed: - when a client requests a device that is already exported: usbip attach -r server_name -b 3-10.2 usbip: error: Attach Request for 3-10.2 failed - Device busy (exported) - when a client requests a device that isn't exportable, usbip attach -r server_name -b 3-10.4 usbip: error: Attach Request for 3-10.4 failed - Device not found Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
c207a10d2f
commit
ad81b15d56
@@ -135,6 +135,7 @@ static int query_import_device(int sockfd, char *busid)
|
||||
struct op_import_request request;
|
||||
struct op_import_reply reply;
|
||||
uint16_t code = OP_REP_IMPORT;
|
||||
int status;
|
||||
|
||||
memset(&request, 0, sizeof(request));
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
@@ -157,9 +158,10 @@ static int query_import_device(int sockfd, char *busid)
|
||||
}
|
||||
|
||||
/* receive a reply */
|
||||
rc = usbip_net_recv_op_common(sockfd, &code);
|
||||
rc = usbip_net_recv_op_common(sockfd, &code, &status);
|
||||
if (rc < 0) {
|
||||
err("recv op_common");
|
||||
err("Attach Request for %s failed - %s\n",
|
||||
busid, usbip_op_common_status_string(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -194,11 +196,8 @@ static int attach_device(char *host, char *busid)
|
||||
}
|
||||
|
||||
rhport = query_import_device(sockfd, busid);
|
||||
if (rhport < 0) {
|
||||
err("Attach request for Device %s. Is this device exported?",
|
||||
busid);
|
||||
if (rhport < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(sockfd);
|
||||
|
||||
|
Reference in New Issue
Block a user