diff options
| author | Chen Qi <Qi.Chen@windriver.com> | 2014-07-08 18:38:15 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-07-08 16:09:58 +0100 |
| commit | c4a539c8c85b16237a865d31549748a398de62d3 (patch) | |
| tree | acf1225dead90248844175ddee7c723ac8719e38 | |
| parent | 845df01345e166b9f9921514cea3a4f1274023a1 (diff) | |
| download | poky-c4a539c8c85b16237a865d31549748a398de62d3.tar.gz | |
populate-extfs.sh: fix to handle special file names correctly
`debugfs' treats spaces and "" specially. So when we are dealing with
file names, great care should be taken to make sure that `debugfs'
recognizes file names correctly.
The basic solution here is:
1. Use quotation marks to handle spaces correctly.
2. Replace "xxx" with ""xxx"" so that debugfs knows that the quotation
marks are parts of the file name.
[YOCTO #6503]
(From OE-Core rev: 24f17607e996c499c8f86eda0588d02af1e960b9)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh index 47f5b5b237..a1808b3b3f 100644 --- a/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh +++ b/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/populate-extfs.sh | |||
| @@ -30,8 +30,41 @@ DEBUGFS="debugfs" | |||
| 30 | 30 | ||
| 31 | DIR="$(dirname "$DIR")" | 31 | DIR="$(dirname "$DIR")" |
| 32 | 32 | ||
| 33 | # debugfs handles the quotation mark differently from other special marks like { | ||
| 34 | # If FILE contains quotation marks in its name, then we have to replace " with "" | ||
| 35 | # so that debugfs could correclty recognize them. In this script, we use the prefix | ||
| 36 | # of D_ to denote the file names that should be used by debugfs. | ||
| 37 | # | ||
| 38 | # The usage of case statements here is to avoid performace impact. | ||
| 39 | case $FILE in | ||
| 40 | *\"*) | ||
| 41 | D_FILE="$(echo $FILE | sed -e 's#\"#\"\"#g')" | ||
| 42 | ;; | ||
| 43 | *) | ||
| 44 | D_FILE="$FILE" | ||
| 45 | ;; | ||
| 46 | esac | ||
| 47 | |||
| 48 | case $DIR in | ||
| 49 | *\"*) | ||
| 50 | D_DIR="$(echo $DIR | sed -e 's#\"#\"\"#g')" | ||
| 51 | ;; | ||
| 52 | *) | ||
| 53 | D_DIR="$DIR" | ||
| 54 | ;; | ||
| 55 | esac | ||
| 56 | |||
| 57 | case $TGT in | ||
| 58 | *\"*) | ||
| 59 | D_TGT="$(echo $TGT | sed -e 's#\"#\"\"#g')" | ||
| 60 | ;; | ||
| 61 | *) | ||
| 62 | D_TGT="$TGT" | ||
| 63 | ;; | ||
| 64 | esac | ||
| 65 | |||
| 33 | if [ "$DIR" != "$CWD" ]; then | 66 | if [ "$DIR" != "$CWD" ]; then |
| 34 | echo "cd $DIR" | 67 | echo "cd \"$D_DIR\"" |
| 35 | CWD="$DIR" | 68 | CWD="$DIR" |
| 36 | fi | 69 | fi |
| 37 | 70 | ||
| @@ -41,23 +74,24 @@ DEBUGFS="debugfs" | |||
| 41 | 74 | ||
| 42 | case $TYPE in | 75 | case $TYPE in |
| 43 | "directory") | 76 | "directory") |
| 44 | echo "mkdir $TGT" | 77 | echo "mkdir \"$D_TGT\"" |
| 45 | ;; | 78 | ;; |
| 46 | "regular file" | "regular empty file") | 79 | "regular file" | "regular empty file") |
| 47 | echo "write \"$FILE\" \"$TGT\"" | 80 | echo "write \"$D_FILE\" \"$D_TGT\"" |
| 48 | ;; | 81 | ;; |
| 49 | "symbolic link") | 82 | "symbolic link") |
| 50 | LINK_TGT=$(readlink "$FILE") | 83 | LINK_TGT=$(readlink "$FILE") |
| 51 | echo "symlink \"$TGT\" \"$LINK_TGT\"" | 84 | D_LINK_TGT="$(echo $LINK_TGT | sed -e 's#\"#\"\"#g')" |
| 85 | echo "symlink \"$D_TGT\" \"$D_LINK_TGT\"" | ||
| 52 | ;; | 86 | ;; |
| 53 | "block special file") | 87 | "block special file") |
| 54 | echo "mknod \"$TGT\" b $DEVNO" | 88 | echo "mknod \"$D_TGT\" b $DEVNO" |
| 55 | ;; | 89 | ;; |
| 56 | "character special file") | 90 | "character special file") |
| 57 | echo "mknod \"$TGT\" c $DEVNO" | 91 | echo "mknod \"$D_TGT\" c $DEVNO" |
| 58 | ;; | 92 | ;; |
| 59 | "fifo") | 93 | "fifo") |
| 60 | echo "mknod \"$TGT\" p" | 94 | echo "mknod \"$D_TGT\" p" |
| 61 | ;; | 95 | ;; |
| 62 | *) | 96 | *) |
| 63 | echo "Unknown/unhandled file type '$TYPE' file: $FILE" 1>&2 | 97 | echo "Unknown/unhandled file type '$TYPE' file: $FILE" 1>&2 |
| @@ -65,19 +99,19 @@ DEBUGFS="debugfs" | |||
| 65 | esac | 99 | esac |
| 66 | 100 | ||
| 67 | # Set the file mode | 101 | # Set the file mode |
| 68 | echo "sif \"$TGT\" mode 0x$MODE" | 102 | echo "sif \"$D_TGT\" mode 0x$MODE" |
| 69 | 103 | ||
| 70 | # Set uid and gid | 104 | # Set uid and gid |
| 71 | echo "sif \"$TGT\" uid $U" | 105 | echo "sif \"$D_TGT\" uid $U" |
| 72 | echo "sif \"$TGT\" gid $G" | 106 | echo "sif \"$D_TGT\" gid $G" |
| 73 | 107 | ||
| 74 | # Set atime, mtime and ctime | 108 | # Set atime, mtime and ctime |
| 75 | AT=`echo $AT | cut -d'.' -f1 | sed -e 's#[- :]##g'` | 109 | AT=`echo $AT | cut -d'.' -f1 | sed -e 's#[- :]##g'` |
| 76 | MT=`echo $MT | cut -d'.' -f1 | sed -e 's#[- :]##g'` | 110 | MT=`echo $MT | cut -d'.' -f1 | sed -e 's#[- :]##g'` |
| 77 | CT=`echo $CT | cut -d'.' -f1 | sed -e 's#[- :]##g'` | 111 | CT=`echo $CT | cut -d'.' -f1 | sed -e 's#[- :]##g'` |
| 78 | echo "sif \"$TGT\" atime $AT" | 112 | echo "sif \"$D_TGT\" atime $AT" |
| 79 | echo "sif \"$TGT\" mtime $MT" | 113 | echo "sif \"$D_TGT\" mtime $MT" |
| 80 | echo "sif \"$TGT\" ctime $CT" | 114 | echo "sif \"$D_TGT\" ctime $CT" |
| 81 | done | 115 | done |
| 82 | 116 | ||
| 83 | # Handle the hard links. | 117 | # Handle the hard links. |
| @@ -91,15 +125,17 @@ DEBUGFS="debugfs" | |||
| 91 | # Use the debugfs' ln and "sif links_count" to handle them. | 125 | # Use the debugfs' ln and "sif links_count" to handle them. |
| 92 | for i in `ls $INODE_DIR`; do | 126 | for i in `ls $INODE_DIR`; do |
| 93 | # The link source | 127 | # The link source |
| 94 | SRC=`head -1 $INODE_DIR/$i` | 128 | SRC="$(head -1 $INODE_DIR/$i)" |
| 129 | D_SRC="$(echo $SRC | sed -e 's#\"#\"\"#g')" | ||
| 95 | # Remove the files and link them again except the first one | 130 | # Remove the files and link them again except the first one |
| 96 | for TGT in `sed -n -e '1!p' $INODE_DIR/$i`; do | 131 | sed -n -e '1!p' $INODE_DIR/$i | while read TGT; do |
| 97 | echo "rm $TGT" | 132 | D_TGT="$(echo $TGT | sed -e 's#\"#\"\"#g')" |
| 98 | echo "ln $SRC $TGT" | 133 | echo "rm \"$D_TGT\"" |
| 134 | echo "ln \"$D_SRC\" \"$D_TGT\"" | ||
| 99 | done | 135 | done |
| 100 | LN_CNT=`cat $INODE_DIR/$i | wc -l` | 136 | LN_CNT=`cat $INODE_DIR/$i | wc -l` |
| 101 | # Set the links count | 137 | # Set the links count |
| 102 | echo "sif $SRC links_count $LN_CNT" | 138 | echo "sif \"$D_SRC\" links_count $LN_CNT" |
| 103 | done | 139 | done |
| 104 | rm -fr $INODE_DIR | 140 | rm -fr $INODE_DIR |
| 105 | } | $DEBUGFS -w -f - $DEVICE 2>&1 1>/dev/null | grep '.*: .*' | 141 | } | $DEBUGFS -w -f - $DEVICE 2>&1 1>/dev/null | grep '.*: .*' |
