All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/3 v3] fs/ext2: misc enhancements (branch yem/fs-vol-id)
@ 2014-12-06 12:29 Yann E. MORIN
  2014-12-06 12:29 ` [Buildroot] [PATCH 1/3 v3] package/mke2img: new package Yann E. MORIN
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Yann E. MORIN @ 2014-12-06 12:29 UTC (permalink / raw
  To: buildroot

Hello All!

This series enhances the fs/ext2 generation.
Not much to say beside the individual commit logs... ;-)

Changes v2 -> v3:
  - fix quoting for labels with a space in them  (K?roly)

Changes v1 -> v2:
  - move our genext2fs.sh wrapper and make it a proper host package,
    with extensive tweaks to the code  (Thomas)

Regards,
Yann E. MORIN.


The following changes since commit c5f0e93d2cc6107cce249e1f11158aeccb4a3449:

  rp-pppoe: install default conf file (2014-12-03 23:26:21 +0100)

are available in the git repository at:

  git://git.busybox.net/~ymorin/git/buildroot yem/fs-vol-id

for you to fetch changes up to 0244e2c2f1c3933e110df8478544efafe66c7e5c:

  fs/ext2: add option to specify a filesystem label (2014-12-06 13:26:58 +0100)

----------------------------------------------------------------
Yann E. MORIN (3):
      package/mke2img: new package
      fs/ext2: use the new mke2img host package
      fs/ext2: add option to specify a filesystem label

 fs/ext2/Config.in              |   6 +-
 fs/ext2/ext2.mk                |  19 ++++--
 fs/ext2/genext2fs.sh           | 121 ---------------------------------
 package/Config.in.host         |   1 +
 package/mke2img/Config.in.host |   9 +++
 package/mke2img/mke2img        | 148 +++++++++++++++++++++++++++++++++++++++++
 package/mke2img/mke2img.mk     |  14 ++++
 7 files changed, 188 insertions(+), 130 deletions(-)
 delete mode 100755 fs/ext2/genext2fs.sh
 create mode 100644 package/mke2img/Config.in.host
 create mode 100755 package/mke2img/mke2img
 create mode 100644 package/mke2img/mke2img.mk

-- 
.-----------------.--------------------.------------------.--------------------.
|  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] 9+ messages in thread

* [Buildroot] [PATCH 1/3 v3] package/mke2img: new package
  2014-12-06 12:29 [Buildroot] [PATCH 0/3 v3] fs/ext2: misc enhancements (branch yem/fs-vol-id) Yann E. MORIN
@ 2014-12-06 12:29 ` Yann E. MORIN
  2014-12-06 18:20   ` Thomas Petazzoni
  2014-12-06 12:29 ` [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package Yann E. MORIN
  2014-12-06 12:29 ` [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label Yann E. MORIN
  2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2014-12-06 12:29 UTC (permalink / raw
  To: buildroot

Currently, we are using a shell script called genext2fs, that
impersonates the real genext2fs. But that script does much more than
just call genextfs: it also calls tune2fs and e2fsck.

Because it impersonates genext2fs, we can not easily add new options,
and are constrained by the genext2fs options.

But it turns out that, of all the options supported by the real
genext2fs, we only really care for a subset, namely:
  - number of blocks
  - number of inodes
  - percentage of blocks reeserved to root
  - the root directory which to generate the image from

So, we introduce a new host package, mke2img, that is intended to
eventually replace genext2fs.sh.

This new script is highly modeled from the existing genext2fs.sh, but
was slightly refreshed, and a new, supposedly sane set of options has
been choosen for the features we need (see above), and some new options
were added, too, rather than relying on the arguments order or
environment variables:
  -b <nb-blocks>    number of blocks in the filesystem
  -i <nb-inodes>    number of inodes in the filesystem
  -r <pc-reserved>  percentage of reserved blocks
* -d <root-dir>     directory containing the root of the filesystem
* -o <img-file>     output image file
* -G <ext-gen>      extfs generation: 2, 3, or 4
* -R <ext-rev>      ext2 revision: 0 or 1 (1 is assumed for ext3 and ext4)
  -l <label>        filesystem label
  -u <uid>          filesystem UUID; if not specified, a random one is used

* Mandatory options

Since the upstream e2fsprogs are expected to release a new mke2fs that
will be able to generate a filesystem image from a directory, we then
will be able to replace all the logic in mke2img, to use mke2fs instead
of the (relatively fragile) combination of the three tools we currently
use.

An entry is added for it in the "Host utilities" menu, so it can be
selected for use by post-{build,image} scripts. The ext2 filesystem
selection is changed to select that now.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Karoly Kasza <kaszak@gmail.com>
Reviewed-by: Karoly Kasza <kaszak@gmail.com>
---
 fs/ext2/Config.in              |   3 +-
 package/Config.in.host         |   1 +
 package/mke2img/Config.in.host |   9 +++
 package/mke2img/mke2img        | 148 +++++++++++++++++++++++++++++++++++++++++
 package/mke2img/mke2img.mk     |  14 ++++
 5 files changed, 173 insertions(+), 2 deletions(-)
 create mode 100644 package/mke2img/Config.in.host
 create mode 100755 package/mke2img/mke2img
 create mode 100644 package/mke2img/mke2img.mk

diff --git a/fs/ext2/Config.in b/fs/ext2/Config.in
index adba6f3..8751b62 100644
--- a/fs/ext2/Config.in
+++ b/fs/ext2/Config.in
@@ -1,7 +1,6 @@
 config BR2_TARGET_ROOTFS_EXT2
 	bool "ext2/3/4 root filesystem"
-	select BR2_PACKAGE_HOST_GENEXT2FS
-	select BR2_PACKAGE_HOST_E2FSPROGS
+	select BR2_PACKAGE_HOST_MKE2IMG
 	help
 	  Build an ext2/3/4 root filesystem
 
diff --git a/package/Config.in.host b/package/Config.in.host
index 185dcbc..0b7bc36 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -10,6 +10,7 @@ menu "Host utilities"
 	source "package/genimage/Config.in.host"
 	source "package/genpart/Config.in.host"
 	source "package/lpc3250loader/Config.in.host"
+	source "package/mke2img/Config.in.host"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
 	source "package/omap-u-boot-utils/Config.in.host"
diff --git a/package/mke2img/Config.in.host b/package/mke2img/Config.in.host
new file mode 100644
index 0000000..9781c6a
--- /dev/null
+++ b/package/mke2img/Config.in.host
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_HOST_MKE2IMG
+	bool "host mke2img"
+	select BR2_PACKAGE_HOST_E2FSPROGS
+	select BR2_PACKAGE_HOST_GENEXT2FS
+	help
+	  Easily create filesystems of the extend familly: ext2/3/4.
+
+	  This tool is bundled by, and specific to Buildroot. However, it can
+	  be used from post-images scripts is needed.
diff --git a/package/mke2img/mke2img b/package/mke2img/mke2img
new file mode 100755
index 0000000..98ac7e6
--- /dev/null
+++ b/package/mke2img/mke2img
@@ -0,0 +1,148 @@
+#!/bin/bash
+
+# Buildroot wrapper to the collection of ext2/3/4 filesystem tools:
+# - genext2fs, to generate ext2 filesystem images
+# - tune2fs, to modify an ext2/3/4 filesystem (possibly in an image file)
+# - e2fsck, to check and fix an ext2/3/4 filesystem (possibly in an image file)
+
+set -e
+
+main() {
+    local OPT OPTARG
+    local nb_blocks nb_inodes nb_res_blocks root_dir image gen rev label uuid
+    local -a genext2fs_opts
+    local -a tune2fs_opts
+    local tune2fs_O_opts
+
+    while getopts :b:i:r:d:o:G:R:l:u: OPT; do
+        case "${OPT}" in
+        b)  nb_blocks=${OPTARG};;
+        i)  nb_inodes=${OPTARG};;
+        r)  nb_res_blocks=${OPTARG};;
+        d)  root_dir="${OPTARG}";;
+        o)  image="${OPTARG}";;
+        G)  gen=${OPTARG};;
+        R)  rev=${OPTARG};;
+        l)  label="${OPTARG}";;
+        u)  uuid="${OPTARG}";;
+        :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
+        \?) error "unknown option '%s'\n" "${OPTARG}";;
+        esac
+    done
+
+    # Sanity checks
+    if [ -z "${root_dir}" ]; then
+        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"
+    fi
+    case "${gen}:${rev}" in
+    2:0|2:1|3:1|4:1)    ;;
+    *)  error "unknown ext generation '%s' and/or revision '%s'\n" \
+               "${gen}" "${rev}"
+        ;;
+    esac
+
+    # calculate needed inodes
+    if [ -z "${nb_inodes}" ]; then
+        nb_inodes=$(find "${root_dir}" | wc -l)
+        nb_inodes=$((nb_inodes+400))
+    fi
+
+    # calculate needed blocks
+    if [ -z "${nb_blocks}" ]; then
+        # size ~= superblock, block+inode bitmaps, inodes (8 per block),
+        # blocks; we scale inodes / blocks with 10% to compensate for
+        # bitmaps size + slack
+        nb_blocks=$(du -s -k "${root_dir}" |sed -r -e 's/[[:space:]]+.*$//')
+        nb_blocks=$((500+(nb_blocks+nb_inodes/8)*11/10))
+    fi
+
+    # Upgrade to rev1 if needed
+    if [ ${rev} -ge 1 ]; then
+        tune2fs_O_opts+=",filetype"
+    fi
+
+    # Add a journal for ext3 and above
+    if [ ${gen} -ge 3 ]; then
+        tune2fs_opts+=( -j -J size=1 )
+        # we add 1300 blocks (a bit more than 1 MiB, assuming 1KiB blocks)
+        # for the journal
+        # Note: I came to 1300 blocks after trial-and-error checks. YMMV.
+        nb_blocks=$((nb_blocks+1300))
+    fi
+
+    # Add ext4 specific features
+    if [ ${gen} -ge 4 ]; then
+        tune2fs_O_opts+=",extents,uninit_bg,dir_index"
+    fi
+
+    # Add our -O options (there will be at most one leading comma, remove it)
+    if [ -n "${tune2fs_O_opts}" ]; then
+        tune2fs_opts+=( -O "${tune2fs_O_opts#,}" )
+    fi
+
+    # Add the label if specified
+    if [ -n "${label}" ]; then
+        tune2fs_opts+=( -L "${label}" )
+    fi
+
+    # Generate the filesystem
+    genext2fs_opts=( -b ${nb_blocks} -N ${nb_inodes} -d "${root_dir}" )
+    if [ -n "${nb_res_blocks}" ]; then
+        genext2fs_opts+=( -m ${nb_res_blocks} )
+    fi
+    genext2fs "${genext2fs_opts[@]}" "${image}"
+
+    # genext2fs does not generate a UUID, but fsck will whine if one is
+    # is missing, so we need to add a UUID.
+    # Of course, this has to happend _before_ we run fsck.
+    # Also, some ext4 metadata are based on the UUID, so we must
+    # set it before we can convert the filesystem to ext4.
+    # If the user did not specify a UUID, we generate a random one.
+    # Although a random UUID may seem bad for reproducibility, there
+    # already are so many things that are not reproducible in a
+    # filesystem: file dates, file ordering, content of the files...
+    tune2fs -U "${uuid:-random}" "${image}"
+
+    # Upgrade the filesystem
+    if [ ${#tune2fs_opts[@]} -ne 0 ]; then
+        tune2fs "${tune2fs_opts[@]}" "${image}"
+    fi
+
+    # After changing filesystem options, running fsck is required
+    # (see: man tune2fs). Running e2fsck in other cases will ensure
+    # coherency of the filesystem, although it is not required.
+    # 'e2fsck -pDf' means:
+    #  - automatically repair
+    #  - optimise and check for duplicate entries
+    #  - force checking
+    # Sending output to oblivion, as e2fsck can be *very* verbose,
+    # especially with filesystems generated by genext2fs.
+    # Exit codes 1 & 2 are OK, it means fs errors were successfully
+    # corrected, hence our little trick with $ret.
+    ret=0
+    e2fsck -pDf "${image}" >/dev/null || ret=$?
+    case ${ret} in
+       0|1|2) ;;
+       *)   errorN ${ret} "failed to run e2fsck on '%s' (ext%d)\n" \
+                   "${image}" ${gen}
+    esac
+    printf "\n"
+    trace "e2fsck was successfully run on '%s' (ext%d)\n" "${image}" ${gen}
+    printf "\n"
+
+    # Remove count- and time-based checks, they are not welcome
+    # on embedded devices, where they can cause serious boot-time
+    # issues by tremendously slowing down the boot.
+    tune2fs -c 0 -i 0 "${image}"
+}
+
+trace()  { local msg="${1}"; shift; printf "%s: ${msg}" "${my_name}" "${@}"; }
+warn()   { trace "${@}" >&2; }
+errorN() { local ret="${1}"; shift; warn "${@}"; exit ${ret}; }
+error()  { errorN 1 "${@}"; }
+
+my_name="${0##*/}"
+main "$@"
diff --git a/package/mke2img/mke2img.mk b/package/mke2img/mke2img.mk
new file mode 100644
index 0000000..04aaa8f
--- /dev/null
+++ b/package/mke2img/mke2img.mk
@@ -0,0 +1,14 @@
+################################################################################
+#
+# mke2img
+#
+################################################################################
+
+HOST_MKE2IMG_SOURCE =
+HOST_MKE2IMG_DEPENDENCIES = host-genext2fs host-e2fsprogs
+
+define HOST_MKE2IMG_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 package/mke2img/mke2img $(HOST_DIR)/usr/bin/mke2img
+endef
+
+$(eval $(host-generic-package))
-- 
1.9.1

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

* [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package
  2014-12-06 12:29 [Buildroot] [PATCH 0/3 v3] fs/ext2: misc enhancements (branch yem/fs-vol-id) Yann E. MORIN
  2014-12-06 12:29 ` [Buildroot] [PATCH 1/3 v3] package/mke2img: new package Yann E. MORIN
@ 2014-12-06 12:29 ` Yann E. MORIN
  2014-12-06 18:21   ` Thomas Petazzoni
  2014-12-06 12:29 ` [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label Yann E. MORIN
  2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2014-12-06 12:29 UTC (permalink / raw
  To: buildroot

And get rid of the old genext2fs.sh wrapper.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Karoly Kasza <kaszak@gmail.com>
Reviewed-by: Karoly Kasza <kaszak@gmail.com>
---
 fs/ext2/ext2.mk      |  13 +++---
 fs/ext2/genext2fs.sh | 121 ---------------------------------------------------
 2 files changed, 5 insertions(+), 129 deletions(-)
 delete mode 100755 fs/ext2/genext2fs.sh

diff --git a/fs/ext2/ext2.mk b/fs/ext2/ext2.mk
index 425f7bf..96b7a4a 100644
--- a/fs/ext2/ext2.mk
+++ b/fs/ext2/ext2.mk
@@ -4,27 +4,24 @@
 #
 ################################################################################
 
-EXT2_OPTS :=
+EXT2_OPTS = -G $(BR2_TARGET_ROOTFS_EXT2_GEN) -R $(BR2_TARGET_ROOTFS_EXT2_REV)
 
 ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
 EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
 endif
 
 ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
-EXT2_OPTS += -N $(BR2_TARGET_ROOTFS_EXT2_INODES)
+EXT2_OPTS += -i $(BR2_TARGET_ROOTFS_EXT2_INODES)
 endif
 
 ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
-EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)
+EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)
 endif
 
-ROOTFS_EXT2_DEPENDENCIES = host-genext2fs host-e2fsprogs
-
-EXT2_ENV = GEN=$(BR2_TARGET_ROOTFS_EXT2_GEN)
-EXT2_ENV += REV=$(BR2_TARGET_ROOTFS_EXT2_REV)
+ROOTFS_EXT2_DEPENDENCIES = host-mke2img
 
 define ROOTFS_EXT2_CMD
-	PATH=$(BR_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@
+	PATH=$(BR_PATH) mke2img -d $(TARGET_DIR) $(EXT2_OPTS) -o $@
 endef
 
 rootfs-ext2-symlink:
diff --git a/fs/ext2/genext2fs.sh b/fs/ext2/genext2fs.sh
deleted file mode 100755
index 6f7b075..0000000
--- a/fs/ext2/genext2fs.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/sh
-# genext2fs wrapper calculating needed blocks/inodes values if not specified
-set -e
-
-export LC_ALL=C
-
-CALC_BLOCKS=1
-CALC_INODES=1
-EXT_OPTS=
-EXT_OPTS_O=
-
-while getopts x:d:D:b:i:N:m:g:e:zfqUPhVv f
-do
-    case $f in
-	b) CALC_BLOCKS=0 ;;
-	N) CALC_INODES=0; INODES=$OPTARG ;;
-	d) TARGET_DIR=$OPTARG ;;
-    esac
-done
-eval IMG="\"\${${OPTIND}}\""
-
-# calculate needed inodes
-if [ $CALC_INODES -eq 1 ];
-then
-    INODES=$(find $TARGET_DIR | wc -l)
-    INODES=$(expr $INODES + 400)
-    set -- $@ -N $INODES
-fi
-
-# calculate needed blocks
-if [ $CALC_BLOCKS -eq 1 ];
-then
-    # size ~= superblock, block+inode bitmaps, inodes (8 per block), blocks
-    # we scale inodes / blocks with 10% to compensate for bitmaps size + slack
-    BLOCKS=$(du -s -c -k $TARGET_DIR | grep total | sed -e "s/total//")
-    BLOCKS=$(expr 500 + \( $BLOCKS + $INODES / 8 \) \* 11 / 10)
-    # we add 1300 blocks (a bit more than 1 MiB, assuming 1KiB blocks) for
-    # the journal if ext3/4
-    # Note: I came to 1300 blocks after trial-and-error checks. YMMV.
-    if [ ${GEN} -ge 3 ]; then
-        BLOCKS=$(expr 1300 + $BLOCKS )
-    fi
-    set -- $@ -b $BLOCKS
-fi
-
-e2tunefsck() {
-    # genext2fs does not generate a UUID, but fsck will whine if one is
-    # is missing, so we need to add a UUID.
-    # Of course, this has to happend _before_ we run fsck.
-    # Also, some ext4 metadata are based on the UUID, so we must
-    # set it before we can convert the filesystem to ext4.
-    # Although a random UUID may seem bad for reproducibility, there
-    # already are so many things that are not reproducible in a
-    # filesystem: file dates, file ordering, content of the files...
-    tune2fs -U random "${IMG}"
-
-    # Upgrade the filesystem
-    if [ $# -ne 0 ]; then
-        tune2fs "$@" "${IMG}"
-    fi
-
-    # After changing filesystem options, running fsck is required
-    # (see: man tune2fs). Running e2fsck in other cases will ensure
-    # coherency of the filesystem, although it is not required.
-    # 'e2fsck -pDf' means:
-    #  - automatically repair
-    #  - optimise and check for duplicate entries
-    #  - force checking
-    # Sending output to oblivion, as e2fsck can be *very* verbose,
-    # especially with filesystems generated by genext2fs.
-    # Exit codes 1 & 2 are OK, it means fs errors were successfully
-    # corrected, hence our little trick with $ret.
-    ret=0
-    e2fsck -pDf "${IMG}" >/dev/null || ret=$?
-    case ${ret} in
-       0|1|2) ;;
-       *)   exit ${ret};;
-    esac
-    printf "\ne2fsck was successfully run on '%s' (ext%d)\n\n"  \
-           "${IMG##*/}" "${GEN}"
-
-    # Remove count- and time-based checks, they are not welcome
-    # on embedded devices, where they can cause serious boot-time
-    # issues by tremendously slowing down the boot.
-    tune2fs -c 0 -i 0 "${IMG}"
-}
-
-# Check we know what generation to generate
-case "${GEN}:${REV}" in
-    2:0|2:1|3:1|4:1)
-	;;
-    *)
-	printf "%s: unknown ext generation '%s' and/or revision '%s'\n" \
-	       "${0##*/}" "${GEN}" "${REV}" >&2
-	exit 1
-	;;
-esac
-
-# Upgrade to rev1 if needed
-if [ ${REV} -ge 1 ]; then
-    EXT_OPTS_O="${EXT_OPTS_O},filetype"
-fi
-
-# Add a journal for ext3 and above
-if [ ${GEN} -ge 3 ]; then
-    EXT_OPTS="${EXT_OPTS} -j -J size=1"
-fi
-
-# Add ext4 specific features
-if [ ${GEN} -ge 4 ]; then
-    EXT_OPTS_O="${EXT_OPTS_O},extents,uninit_bg,dir_index"
-fi
-
-# Add our -O options (there will be at most one leading comma, remove it)
-if [ -n "${EXT_OPTS_O}" ]; then
-    EXT_OPTS="${EXT_OPTS} -O ${EXT_OPTS_O#,}"
-fi
-
-# Generate and upgrade the filesystem
-genext2fs "$@"
-e2tunefsck ${EXT_OPTS}
-- 
1.9.1

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

* [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label
  2014-12-06 12:29 [Buildroot] [PATCH 0/3 v3] fs/ext2: misc enhancements (branch yem/fs-vol-id) Yann E. MORIN
  2014-12-06 12:29 ` [Buildroot] [PATCH 1/3 v3] package/mke2img: new package Yann E. MORIN
  2014-12-06 12:29 ` [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package Yann E. MORIN
@ 2014-12-06 12:29 ` Yann E. MORIN
  2014-12-06 14:15   ` Károly Kasza
  2014-12-06 18:23   ` Thomas Petazzoni
  2 siblings, 2 replies; 9+ messages in thread
From: Yann E. MORIN @ 2014-12-06 12:29 UTC (permalink / raw
  To: buildroot

Filesystems of the ext familly can carry a filesystem label.
Add an option for the user to specify such a label.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: K?roly Kasza <kaszak@gmail.com>

---
Changes v2 -> v3:
  - fix quoting for when the label contains a space  (K?roly)
---
 fs/ext2/Config.in | 3 +++
 fs/ext2/ext2.mk   | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/fs/ext2/Config.in b/fs/ext2/Config.in
index 8751b62..5b1cd0c 100644
--- a/fs/ext2/Config.in
+++ b/fs/ext2/Config.in
@@ -41,6 +41,9 @@ config BR2_TARGET_ROOTFS_EXT2_REV
 	default 0   if BR2_TARGET_ROOTFS_EXT2_2r0
 	default 1   if !BR2_TARGET_ROOTFS_EXT2_2r0
 
+config BR2_TARGET_ROOTFS_EXT2_LABEL
+	string "filesystem label"
+
 config BR2_TARGET_ROOTFS_EXT2_BLOCKS
 	int "size in blocks (leave at 0 for auto calculation)"
 	default 0
diff --git a/fs/ext2/ext2.mk b/fs/ext2/ext2.mk
index 96b7a4a..1cac72e 100644
--- a/fs/ext2/ext2.mk
+++ b/fs/ext2/ext2.mk
@@ -18,6 +18,14 @@ ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
 EXT2_OPTS += -r $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)
 endif
 
+# Not qstrip-ing the variable, because it may contain spaces, but we must
+# qstrip it when checking. Furthermore, we need to further quote it, so
+# that the quotes do not get eaten by the echo statement when creating the
+# fakeroot script
+ifneq ($(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_LABEL)),)
+EXT2_OPTS += -l '$(BR2_TARGET_ROOTFS_EXT2_LABEL)'
+endif
+
 ROOTFS_EXT2_DEPENDENCIES = host-mke2img
 
 define ROOTFS_EXT2_CMD
