All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] mke2img: Sanity check block size and fail if zero or missing.
@ 2017-04-29 14:58 J Evans
  2017-04-29 16:02 ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: J Evans @ 2017-04-29 14:58 UTC (permalink / raw)
  To: buildroot

Signed-off-by: J Evans <g4@novadsp.com>
---
 package/mke2img/mke2img | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/package/mke2img/mke2img b/package/mke2img/mke2img
index b773aa9..0a3ed6c 100755
--- a/package/mke2img/mke2img
+++ b/package/mke2img/mke2img
@@ -39,10 +39,16 @@ main() {
 
     # Sanity checks
     if [ -z "${root_dir}" ]; then
-        error "you must specify a root directory with '-d'\n"
+        error "Error: you must specify a root directory with '-d'\n"
     fi
     if [ -z "${image}" ]; then
-        error "you must specify an output image file with '-o'\n"
+        error "Error: you must specify an output image file with '-o'\n"
+    fi
+    if [ -z "${nb_blocks}" ]; then
+        error "Error: you must specify a file system block count with '-b'. This cannot be zero, e.g. 61440 == 60MB\n"
+    fi
+    if [ "${nb_blocks}" -eq 0]; then
+        error "Error: The file system block count size cannot be zero. e.g. 61440 == 60MB \n"
     fi
     case "${gen}:${rev}" in
     2:0|2:1|3:1|4:1)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] mke2img: Sanity check block size and fail if zero or missing.
  2017-04-29 14:58 [Buildroot] [PATCH 1/1] mke2img: Sanity check block size and fail if zero or missing J Evans
@ 2017-04-29 16:02 ` Yann E. MORIN
  2017-04-29 17:08   ` g4 at novadsp.com
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2017-04-29 16:02 UTC (permalink / raw)
  To: buildroot

J, All,

On 2017-04-29 15:58 +0100, J Evans spake thusly:
> Signed-off-by: J Evans <g4@novadsp.com>
> ---
>  package/mke2img/mke2img | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/package/mke2img/mke2img b/package/mke2img/mke2img
> index b773aa9..0a3ed6c 100755
> --- a/package/mke2img/mke2img
> +++ b/package/mke2img/mke2img
> @@ -39,10 +39,16 @@ main() {
>  
>      # Sanity checks
>      if [ -z "${root_dir}" ]; then
> -        error "you must specify a root directory with '-d'\n"
> +        error "Error: you must specify a root directory with '-d'\n"
>      fi
>      if [ -z "${image}" ]; then
> -        error "you must specify an output image file with '-o'\n"
> +        error "Error: you must specify an output image file with '-o'\n"

Is that really necessary?

> +    fi
> +    if [ -z "${nb_blocks}" ]; then
> +        error "Error: you must specify a file system block count with '-b'. This cannot be zero, e.g. 61440 == 60MB\n"
> +    fi
> +    if [ "${nb_blocks}" -eq 0]; then

There is an obvious error here: there is a missing space between '0' and
the closing bracket ']'.

However, I wonder why we should check for a zero size. The filesystem
will be non-creatable (is that a word?) because the requested size is
too low, similar to what a user would get by settign the nb_blocks to
(e.g.) 1024 (i.e. 1MiB) but have a target/ that is 2MiB: that won't fit.

So, I would just keep the check to being set, whatever the value (but I
would not oppose the check against 0 either.)

Regards,
Yann E. MORIN.

> +        error "Error: The file system block count size cannot be zero. e.g. 61440 == 60MB \n"
>      fi
>      case "${gen}:${rev}" in
>      2:0|2:1|3:1|4:1)
> -- 
> 2.7.4
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] mke2img: Sanity check block size and fail if zero or missing.
  2017-04-29 16:02 ` Yann E. MORIN
@ 2017-04-29 17:08   ` g4 at novadsp.com
  0 siblings, 0 replies; 3+ messages in thread
From: g4 at novadsp.com @ 2017-04-29 17:08 UTC (permalink / raw)
  To: buildroot

Hello Yann,

> 
> >      # Sanity checks
> >      if [ -z "${root_dir}" ]; then
> > -        error "you must specify a root directory with '-d'\n"
> > +        error "Error: you must specify a root directory with '-d'\n"
> >      fi
> >      if [ -z "${image}" ]; then
> > -        error "you must specify an output image file with '-o'\n"
> > +        error "Error: you must specify an output image file with '-o'\n"
> 
> Is that really necessary?

The original justification was for any user calling the script directly. Now I think no, it is not.
 
> 
> There is an obvious error here: there is a missing space between '0' and the
> closing bracket ']'.

Indeed. <facepalm>
 
> However, I wonder why we should check for a zero size. The filesystem will
> be non-creatable (is that a word?) because the requested size is too low,
> similar to what a user would get by settign the nb_blocks to
> (e.g.) 1024 (i.e. 1MiB) but have a target/ that is 2MiB: that won't fit.
> 
> So, I would just keep the check to being set, whatever the value (but I would
> not oppose the check against 0 either.)

My revised version applies a check in the ext2.mk file itself. I think this is much cleaner.

Best,

Jerry.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-29 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-29 14:58 [Buildroot] [PATCH 1/1] mke2img: Sanity check block size and fail if zero or missing J Evans
2017-04-29 16:02 ` Yann E. MORIN
2017-04-29 17:08   ` g4 at novadsp.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.