From a8b8fd5698e971a05a8a64e69ea5d5878c5f1c2a Mon Sep 17 00:00:00 2001 From: Ilija Hadzic Date: Fri, 7 Dec 2012 16:49:44 -0500 Subject: [PATCH] --- yaml --- r: 353887 b: refs/heads/master c: 82692d202a199553a92d3c72cdd8959b497b9b62 h: refs/heads/master i: 353885: 3221a78735ec16a90a9cd26f25f3454a7c40b911 353883: 35d5f91a781974e327dea687057d2c493a3d8930 353879: 241a2e5bd8d2159d1a9475928c0e455c1b6b4225 353871: 3b1ffb7efa8995f947e0010e1fbd297dac0b6cb4 353855: e866539bdbfb5ffc0884d75657abe8c1927b6b6a v: v3 --- [refs] | 2 +- .../staging/usbip/userspace/src/usbip_attach.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 8a7460b97e33..8343a586c6ae 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 107fefd4dd56748878f1ffc44c321c29f6180748 +refs/heads/master: 82692d202a199553a92d3c72cdd8959b497b9b62 diff --git a/trunk/drivers/staging/usbip/userspace/src/usbip_attach.c b/trunk/drivers/staging/usbip/userspace/src/usbip_attach.c index bdf61c0fe699..2da4e44e1633 100644 --- a/trunk/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/trunk/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -27,6 +27,7 @@ #include #include #include +#include #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);