diff options
author | Ilija Hadzic <ihadzic@research.bell-labs.com> | 2012-12-07 16:49:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-07 12:38:54 -0800 |
commit | 82692d202a199553a92d3c72cdd8959b497b9b62 (patch) | |
tree | 20bd33dcd559c6ac2dc5d7d63c26646545c01c73 /drivers/staging/usbip/userspace/src/usbip_attach.c | |
parent | 107fefd4dd56748878f1ffc44c321c29f6180748 (diff) |
staging: usbip: userspace: suppress a bogus error
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>
Diffstat (limited to 'drivers/staging/usbip/userspace/src/usbip_attach.c')
-rw-r--r-- | drivers/staging/usbip/userspace/src/usbip_attach.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index bdf61c0fe69..2da4e44e163 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -27,6 +27,7 @@ #include <fcntl.h> #include <getopt.h> #include <unistd.h> +#include <errno.h> #include "vhci_driver.h" #include "usbip_common.h" @@ -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); |