diff options
Diffstat (limited to 'ubi-utils')
-rw-r--r-- | ubi-utils/include/libubi.h | 8 | ||||
-rw-r--r-- | ubi-utils/src/libubi.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubiattach.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubidetach.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubimkvol.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubinfo.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubirename.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubirmvol.c | 7 | ||||
-rw-r--r-- | ubi-utils/src/ubiupdatevol.c | 9 |
9 files changed, 43 insertions, 23 deletions
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h index 71a78a3..bc3404c 100644 --- a/ubi-utils/include/libubi.h +++ b/ubi-utils/include/libubi.h @@ -170,13 +170,13 @@ struct ubi_vol_info /** * libubi_open - open UBI library. - * @required: if non-zero, libubi will print an error messages if this UBI is - * not present in the system * * This function initializes and opens the UBI library and returns UBI library - * descriptor in case of success and %NULL in case of failure. + * descriptor in case of success and %NULL in case of failure. In case of + * failure, errno contains the error code or zero if UBI is not present in the + * system. */ -libubi_t libubi_open(int required); +libubi_t libubi_open(void); /** * libubi_close - close UBI library. 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; } |