summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunmin Lee <sunm.lee@samsung.com>2017-12-21 05:49:19 (GMT)
committerSunmin Lee <sunm.lee@samsung.com>2017-12-21 05:54:15 (GMT)
commitd867203f4188579d5e57217ffa5d2e88a8ab92d0 (patch)
tree3794b1211ab45279842b2474e695f963456e194b
parentf6dce487062797ed8936bd6528fdd06173fe6c20 (diff)
downloadfactory-reset-accepted/tizen_4.0_unified.zip
factory-reset-accepted/tizen_4.0_unified.tar.gz
factory-reset-accepted/tizen_4.0_unified.tar.bz2
Some platform binaries which are based on 2-partition do not have user partition. This patch considers the operation of factory-reset on such binaries. Change-Id: I3f104fc2ad96d8d5a510007943eca59a90290614 Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
-rwxr-xr-xscript/run-factory-reset.sh77
1 files changed, 46 insertions, 31 deletions
diff --git a/script/run-factory-reset.sh b/script/run-factory-reset.sh
index 30307fe..c84c571 100755
--- a/script/run-factory-reset.sh
+++ b/script/run-factory-reset.sh
@@ -45,6 +45,14 @@ done
cd ${ROOTDIR}
+check_user_partition() {
+ RET=`/bin/cat /etc/fstab | /bin/grep "user"`
+ if [ "z$RET" = "z" ]; then
+ echo "There is no user partition: 2 partitions?" >> $logfile
+ NO_USRPART=1
+ fi
+}
+
kill_normal_daemons () {
LIST=`/bin/ls /proc/`
for i in $LIST
@@ -121,34 +129,36 @@ fs_ready() {
/bin/umount -lf ${OPT}/storage/sdcard
# modem binary images should be preserved.
/bin/umount -lf ${OPT}/modem
+ if [ "z$NO_USRPART" = "z" ]; then
# phone usr partition should be reset
- /bin/mkdir -p $USRDATADIR
- /bin/mount $USRDATADIR
- mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $1}'`
- #device=`/bin/grep "$USRDATADIR" /etc/fstab | /usr/bin/awk '{print $1}'`
- device=`blkid --match-token LABEL=user -o device`
- device=`/usr/bin/readlink -f $device`
- if [[ "z$mret" != "z" && "$mret" != "$device" ]]; then
- echo "$mret != $device" >> $logfile
- echo "$USRDATADIR may be encrypted : FAIL" >> $logfile
+ /bin/mkdir -p $USRDATADIR
+ /bin/mount $USRDATADIR
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $1}'`
+ #device=`/bin/grep "$USRDATADIR" /etc/fstab | /usr/bin/awk '{print $1}'`
+ device=`blkid --match-token LABEL=user -o device`
+ device=`/usr/bin/readlink -f $device`
+ if [[ "z$mret" != "z" && "$mret" != "$device" ]]; then
+ echo "$mret != $device" >> $logfile
+ echo "$USRDATADIR may be encrypted : FAIL" >> $logfile
+ check_fail
+ fi
+ if [[ "z$mret" = "z" && "z$device" != "z" ]]; then
+ # mount failed. format and remount
+ echo "$USRDATADIR mount failed. format and retry to mount again" >> $logfile
+ fstype=`/bin/grep "$USRDATADIR " /etc/fstab | /usr/bin/awk '{print $3}'`
+ fstype=`blkid --match-token LABEL=user -o device`
+ /sbin/mkfs.$fstype $device -F
+ /bin/mount -t $fstype $device $USRDATADIR
+ fi
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $2}'`
+ if [ "z$mret" = "z" ]; then
+ echo "$USRDATADIR MOUNT : FAIL" >> $logfile
+ # reboot and retry
+ /bin/sync
+ /sbin/reboot
+ fi
check_fail
fi
- if [[ "z$mret" = "z" && "z$device" != "z" ]]; then
- # mount failed. format and remount
- echo "$USRDATADIR mount failed. format and retry to mount again" >> $logfile
- fstype=`/bin/grep "$USRDATADIR " /etc/fstab | /usr/bin/awk '{print $3}'`
- fstype=`blkid --match-token LABEL=user -o device`
- /sbin/mkfs.$fstype $device -F
- /bin/mount -t $fstype $device $USRDATADIR
- fi
- mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $2}'`
- if [ "z$mret" = "z" ]; then
- echo "$USRDATADIR MOUNT : FAIL" >> $logfile
- # reboot and retry
- /bin/sync
- /sbin/reboot
- fi
- check_fail
}
disable_keys() {
@@ -222,6 +232,7 @@ fi
##kill_before_reset
+check_user_partition
fs_ready
echo "file system ready for factory reset" >> $logfile
@@ -252,18 +263,22 @@ if [ -r /usr/bin/resetCCMode ]; then
/usr/bin/resetCCMode >> $logfile
fi
-/sbin/fstrim -v $USRDATADIR >> $logfile
+if [ "z$NO_USRPART" = "z" ]; then
+ /sbin/fstrim -v $USRDATADIR >> $logfile
+fi
# Delete finished. Restore starts here.
cd /
$RSTCMD
echo "$RSTCMD return $?" >> $logfile
-mret=`/bin/grep "$USRDATADIR " /proc/mounts | /bin/grep rw | /usr/bin/awk '{print $2}'`
-if [ "z$mret" = "z" ]; then
- echo "$USRDATADIR is not RW MOUNTED, RESTORATION : FAIL" >> $logfile
- /bin/rm -rf $USRDATADIR
- check_fail
+if [ "z$NO_USRPART" = "z" ]; then
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /bin/grep rw | /usr/bin/awk '{print $2}'`
+ if [ "z$mret" = "z" ]; then
+ echo "$USRDATADIR is not RW MOUNTED, RESTORATION : FAIL" >> $logfile
+ /bin/rm -rf $USRDATADIR
+ check_fail
+ fi
fi
#check_verify