* 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.
*/
/**
* 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.
* 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.
*/
return -1;
}
-libubi_t libubi_open(void)
+libubi_t libubi_open(int required)
{
int fd, version;
struct libubi *lib;
/* 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;
}
* 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.
*/
* @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;
if (err)
return -1;
- libubi = libubi_open();
+ libubi = libubi_open(1);
if (libubi == NULL)
return sys_errmsg("cannot open libubi");
if (err)
return -1;
- libubi = libubi_open();
+ libubi = libubi_open(1);
if (libubi == NULL)
return sys_errmsg("cannot open libubi");
if (err)
return err;
- libubi = libubi_open();
+ libubi = libubi_open(1);
if (!libubi)
return sys_errmsg("cannot open libubi");
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");
if (err)
return -1;
- libubi = libubi_open();
+ libubi = libubi_open(1);
if (libubi == NULL)
return sys_errmsg("cannot open libubi");
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;