]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: make sure only one volume is auto-resize
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 23 Apr 2008 15:13:04 +0000 (18:13 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 23 Apr 2008 15:13:04 +0000 (18:13 +0300)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/ubinize.c

index 8ba8869a824c2b825397cab3babed9a00bc04d86..1350d416950dab7fc370da57a6eb69b33c1ba187 100644 (file)
@@ -418,7 +418,7 @@ static void init_vol_info(const struct ubigen_info *ui,
 
 int main(int argc, char * const argv[])
 {
-       int err = -1, sects, i, volumes;
+       int err = -1, sects, i, volumes, autoresize_was_already = 0;
        struct ubigen_info ui;
        struct ubi_vtbl_record *vtbl;
        off_t seek;
@@ -502,6 +502,14 @@ int main(int argc, char * const argv[])
 
                verbose(args.verbose, "adding volume %d", vi.id);
 
+               /* Make sure only one volume has auto-resize flag */
+               if (vi.flags & UBI_VTBL_AUTORESIZE_FLG) {
+                       if (autoresize_was_already)
+                               return errmsg("only one volume is allowed "
+                                             "to have auto-resize flag");
+                       autoresize_was_already = 1;
+               }
+
                err = ubigen_add_volume(&ui, &vi, vtbl);
                if (err) {
                        errmsg("cannot add volume for section \"%s\"", sname);