summaryrefslogtreecommitdiff
path: root/ubi-utils/src
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-04-22 14:32:08 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-04-22 17:27:54 +0300
commite4d974bb63355d1fff92eaae4df5f0cdf3597dc3 (patch)
treebfba4f78f412a479e14cada6908140173d1f8a91 /ubi-utils/src
parent3ec498778b26134f82bca32c0dc0a71befc48f29 (diff)
libubi: improve libubi_open interface
Remove the not very nice @required parameter, and add a possibility to distinguish between real errors and a situation when UBI is not present. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src')
-rw-r--r--ubi-utils/src/libubi.c7
-rw-r--r--ubi-utils/src/ubiattach.c7
-rw-r--r--ubi-utils/src/ubidetach.c7
-rw-r--r--ubi-utils/src/ubimkvol.c7
-rw-r--r--ubi-utils/src/ubinfo.c7
-rw-r--r--ubi-utils/src/ubirename.c7
-rw-r--r--ubi-utils/src/ubirmvol.c7
-rw-r--r--ubi-utils/src/ubiupdatevol.c9
8 files changed, 39 insertions, 19 deletions
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c
index f456a1d..d4b29b9 100644
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -507,7 +507,7 @@ int mtd_num2ubi_dev(libubi_t desc, int mtd_num, int *dev_num)
return -1;
}
-libubi_t libubi_open(int required)
+libubi_t libubi_open(void)
{
int fd, version;
struct libubi *lib;
@@ -531,9 +531,7 @@ libubi_t libubi_open(int required)
/* Make sure UBI is present */
fd = open(lib->sysfs_ubi, O_RDONLY);
if (fd == -1) {
- if (required)
- errmsg("cannot open \"%s\", UBI does not seem to "
- "exist in system", lib->sysfs_ubi);
+ errno = 0;
goto out_error;
}
@@ -945,6 +943,7 @@ int ubi_rnvols(libubi_t desc, const char *node, struct ubi_rnvol_req *rnvol)
{
int fd, ret;
+ desc = desc;
fd = open(node, O_RDONLY);
if (fd == -1)
return -1;
diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/src/ubiattach.c
index 1f72620..a935b42 100644
--- a/ubi-utils/src/ubiattach.c
+++ b/ubi-utils/src/ubiattach.c
@@ -153,9 +153,12 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- libubi = libubi_open(1);
- if (libubi == NULL)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
/*
* Make sure the kernel is fresh enough and this feature is supported.
diff --git a/ubi-utils/src/ubidetach.c b/ubi-utils/src/ubidetach.c
index 50670d0..83584cd 100644
--- a/ubi-utils/src/ubidetach.c
+++ b/ubi-utils/src/ubidetach.c
@@ -139,9 +139,12 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- libubi = libubi_open(1);
- if (libubi == NULL)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
/*
* Make sure the kernel is fresh enough and this feature is supported.
diff --git a/ubi-utils/src/ubimkvol.c b/ubi-utils/src/ubimkvol.c
index 8d6029a..dba7133 100644
--- a/ubi-utils/src/ubimkvol.c
+++ b/ubi-utils/src/ubimkvol.c
@@ -238,9 +238,12 @@ int main(int argc, char * const argv[])
if (err)
return err;
- libubi = libubi_open(1);
- if (!libubi)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
err = ubi_probe_node(libubi, args.node);
if (err == 2) {
diff --git a/ubi-utils/src/ubinfo.c b/ubi-utils/src/ubinfo.c
index 085691f..025ac62 100644
--- a/ubi-utils/src/ubinfo.c
+++ b/ubi-utils/src/ubinfo.c
@@ -364,9 +364,12 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- libubi = libubi_open(1);
- if (libubi == NULL)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
if (args.node) {
/*
diff --git a/ubi-utils/src/ubirename.c b/ubi-utils/src/ubirename.c
index 14331b6..08b3cd5 100644
--- a/ubi-utils/src/ubirename.c
+++ b/ubi-utils/src/ubirename.c
@@ -92,9 +92,12 @@ int main(int argc, char * const argv[])
}
node = argv[1];
- libubi = libubi_open(1);
- if (!libubi)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
err = ubi_probe_node(libubi, node);
if (err == 2) {
diff --git a/ubi-utils/src/ubirmvol.c b/ubi-utils/src/ubirmvol.c
index edb1b79..17aece4 100644
--- a/ubi-utils/src/ubirmvol.c
+++ b/ubi-utils/src/ubirmvol.c
@@ -180,9 +180,12 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- libubi = libubi_open(1);
- if (libubi == NULL)
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ return errmsg("UBI is not present in the system");
return sys_errmsg("cannot open libubi");
+ }
err = ubi_probe_node(libubi, args.node);
if (err == 2) {
diff --git a/ubi-utils/src/ubiupdatevol.c b/ubi-utils/src/ubiupdatevol.c
index a1e5a30..b160461 100644
--- a/ubi-utils/src/ubiupdatevol.c
+++ b/ubi-utils/src/ubiupdatevol.c
@@ -316,9 +316,12 @@ int main(int argc, char * const argv[])
if (err)
return -1;
- libubi = libubi_open(1);
- if (libubi == NULL) {
- sys_errmsg("cannot open libubi");
+ libubi = libubi_open();
+ if (!libubi) {
+ if (errno == 0)
+ errmsg("UBI is not present in the system");
+ else
+ sys_errmsg("cannot open libubi");
goto out_libubi;
}