Fix mkdebugfs.sh: * Add a simple usage * Add checking for the number of the parameters * Add the "regular empty file" and "fifo" file type * Set mode, uid and gid for the file * Save the command lines to a file and batch run them
[YOCTO #3848] Signed-off-by: Robert Yang <liezhi.y...@windriver.com> --- .../e2fsprogs/e2fsprogs/mkdebugfs.sh | 43 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdebugfs.sh b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdebugfs.sh index 41a13cb..88abc35 100644 --- a/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdebugfs.sh +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs/mkdebugfs.sh @@ -1,10 +1,25 @@ #!/bin/sh + +do_usage () { + cat << _EOF +Usage: mkdebugfs.sh <source> <device> +Create an ext2/ext3/ext4 filesystem from a directory or file + + source: The source directory or file + device: The target device + +_EOF + exit 1 +} + +[ $# -ne 2 ] && do_usage + SRCDIR=$1 DEVICE=$2 -DEBUGFS="debugfs/debugfs" - -yes | mkfs.ext4 test.img +DEBUGFS="debugfs" +CMD_FILE=`mktemp` +# Save the debugfs command lines to a file, then run them { CWD="/" find $SRCDIR | while read FILE; do @@ -26,7 +41,7 @@ yes | mkfs.ext4 test.img "directory") echo "mkdir $TGT" ;; - "regular file") + "regular file" | "regular empty file") echo "write $FILE $TGT" ;; "symbolic link") @@ -41,9 +56,27 @@ yes | mkfs.ext4 test.img DEVNO=$(stat -c "%t %T" $FILE) echo "mknod $TGT c $DEVNO" ;; + "fifo") + echo "mknod $TGT p" + ;; *) echo "Unknown file $FILE" 1>&2 ;; esac + + # Set the file mode + MY_MODE=$(stat -c "%f" $FILE) + echo "sif $TGT mode 0x$MY_MODE" + + # Set uid and gid + MY_UID=$(stat -c "%u" $FILE) + echo "sif $TGT uid $MY_UID" + MY_GID=$(stat -c "%g" $FILE) + echo "sif $TGT gid $MY_GID" done -} | $DEBUGFS -w -f /dev/stdin $DEVICE +} > $CMD_FILE + +# Run the command lines +$DEBUGFS -w -f $CMD_FILE $DEVICE + +rm -f $CMD_FILE -- 1.7.11.2 _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core