6 Star 5 Fork 61

OpenHarmony/third_party_e2fsprogs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1001-image-make.patch 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
张文迪 提交于 2023-05-20 17:27 +08:00 . switch to OpenEuler e2fsprogs
diff --git a/contrib/populate-extfs.sh b/contrib/populate-extfs.sh
index b1d3d1f8cd45bd7d0a09973f7b8b83752a7c166f..173b0a568f3fdbc48b4a17d274fd3a03840f14a9 100755
--- a/contrib/populate-extfs.sh
+++ b/contrib/populate-extfs.sh
@@ -3,10 +3,13 @@
# This script uses debugfs command to populate the ext2/3/4 filesystem
# from a given directory.
#
+# Added mode, uid and gid config function by OpenHarmony team.
+export LANG=en_US.UTF-8
+export LANGUAGE=en_US:en
do_usage () {
cat << _EOF
-Usage: populate-extfs.sh <source> <device>
+Usage: populate-extfs.sh <source> <device> <cfgfile>
Create an ext2/ext3/ext4 filesystem from a directory or file
source: The source directory or file
@@ -16,17 +19,71 @@ _EOF
exit 1
}
-[ $# -ne 2 ] && do_usage
+CFGFILE_CNT=5
+FILEMODE_IDX=2
+FILEU_IDX=3
+FILEG_IDX=4
+_NEW_FILEMODE=0
+_NEW_FILEUID=0
+_NEW_FILEGID=0
+
+declare -a CONFIG_ARRAY
+
+do_parsecfgfile () {
+ i=0
+ while read _BINFILE_ _FILETYPE_ _FILEMODE_ _FILEUID_ _FILEGID_
+ do
+ CONFIG_ARRAY[${i}]=${_BINFILE_}
+ i=$[$i+1]
+ CONFIG_ARRAY[${i}]=${_FILETYPE_}
+ i=$[$i+1]
+ CONFIG_ARRAY[${i}]=${_FILEMODE_}
+ i=$[$i+1]
+ CONFIG_ARRAY[${i}]=${_FILEUID_}
+ i=$[$i+1]
+ CONFIG_ARRAY[${i}]=${_FILEGID_}
+ i=$[$i+1]
+ done < ${CFGFILE}
+}
+
+do_getfilecfgmode () {
+ i=0
+ _NEW_FILEMODE_=$2
+ _NEW_FILEUID_=0
+ _NEW_FILEGID_=0
+ while [ $i -lt ${#CONFIG_ARRAY[@]} ]
+ do
+ if [ "$1" == "${CONFIG_ARRAY[$i]}" ]; then
+ # Change file mode from OCT to HEX.
+ _NEW_FILEMODE_=$(echo "obase=16;$((0x$MODE & (~07777) | 0${CONFIG_ARRAY[$i+${FILEMODE_IDX}]}))"|bc)
+ _NEW_FILEUID_=${CONFIG_ARRAY[$i+${FILEU_IDX}]}
+ _NEW_FILLEGID_=${CONFIG_ARRAY[$i+${FILEG_IDX}]}
+ return 0
+ fi
+ i=$[$i+${CFGFILE_CNT}]
+ done
+}
+
+[ $# -ne 3 ] && do_usage
SRCDIR=${1%%/}
DEVICE=$2
+CFGFILE=$3
+
+# parse config file
+do_parsecfgfile
# Find where is the debugfs command if not found in the env.
if [ -z "$DEBUGFS" ]; then
CONTRIB_DIR=$(dirname $(readlink -f $0))
DEBUGFS="$CONTRIB_DIR/../debugfs/debugfs"
+ DEBUGFS=debugfs
fi
+# "debugfs" command check.
+command -v debugfs >/dev/null 2>&1 || \
+{ echo >&2 "debugfs is required, please install by \"apt-get install e2fsprogs\". Aborting."; exit 1; }
+
{
CWD="/"
find $SRCDIR | while read FILE; do
@@ -72,6 +129,10 @@ fi
;;
esac
+ do_getfilecfgmode ${FILE#$SRCDIR} $MODE $U $G
+ MODE=${_NEW_FILEMODE_}
+ U=${_NEW_FILEUID_}
+ G=${_NEW_FILEGID_}
# Set the file mode
echo "sif $TGT mode 0x$MODE"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_e2fsprogs.git
git@gitee.com:openharmony/third_party_e2fsprogs.git
openharmony
third_party_e2fsprogs
third_party_e2fsprogs
master

搜索帮助