]> www.infradead.org Git - mtd-utils.git/commitdiff
Teach libubi_open not to prirnt error message
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 17 Apr 2008 12:53:35 +0000 (15:53 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 17 Apr 2008 12:53:35 +0000 (15:53 +0300)
... when it is expected that UBI is not necessarily present

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/include/libubi.h
ubi-utils/new-utils/src/libubi.c
ubi-utils/new-utils/src/libubi_int.h
ubi-utils/new-utils/src/libubigen.c
ubi-utils/new-utils/src/ubiattach.c
ubi-utils/new-utils/src/ubidetach.c
ubi-utils/new-utils/src/ubimkvol.c
ubi-utils/new-utils/src/ubinfo.c
ubi-utils/new-utils/src/ubirmvol.c
ubi-utils/new-utils/src/ubiupdatevol.c

index 7e0bfcdecdda170f3f21322ceaa8ef1f7a341fa9..3e8c55a2b16759677eea952ee30fe5d9afd072ce 100644 (file)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Author: Artem B. Bityutskiy
+ * Author: Artem Bityutskiy
  *
  * UBI (Unsorted Block Images) library.
  */
@@ -170,10 +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.
  */
-libubi_t libubi_open(void);
+libubi_t libubi_open(int required);
 
 /**
  * libubi_close - close UBI library.
index b53f18c0db92d3c41cd82d9f35cdc8cc4ffe4eb7..f0cbc9ec9298d855d416e0055226038552709cbc 100644 (file)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Author: Artem B. Bityutskiy
+ * Author: Artem Bityutskiy
  *
  * UBI (Unsorted Block Images) library.
  */
@@ -501,7 +501,7 @@ static int mtd_num2ubi_dev(struct libubi *lib, int mtd_num, int *dev_num)
        return -1;
 }
 
-libubi_t libubi_open(void)
+libubi_t libubi_open(int required)
 {
        int fd, version;
        struct libubi *lib;
@@ -530,8 +530,9 @@ libubi_t libubi_open(void)
        /* Make sure UBI is present */
        fd = open(lib->sysfs_ubi, O_RDONLY);
        if (fd == -1) {
-               errmsg("cannot open \"%s\", UBI does not seem to exist in system",
-                      lib->sysfs_ubi);
+               if (required)
+                       errmsg("cannot open \"%s\", UBI does not seem to "
+                              "exist in system", lib->sysfs_ubi);
                goto out_error;
        }
 
index dab3e6251f4cc5d8a1e2fd7d20738198f54f8108..f52797a49cb987aace4504d7d089581ac43150ce 100644 (file)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * Author: Artem B. Bityutskiy
+ * Author: Artem Bityutskiy
  *
  * UBI (Unsorted Block Images) library.
  */
index 34e2c0b06c7777bb638f255813859998b8eb11ae..bee6f77e2dced20088977fd171d408741b7c7e9c 100644 (file)
@@ -111,8 +111,8 @@ struct ubi_vtbl_record *ubigen_create_empty_vtbl(const struct ubigen_info *ui)
  * @vtbl.
  */
 int ubigen_add_volume(const struct ubigen_info *ui,
-                      const struct ubigen_vol_info *vi,
-                      struct ubi_vtbl_record *vtbl)
+                     const struct ubigen_vol_info *vi,
+                     struct ubi_vtbl_record *vtbl)
 {
        struct ubi_vtbl_record *vtbl_rec = &vtbl[vi->id];
        uint32_t tmp;
index b3d768a2f4796f6d4be75da8e2aa8201b0b1711d..04a2f9c447ed2bb865e545d29e2e09ac3470a0f1 100644 (file)
@@ -153,7 +153,7 @@ int main(int argc, char * const argv[])
        if (err)
                return -1;
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (libubi == NULL)
                return sys_errmsg("cannot open libubi");
 
index cd4836811e97991673a3d7f60f15a496c3f5a365..50670d05b8215f5fe552412f3972e512567dd4b4 100644 (file)
@@ -139,7 +139,7 @@ int main(int argc, char * const argv[])
        if (err)
                return -1;
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (libubi == NULL)
                return sys_errmsg("cannot open libubi");
 
index b99582cfde95e7af0e651c0c2a180dec3170272a..fd8c56852bc3ca59252e3411da66d610f8aaf570 100644 (file)
@@ -240,7 +240,7 @@ int main(int argc, char * const argv[])
        if (err)
                return err;
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (!libubi)
                return sys_errmsg("cannot open libubi");
 
index 185caae9643b0e5438465c946427b96b95bcc530..a71f087eabe84ef1e39165d455fb24618c53d93f 100644 (file)
@@ -366,7 +366,7 @@ int main(int argc, char * const argv[])
        if (!args.node && args.devn != -1)
                return errmsg("specify either device number or node file (use -h for help)");
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (libubi == NULL)
                return sys_errmsg("cannot open libubi");
 
index 5822aa079062a383e633187acdbac9c63481ad2e..10be9758f6fd2b1b348f6da4ddb72c3e5300fca5 100644 (file)
@@ -166,7 +166,7 @@ int main(int argc, char * const argv[])
        if (err)
                return -1;
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (libubi == NULL)
                return sys_errmsg("cannot open libubi");
 
index 5c67fc99bb74c2cd6883b1f50fc2931426ad7593..7748de84ab804b67be2b2a7ec34a837fdcd4142a 100644 (file)
@@ -295,7 +295,7 @@ int main(int argc, char * const argv[])
        if (!args.img && !args.truncate)
                return errmsg("incorrect arguments, use -h for help");
 
-       libubi = libubi_open();
+       libubi = libubi_open(1);
        if (libubi == NULL) {
                sys_errmsg("cannot open libubi");
                goto out_libubi;