-- 
1.9.1

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

* [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label
  2014-12-06 12:29 ` [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label Yann E. MORIN
@ 2014-12-06 14:15   ` Károly Kasza
  2014-12-06 18:23   ` Thomas Petazzoni
  1 sibling, 0 replies; 9+ messages in thread
From: Károly Kasza @ 2014-12-06 14:15 UTC (permalink / raw
  To: buildroot

Hi Yann, Thomas, list,

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: K?roly Kasza <kaszak@gmail.com>
>

Tested-by: Karoly Kasza <kaszak@gmail.com>
Reviewed-by: Karoly Kasza <kaszak@gmail.com>

Tested the whole series of 3 together (v3), successfully built different
rootfs.ext images and booted them.
Tested with master branch, x86_64 arch in QEMU, internal toolchain GCC
4.9.2 w/ uclibc, Linux 3.17.4.

Regards,
Karoly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20141206/dd6f609b/attachment.html>

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

* [Buildroot] [PATCH 1/3 v3] package/mke2img: new package
  2014-12-06 12:29 ` [Buildroot] [PATCH 1/3 v3] package/mke2img: new package Yann E. MORIN
@ 2014-12-06 18:20   ` Thomas Petazzoni
  2014-12-06 19:26     ` Yann E. MORIN
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2014-12-06 18:20 UTC (permalink / raw
  To: buildroot

Dear Yann E. MORIN,

On Sat,  6 Dec 2014 13:29:44 +0100, Yann E. MORIN wrote:

> This new script is highly modeled from the existing genext2fs.sh, but
> was slightly refreshed, and a new, supposedly sane set of options has
> been choosen for the features we need (see above), and some new options
> were added, too, rather than relying on the arguments order or
> environment variables:
>   -b <nb-blocks>    number of blocks in the filesystem
>   -i <nb-inodes>    number of inodes in the filesystem
>   -r <pc-reserved>  percentage of reserved blocks
> * -d <root-dir>     directory containing the root of the filesystem
> * -o <img-file>     output image file
> * -G <ext-gen>      extfs generation: 2, 3, or 4
> * -R <ext-rev>      ext2 revision: 0 or 1 (1 is assumed for ext3 and ext4)
>   -l <label>        filesystem label
>   -u <uid>          filesystem UUID; if not specified, a random one is used
> 
> * Mandatory options

What about putting this in a "help" of the mke2img tool, or at least in
the comment header at the beginning of the script?

> +    # genext2fs does not generate a UUID, but fsck will whine if one is
> +    # is missing, so we need to add a UUID.

duplicate "is".

> +    # Of course, this has to happend _before_ we run fsck.

happend -> happen

> +    # Also, some ext4 metadata are based on the UUID, so we must
> +    # set it before we can convert the filesystem to ext4.
> +    # If the user did not specify a UUID, we generate a random one.
> +    # Although a random UUID may seem bad for reproducibility, there
> +    # already are so many things that are not reproducible in a

s/already are/are already/

Other than that, looks good.

Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

 (on x86-64 in qemu, tested an ext4 filesystem with only the ext4
 kernel driver compiled in, and then tested an ext2 filesystem with
 only the ext2 kernel driver compiled in).

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package
  2014-12-06 12:29 ` [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package Yann E. MORIN
@ 2014-12-06 18:21   ` Thomas Petazzoni
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2014-12-06 18:21 UTC (permalink / raw
  To: buildroot

Dear Yann E. MORIN,

On Sat,  6 Dec 2014 13:29:45 +0100, Yann E. MORIN wrote:
> And get rid of the old genext2fs.sh wrapper.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Tested-by: Karoly Kasza <kaszak@gmail.com>
> Reviewed-by: Karoly Kasza <kaszak@gmail.com>
> ---
>  fs/ext2/ext2.mk      |  13 +++---
>  fs/ext2/genext2fs.sh | 121 ---------------------------------------------------
>  2 files changed, 5 insertions(+), 129 deletions(-)
>  delete mode 100755 fs/ext2/genext2fs.sh

Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

 (on x86-64 in qemu, tested an ext4 filesystem with only the ext4
 kernel driver compiled in, and then tested an ext2 filesystem with
 only the ext2 kernel driver compiled in).

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label
  2014-12-06 12:29 ` [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label Yann E. MORIN
  2014-12-06 14:15   ` Károly Kasza
@ 2014-12-06 18:23   ` Thomas Petazzoni
  1 sibling, 0 replies; 9+ messages in thread
From: Thomas Petazzoni @ 2014-12-06 18:23 UTC (permalink / raw
  To: buildroot

Dear Yann E. MORIN,

On Sat,  6 Dec 2014 13:29:46 +0100, Yann E. MORIN wrote:
> Filesystems of the ext familly can carry a filesystem label.
> Add an option for the user to specify such a label.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: K?roly Kasza <kaszak@gmail.com>

Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

 (on x86-64 in qemu, tested an ext4 filesystem with only the ext4
 kernel driver compiled in, and then tested an ext2 filesystem with
 only the ext2 kernel driver compiled in).

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 1/3 v3] package/mke2img: new package
  2014-12-06 18:20   ` Thomas Petazzoni
@ 2014-12-06 19:26     ` Yann E. MORIN
  0 siblings, 0 replies; 9+ messages in thread
From: Yann E. MORIN @ 2014-12-06 19:26 UTC (permalink / raw
  To: buildroot

Thomas, All,

On 2014-12-06 19:20 +0100, Thomas Petazzoni spake thusly:
> On Sat,  6 Dec 2014 13:29:44 +0100, Yann E. MORIN wrote:
> > This new script is highly modeled from the existing genext2fs.sh, but
> > was slightly refreshed, and a new, supposedly sane set of options has
> > been choosen for the features we need (see above), and some new options
> > were added, too, rather than relying on the arguments order or
> > environment variables:
> >   -b <nb-blocks>    number of blocks in the filesystem
> >   -i <nb-inodes>    number of inodes in the filesystem
> >   -r <pc-reserved>  percentage of reserved blocks
> > * -d <root-dir>     directory containing the root of the filesystem
> > * -o <img-file>     output image file
> > * -G <ext-gen>      extfs generation: 2, 3, or 4
> > * -R <ext-rev>      ext2 revision: 0 or 1 (1 is assumed for ext3 and ext4)
> >   -l <label>        filesystem label
> >   -u <uid>          filesystem UUID; if not specified, a random one is used
> > 
> > * Mandatory options
> 
> What about putting this in a "help" of the mke2img tool, or at least in
> the comment header at the beginning of the script?

Ack.

> > +    # genext2fs does not generate a UUID, but fsck will whine if one is
> > +    # is missing, so we need to add a UUID.
> 
> duplicate "is".

Ack.

> > +    # Of course, this has to happend _before_ we run fsck.
> 
> happend -> happen

Ack.

> > +    # Also, some ext4 metadata are based on the UUID, so we must
> > +    # set it before we can convert the filesystem to ext4.
> > +    # If the user did not specify a UUID, we generate a random one.
> > +    # Although a random UUID may seem bad for reproducibility, there
> > +    # already are so many things that are not reproducible in a
> 
> s/already are/are already/

Nak. Positioning adverbs before the verb is a way emphasise the effects
of the adverb. See for instance:
    https://learnenglish.britishcouncil.org/en/english-grammar/adverbials/where-they-go-sentence

    [...]
    But if we want to emphasise an adverbial we can put it at the
    beginning of a clause
    [...]

> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Thanks! I'll fix and respin later.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  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] 9+ messages in thread

end of thread, other threads:[~2014-12-06 19:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 12:29 [Buildroot] [PATCH 0/3 v3] fs/ext2: misc enhancements (branch yem/fs-vol-id) Yann E. MORIN
2014-12-06 12:29 ` [Buildroot] [PATCH 1/3 v3] package/mke2img: new package Yann E. MORIN
2014-12-06 18:20   ` Thomas Petazzoni
2014-12-06 19:26     ` Yann E. MORIN
2014-12-06 12:29 ` [Buildroot] [PATCH 2/3 v3] fs/ext2: use the new mke2img host package Yann E. MORIN
2014-12-06 18:21   ` Thomas Petazzoni
2014-12-06 12:29 ` [Buildroot] [PATCH 3/3 v3] fs/ext2: add option to specify a filesystem label Yann E. MORIN
2014-12-06 14:15   ` Károly Kasza
2014-12-06 18:23   ` Thomas Petazzoni

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.