OSDN Git Service

lndir: set permission, owner, group of destination dir android-x86-7.1-r3
authorChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 19 Jul 2019 04:25:57 +0000 (12:25 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 19 Jul 2019 04:25:57 +0000 (12:25 +0800)
Set them to be the same as the source dir if runs by root.

initrd/bin/lndir

index a80ab16..e2168c7 100755 (executable)
@@ -12,9 +12,19 @@ usage()
        exit 1
 }
 
+make_dir()
+{
+       [ -d "$2" ] || mkdir -p "$2"
+       if [ "`id -u`" = "0" ]; then
+               chmod `stat -c "%a" "$1"` "$2"
+               chown `stat -c "%u.%g" "$1"` "$2"
+       fi
+}
+
 linkdir()
 {
        local odir="$PWD"
+       make_dir "$1" "$2"
        [ -d "$2" ] || mkdir -p "$2"
        cd "$2"
        local d="$PWD"
@@ -31,6 +41,8 @@ linkdir()
        cd "$odir"
 }
 
+[ -d /system/bin ] && PATH=/system/bin:$PATH
+
 [ -z "$src" ] && usage
 
 [ ! -d "$src" ] && echo "$src is not a directory" && exit 2