public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Romain Izard <romain.izard.pro@gmail.com>
To: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Cc: linux-mtd@lists.infradead.org, Romain Izard <romain.izard.pro@gmail.com>
Subject: [PATCH] mkfs.ubifs: Only require 17 LEBs
Date: Wed,  5 Jul 2017 18:34:11 +0200	[thread overview]
Message-ID: <20170705163411.23546-1-romain.izard.pro@gmail.com> (raw)

The minimum size for a UBIFS volume is 17 LEBs. As mkfs.ubifs counted
the reserved log and orphan blocks twice, the program did not allow
such a small volume.

Fix the calculations to be able to build an image with 17 LEBs. With
this, the following command works:

mkfs.ubifs -c 17 -l2 -m 2048 -e 124KiB -o small.ubifs

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
---
 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 9e69a4f..ba0293c 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -331,6 +331,9 @@ static long long add_space_overhead(long long size)
         return size / divisor;
 }
 
+#define UBIFS_MIN_LEB_NOLOG   (UBIFS_MIN_LEB_CNT - UBIFS_MIN_LOG_LEBS)
+#define UBIFS_MIN_LEB_NOORPH  (UBIFS_MIN_LEB_CNT - UBIFS_MIN_ORPH_LEBS)
+
 static int validate_options(void)
 {
 	int tmp;
@@ -372,15 +375,15 @@ static int validate_options(void)
 	if (c->log_lebs < UBIFS_MIN_LOG_LEBS)
 		return err_msg("too few log LEBs, minimum is %d",
 			       UBIFS_MIN_LOG_LEBS);
-	if (c->log_lebs >= c->max_leb_cnt - UBIFS_MIN_LEB_CNT)
+	if (c->log_lebs > c->max_leb_cnt - UBIFS_MIN_LEB_NOLOG)
 		return err_msg("too many log LEBs, maximum is %d",
-			       c->max_leb_cnt - UBIFS_MIN_LEB_CNT);
+			       c->max_leb_cnt - UBIFS_MIN_LEB_NOLOG);
 	if (c->orph_lebs < UBIFS_MIN_ORPH_LEBS)
 		return err_msg("too few orphan LEBs, minimum is %d",
 			       UBIFS_MIN_ORPH_LEBS);
-	if (c->orph_lebs >= c->max_leb_cnt - UBIFS_MIN_LEB_CNT)
+	if (c->orph_lebs > c->max_leb_cnt - UBIFS_MIN_LEB_NOORPH)
 		return err_msg("too many orphan LEBs, maximum is %d",
-			       c->max_leb_cnt - UBIFS_MIN_LEB_CNT);
+			       c->max_leb_cnt - UBIFS_MIN_LEB_NOORPH);
 	tmp = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs + c->lpt_lebs;
 	tmp += c->orph_lebs + 4;
 	if (tmp > c->max_leb_cnt)
-- 
2.11.0

             reply	other threads:[~2017-07-05 16:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 16:34 Romain Izard [this message]
2017-07-06  6:46 ` [PATCH] mkfs.ubifs: Only require 17 LEBs Artem Bityutskiy
2017-07-06  7:57   ` Romain Izard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170705163411.23546-1-romain.izard.pro@gmail.com \
    --to=romain.izard.pro@gmail.com \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox