ext2.mk: ensure file system block count is not zero (0)
PATCH 1/2 ext2.mk: ensure file system block count is not zero (0)
--- fs/ext2/ext2.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext2/ext2.mk +3 -1
@@ -6,7 +6,9 @@ EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV) -ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +$(error BR2_TARGET_ROOTFS_EXT2_BLOCKS cannot be zero (0)) +else EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endif
Signature · 1 line
2.7.4
PATCH 2/2 mke2img: add parameter sanity checks to prevent odd error messages from genext2.fs
--- package/mke2img/mke2img | 6 ++++++ 1 file changed, 6 insertions(+)
package/mke2img/mke2img +6 -0
@@ -44,6 +44,12 @@ main() { if [ -z "${image}" ]; then 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) ;;
Signature · 1 line
2.7.4
PATCH 2/2 mke2img: add parameter sanity checks to prevent odd error messages from genext2.fs
Hello,
package/mke2img/mke2img main() { · line 49
Quoted 3 lines · J Evans
package/mke2img/mke2img +3
-0+ 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
Check this is useless: there is already error checking done by getopt itself, because the -b option *must* have an argument. Indeed, the current mke2img behaves like this:
$ ./package/mke2img/mke2img -b mke2img: option 'b' expects a mandatory argument
So it is already checked that ${nb_blocks} cannot be empty.
package/mke2img/mke2img main() { · line 52
Quoted 3 lines
package/mke2img/mke2img +3
-0+ if [ "${nb_blocks}" -eq 0 ]; then + error "Error: The file system block count size cannot be zero. e.g. 61440 == 60MB \n" + fi
See my reply to the previous commit: I don't see why 0 should be checked specifically. Please explain in the commit log why it should be.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 2/2 mke2img: add parameter sanity checks to prevent odd error messages from genext2.fs
Thomas, All,
On 2017-04-29 21:06 +0200, Thomas Petazzoni spake thusly:
Quoted 6 lines
Hello,
Quoted 2 lines · J Evans
package/mke2img/mke2img +2
-0+ 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"
Really, just state that it must be specified, this the value is explained in the help text.
error "Error: you must specify a file system block count with '-b'.\n"
However, please also update the help text at the end of the script,m to remove a hint about auto calculation:
https://git.buildroot.org/buildroot/tree/package/mke2img/mke2img#n152
-b BLOCKS
Create a filesystem of BLOCKS 1024-byte blocs. The default is to compute the required number of blocks.
Quoted 10 lines
Quoted 1 line
+ fi
Check this is useless: there is already error checking done by getopt itself, because the -b option *must* have an argument. Indeed, the current mke2img behaves like this:
$ ./package/mke2img/mke2img -b mke2img: option 'b' expects a mandatory argumentSo it is already checked that ${nb_blocks} cannot be empty.
But if you don't pass the -b option, then nb_blocks *is* unset.
Adding the check is correct in my opinion.
Quoted 6 lines
package/mke2img/mke2img main() { · line 52
Quoted 3 lines
package/mke2img/mke2img +3
-0+ if [ "${nb_blocks}" -eq 0 ]; then + error "Error: The file system block count size cannot be zero. e.g. 61440 == 60MB \n" + fiSee my reply to the previous commit: I don't see why 0 should be checked specifically. Please explain in the commit log why it should be.
Agreed, a zero size is like specifying any size that is too small to fit the content of target/. There is no way we can check that the given size is correct.
zero if of course special, because we *know* it is incorrect. But since this is not the default value, the user would have explicitly set it to zero. Which is justa little tad stupid to begin with.
As I previously said: I really don't see the point of checking that the size is not zero.
Just keep the text tht nb_blocks is set, though, because it is required.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------^-------^------------------^--------------------'
PATCH 2/2 mke2img: add parameter sanity checks to prevent odd error messages from genext2.fs
Hello,
Quoted 8 lines · Yann E. MORIN
Quoted 4 lines
$ ./package/mke2img/mke2img -b mke2img: option 'b' expects a mandatory argumentSo it is already checked that ${nb_blocks} cannot be empty.
But if you don't pass the -b option, then
nb_blocks*is* unset.Adding the check is correct in my opinion.
Ah, yes agreed.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/2 ext2.mk: ensure file system block count is not zero (0)
In reply to J EvansHello,
fs/ext2/ext2.mk line 13
Quoted 6 lines · J Evans
fs/ext2/ext2.mk +3
-1-ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +$(error BR2_TARGET_ROOTFS_EXT2_BLOCKS cannot be zero (0)) +else EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endif
What is the motivation for checking that the size is not zero? Zero is like any other size too small to contain the target directory contents, so I don't see why we would add a specific check for it.
Your commit log unfortunately only explains *what* the commit is doing (which is obvious by reading the code) but not *why* this change is necessary.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/2 ext2.mk: ensure file system block count is not zero (0)
J, Thomas, All,
On 2017-04-29 21:03 +0200, Thomas Petazzoni spake thusly:
Quoted 12 lines · J Evans
fs/ext2/ext2.mk line 13
Quoted 7 lines
fs/ext2/ext2.mk +3
-1-ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0) +$(error BR2_TARGET_ROOTFS_EXT2_BLOCKS cannot be zero (0)) +else EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS) endifWhat is the motivation for checking that the size is not zero? Zero is like any other size too small to contain the target directory contents, so I don't see why we would add a specific check for it.
I agree, and that's exactly what I said in my review to the previous iteration of the patch.
Just remove the check and keep the line:
EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/2 ext2.mk: ensure file system block count is not zero (0)
Yann, all
Quoted 4 lines
Just remove the check and keep the line:
EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
Yes, ideal. That will satisfy us both and (most importantly) make sure the user cannot get this otherwise hard to debug error:
"genext2fs: Too many arguments. Try --help or else see the man page."
BTW many thanks for patience etc. with this shower of patches.
BR,
Jerry.