fs/ext2: misc enhancements (branch yem/fs-vol-id)
cover fs/ext2: misc enhancements (branch yem/fs-vol-id)
Hello All!
This series enhances the fs/ext2 generation. Not much to say beside the individual commit logs... ;-)
Regards,
Yann E. MORIN.
The following changes since commit fcd720dfcf702d796fbc625b9abc4c06cb848d84:
Update for 2014.08 (2014-09-01 13:20:56 +0200)
are available in the git repository at:
git://ymorin.is-a-geek.org/buildroot yem/fs-vol-id
for you to fetch changes up to aef27eee3aa358ec0d07fd0e2a437a0f16a3b4b2:
fs/ext2: add support for specifying UUID (2014-09-01 14:28:12 +0200)
----------------------------------------------------------------
Yann E. MORIN (4):
fs/ext2: enhance option parsing in our genext2fs wrapper fs/ext2: pass the ext GEN and REV as options fs/ext2: add option to specify a filesystem label fs/ext2: add support for specifying UUID
fs/ext2/Config.in | 3 +++ fs/ext2/ext2.mk | 11 ++++++----- fs/ext2/genext2fs.sh | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 11 deletions(-)
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/4 fs/ext2: enhance option parsing in our genext2fs wrapper
In the following changesets, we are going to introduce new options to our genext2fs wrapper, but which are unknown to the real genext2fs. Thus, we need to filter those incompatible options out, so as not to confuse genext2fs.
We currently only skim over the existing options, and only add our own ontop of the existing ones.
Change this behaviour by regenerating a valid set of options, and get rid of the previous set passed to the wrapper. Also, do not carry the image filename in that new set of options, and pass it explicitly in the actual call to genext2fs.
This complexifies a bit the code, and is a no-op for now, but it will be used by the following changes.
--- fs/ext2/genext2fs.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
fs/ext2/genext2fs.sh +20 -4
@@ -9,16 +9,32 @@ CALC_INODES=1 EXT_OPTS= EXT_OPTS_O= +# Tell getopts to stop after all existing options, +# and not parse the ones we add +set -- "${@}" -- 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 ;; + # The following options are specific to our wrapper, + # so do not pass them to the real genext2fs. + # (none for now) + # Any other option is recognised by the real genext2fs, + # so we want to keep them. + b) CALC_BLOCKS=0 ;; + N) CALC_INODES=0; INODES=$OPTARG ;; + d) TARGET_DIR=$OPTARG ;; esac + # Append the option, and its arg if there's one + set -- "${@}" "-${f}" + if [ "${OPTARG+set}" = "set" ]; then + set -- "${@}" "${OPTARG}" + fi done eval IMG="\"\${${OPTIND}}\"" +# Get rid of all old options, up to and including our '--' marker +while [ "${1}" != "--" ]; do shift; done; shift + # calculate needed inodes if [ $CALC_INODES -eq 1 ]; then
@@ -117,5 +133,5 @@ if [ -n "${EXT_OPTS_O}" ]; then fi # Generate and upgrade the filesystem -genext2fs "$@" +genext2fs "$@" "${IMG}" e2tunefsck ${EXT_OPTS}
Signature · 1 line
1.9.1
PATCH 2/4 fs/ext2: pass the ext GEN and REV as options
In reply to Yann E. MORINNow that we do have a way to pass options to the wrapper, that are not options to the real genext2fs, use that mechanism to pass the generation and revision of ext filesystem to generate.
--- fs/ext2/ext2.mk | 7 ++----- fs/ext2/genext2fs.sh | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-)
fs/ext2/ext2.mk +2 -5
@@ -4,7 +4,7 @@ # ################################################################################ -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)
@@ -20,11 +20,8 @@ endif ROOTFS_EXT2_DEPENDENCIES = host-genext2fs host-e2fsprogs -EXT2_ENV = GEN=$(BR2_TARGET_ROOTFS_EXT2_GEN) -EXT2_ENV += REV=$(BR2_TARGET_ROOTFS_EXT2_REV) - define ROOTFS_EXT2_CMD - PATH=$(BR_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@ + PATH=$(BR_PATH) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@ endef rootfs-ext2-symlink:
fs/ext2/genext2fs.sh +8 -2
@@ -9,15 +9,21 @@ CALC_INODES=1 EXT_OPTS= EXT_OPTS_O= +# Backward compatibility +if [ -n "${GEN}" -o -n "${REV}" ]; then + printf "GEN and REV are now to be specified with the -G and -R options\n" >&2 +fi + # Tell getopts to stop after all existing options, # and not parse the ones we add set -- "${@}" -- -while getopts x:d:D:b:i:N:m:g:e:zfqUPhVv f +while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R: f do case $f in # The following options are specific to our wrapper, # so do not pass them to the real genext2fs. - # (none for now) + G) GEN=$OPTARG; continue ;; + R) REV=$OPTARG; continue ;; # Any other option is recognised by the real genext2fs, # so we want to keep them. b) CALC_BLOCKS=0 ;;
Signature · 1 line
1.9.1
PATCH 3/4 fs/ext2: add option to specify a filesystem label
In reply to Yann E. MORINFilesystems of the ext familly can carry a filesystem label. Add an option for the user to specify such a label.
--- fs/ext2/Config.in | 3 +++ fs/ext2/ext2.mk | 4 ++++ fs/ext2/genext2fs.sh | 9 ++++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
fs/ext2/Config.in +3 -0
@@ -42,6 +42,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
fs/ext2/ext2.mk +4 -0
@@ -18,6 +18,10 @@ ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0) EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) endif +ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_LABEL)),0) +EXT2_OPTS += -L $(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_LABEL)) +endif + ROOTFS_EXT2_DEPENDENCIES = host-genext2fs host-e2fsprogs define ROOTFS_EXT2_CMD
fs/ext2/genext2fs.sh +8 -1
@@ -8,6 +8,7 @@ CALC_BLOCKS=1 CALC_INODES=1 EXT_OPTS= EXT_OPTS_O= +LABEL= # Backward compatibility if [ -n "${GEN}" -o -n "${REV}" ]; then
@@ -17,13 +18,14 @@ fi # Tell getopts to stop after all existing options, # and not parse the ones we add set -- "${@}" -- -while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R: f +while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R:L: f do case $f in # The following options are specific to our wrapper, # so do not pass them to the real genext2fs. G) GEN=$OPTARG; continue ;; R) REV=$OPTARG; continue ;; + L) LABEL=$OPTARG; continue ;; # Any other option is recognised by the real genext2fs, # so we want to keep them. b) CALC_BLOCKS=0 ;;
@@ -133,6 +135,11 @@ if [ ${GEN} -ge 4 ]; then EXT_OPTS_O="${EXT_OPTS_O},extents,uninit_bg,dir_index" fi +# Set a label if specified +if [ -n "${LABEL}" ]; then + EXT_OPTS="${EXT_OPTS} -L ${LABEL}" +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#,}"
Signature · 1 line
1.9.1
PATCH 4/4 fs/ext2: add support for specifying UUID
In reply to Yann E. MORINSome post-image script might want to call our own genext2fs wrapper, instead of re-inventing their own wrapper. Also, such scripts may want to set a specific UUID to the newly generated filesystem.
Given how tricky the ext2/3/4 handling can be (remember our past bad experiences with it?), and given that we already have a proven, stable solution for generating ext2/3/4 filesystems, add a new option that allows external callers to specify the UUID, instead of letting tune2fs compute a random one, which is kept as the default behaviour if no UUID is specified.
--- fs/ext2/genext2fs.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext2/genext2fs.sh +4 -2
@@ -9,6 +9,7 @@ CALC_INODES=1 EXT_OPTS= EXT_OPTS_O= LABEL= +UUID=random # Backward compatibility if [ -n "${GEN}" -o -n "${REV}" ]; then
@@ -18,7 +19,7 @@ fi # Tell getopts to stop after all existing options, # and not parse the ones we add set -- "${@}" -- -while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R:L: f +while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R:L:u: f do case $f in # The following options are specific to our wrapper,
@@ -26,6 +27,7 @@ do G) GEN=$OPTARG; continue ;; R) REV=$OPTARG; continue ;; L) LABEL=$OPTARG; continue ;; + u) UUID=$OPTARG; continue ;; # Any other option is recognised by the real genext2fs, # so we want to keep them. b) CALC_BLOCKS=0 ;;
@@ -76,7 +78,7 @@ e2tunefsck() { # 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}" + tune2fs -U "${UUID}" "${IMG}" # Upgrade the filesystem if [ $# -ne 0 ]; then
Signature · 1 line
1.9.1