summaryrefslogtreecommitdiff
path: root/ubi-utils/src
diff options
context:
space:
mode:
authorAlexander Schmidt <alexs@linux.vnet.ibm.com>2007-02-28 10:29:34 +0100
committerJosh Boyer <jwboyer@gmail.com>2007-03-14 12:34:42 -0500
commit8bc5349626f1a83f49dd400ca6f45e0bb8347a4e (patch)
tree8e358dcd399f25a62be06799f7c67b2a7741a064 /ubi-utils/src
parent65561f4974a21d0d9f02ba359522fa2d539f4142 (diff)
UBI Tools - problem with multiple ubi devices.
Fix problem with multiple ubi devices Signed-off-by: Alexander Schmidt <alexs@linux.vnet.ibm.com> Signed-off-by: Josh Boyer <jwboyer@gmail.com>
Diffstat (limited to 'ubi-utils/src')
-rw-r--r--ubi-utils/src/libubi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c
index 7cb74bf..62216ad 100644
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -138,7 +138,7 @@ static int
get_ubi_info(ubi_lib_t desc, struct ubi_info *ubi)
{
int err;
- int n = 1;
+ int dev_count = 0;
char *path;
struct stat stat;
@@ -147,31 +147,31 @@ get_ubi_info(ubi_lib_t desc, struct ubi_info *ubi)
return -1;
/* Calculate number of UBI devices */
- do {
+ while (!err) {
char dir[20];
- sprintf(&dir[0], "ubi%d", n);
- path = mkpath(desc->sysfs_root, dir);
+ sprintf(&dir[0], "ubi%d", dev_count);
+ path = mkpath(desc->ubi_root, dir);
if (!path)
return ENOMEM;
err = lstat(path, &stat);
if (err == 0)
- n += 1;
+ dev_count += 1;
free(path);
- } while (err == 0);
+ }
if (errno != ENOENT)
return -1;
- if (n == 0) {
+ if (dev_count == 0) {
ubi_err("no UBI devices found");
errno = EINVAL;
return -1;
}
errno = 0;
- ubi->dev_count = n;
+ ubi->dev_count = dev_count;
return 0;
}