Skip to content

Commit

Permalink
staging: usbip: userspace: suppress a bogus error
Browse files Browse the repository at this point in the history
If mkdir() of VHCI_STATE_PATH fails because the directory
already exists, that's not an error. This patch fixes
annoying "record connection" errors that would typically
come up on attach.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Acked-by: David Chang <dchang@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ilija Hadzic authored and Greg Kroah-Hartman committed Jan 7, 2013
1 parent 107fefd commit 82692d2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/staging/usbip/userspace/src/usbip_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <fcntl.h>
#include <getopt.h>
#include <unistd.h>
#include <errno.h>

#include "vhci_driver.h"
#include "usbip_common.h"
Expand All @@ -52,8 +53,18 @@ static int record_connection(char *host, char *port, char *busid, int rhport)
int ret;

ret = mkdir(VHCI_STATE_PATH, 0700);
if (ret < 0)
return -1;
if (ret < 0) {
/* if VHCI_STATE_PATH exists, then it better be a directory */
if (errno == EEXIST) {
struct stat s;
ret = stat(VHCI_STATE_PATH, &s);
if (ret < 0)
return -1;
if (!(s.st_mode & S_IFDIR))
return -1;
} else
return -1;
}

snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);

Expand Down

0 comments on commit 82692d2

Please sign in to comment.