]> www.infradead.org Git - mtd-utils.git/commitdiff
libubi: do not use udevsettle
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 8 May 2009 09:33:56 +0000 (12:33 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 8 May 2009 09:33:56 +0000 (12:33 +0300)
Not sure why, but udevsettle does not work when threads are
used. In the io_paral test I experience the problem when
udevsettle opens UBI volumes and prevents tests to open
them (EBUSY is returned).

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/src/libubi.c

index 067f17e9a0501a3daab1bdd922d5e2342e53473b..167460c31794f55d82382799b541a15cd9ba922e 100644 (file)
@@ -695,8 +695,9 @@ int ubi_attach_mtd(libubi_t desc, const char *node,
        req->dev_num = r.ubi_num;
 
 #ifdef UDEV_SETTLE_HACK
-       if (system("udevsettle") == -1)
-               return -1;
+//     if (system("udevsettle") == -1)
+//             return -1;
+       usleep(100000);
 #endif
 
        return ret;
@@ -729,8 +730,9 @@ int ubi_remove_dev(libubi_t desc, const char *node, int ubi_dev)
                goto out_close;
 
 #ifdef UDEV_SETTLE_HACK
-       if (system("udevsettle") == -1)
-               return -1;
+//     if (system("udevsettle") == -1)
+//             return -1;
+       usleep(100000);
 #endif
 
 out_close:
@@ -899,19 +901,21 @@ int ubi_mkvol(libubi_t desc, const char *node, struct ubi_mkvol_request *req)
                return sys_errmsg("cannot open \"%s\"", node);
 
        ret = ioctl(fd, UBI_IOCMKVOL, &r);
-       if (ret == -1)
-               goto out_close;
+       if (ret == -1) {
+               close(fd);
+               return ret;
+       }
 
+       close(fd);
        req->vol_id = r.vol_id;
 
 #ifdef UDEV_SETTLE_HACK
-       if (system("udevsettle") == -1)
-               return -1;
+//     if (system("udevsettle") == -1)
+//             return -1;
+       usleep(100000);
 #endif
 
-out_close:
-       close(fd);
-       return ret;
+       return 0;
 }
 
 int ubi_rmvol(libubi_t desc, const char *node, int vol_id)
@@ -924,17 +928,20 @@ int ubi_rmvol(libubi_t desc, const char *node, int vol_id)
                return sys_errmsg("cannot open \"%s\"", node);
 
        ret = ioctl(fd, UBI_IOCRMVOL, &vol_id);
-       if (ret == -1)
-               goto out_close;
+       if (ret == -1) {
+               close(fd);
+               return ret;
+       }
+
+       close(fd);
 
 #ifdef UDEV_SETTLE_HACK
-       if (system("udevsettle") == -1)
-               return -1;
+//     if (system("udevsettle") == -1)
+//             return -1;
+       usleep(100000);
 #endif
 
-out_close:
-       close(fd);
-       return ret;
+       return 0;
 }
 
 int ubi_rnvols(libubi_t desc, const char *node, struct ubi_rnvol_req *rnvol)
@@ -945,18 +952,22 @@ int ubi_rnvols(libubi_t desc, const char *node, struct ubi_rnvol_req *rnvol)
        fd = open(node, O_RDONLY);
        if (fd == -1)
                return -1;
+
        ret = ioctl(fd, UBI_IOCRNVOL, rnvol);
-       if (ret == -1)
-               goto out_close;
+       if (ret == -1) {
+               close(fd);
+               return ret;
+       }
+
+       close(fd);
 
 #ifdef UDEV_SETTLE_HACK
-       if (system("udevsettle") == -1)
-               return -1;
+//     if (system("udevsettle") == -1)
+//             return -1;
+       usleep(100000);
 #endif
 
-out_close:
-       close(fd);
-       return ret;
+       return 0;
 }
 
 int ubi_rsvol(libubi_t desc, const char *node, int vol_id, long long bytes)