Merge "move UFS dump to gs-common"
diff --git a/storage/dump_storage.sh b/storage/dump_storage.sh
index 378d58b..5f08fc1 100644
--- a/storage/dump_storage.sh
+++ b/storage/dump_storage.sh
@@ -8,3 +8,61 @@
 getprop ro.boottime.init.fsck.data
 echo "\n--- F2FS - checkpoint=disable time (ms) ---"
 getprop ro.boottime.init.mount.data
+
+# UFS
+echo "\n------ UFS model (/sys/block/sda/device/model) ------"
+cat "/sys/block/sda/device/model"
+echo "\n------ UFS rev (/sys/block/sda/device/rev) ------"
+cat "/sys/block/sda/device/rev"
+echo "\n------ UFS size (/sys/block/sda/size) ------"
+cat "/sys/block/sda/size"
+
+echo "\n------ UFS Slow IO Read (/dev/sys/block/bootdevice/slowio_read_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_read_cnt"
+echo "\n------ UFS Slow IO Write (/dev/sys/block/bootdevice/slowio_write_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_write_cnt"
+echo "\n------ UFS Slow IO Unmap (/dev/sys/block/bootdevice/slowio_unmap_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_unmap_cnt"
+echo "\n------ UFS Slow IO Sync (/dev/sys/block/bootdevice/slowio_sync_cnt) ------"
+cat "/dev/sys/block/bootdevice/slowio_sync_cnt"
+
+echo "\n------ UFS err_stats ------"
+path="/dev/sys/block/bootdevice/err_stats";
+for node in `ls $path/* | grep -v reset_err_status`
+do
+  printf "%s:%d\n" $(basename $node) $(cat $node)
+done
+
+
+echo "\n------ UFS io_stats ------"
+path="/dev/sys/block/bootdevice/io_stats"
+printf "\t\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ReadCnt ReadBytes WriteCnt WriteBytes RWCnt RWBytes
+str=$(cat $path/*_start); arr=($str);
+printf "Started: \t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+str=$(cat $path/*_complete); arr=($str);
+printf "Completed: \t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+str=$(cat $path/*_maxdiff); arr=($str);
+printf "MaxDiff: \t%-12s %-12s %-12s %-12s %-12s %-12s\n\n" ${arr[1]} ${arr[0]} ${arr[5]} ${arr[4]} ${arr[3]} ${arr[2]}
+
+echo "\n------ UFS req_stats ------"
+path="/dev/sys/block/bootdevice/req_stats"
+printf "\t%-12s %-12s %-12s %-12s %-12s %-12s\n" All Write Read Security Flush Discard
+str=$(cat $path/*_min); arr=($str);
+printf "Min:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_max); arr=($str);
+printf "Max:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_avg); arr=($str);
+printf "Avg.:\t%-12s %-12s %-12s %-12s %-12s %-12s\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+str=$(cat $path/*_sum); arr=($str);
+printf "Count:\t%-12s %-12s %-12s %-12s %-12s %-12s\n\n" ${arr[0]} ${arr[5]} ${arr[3]} ${arr[4]} ${arr[2]} ${arr[1]}
+
+echo "\n------ UFS health ------"
+for f in $(find /dev/sys/block/bootdevice/health_descriptor -type f)
+do
+  if [[ -r $f && -f $f ]]; then
+    echo --- $f
+    cat $f
+    echo ''
+  fi
+done
+
diff --git a/storage/sepolicy/dump_storage.te b/storage/sepolicy/dump_storage.te
index 314fa78..9411f8e 100644
--- a/storage/sepolicy/dump_storage.te
+++ b/storage/sepolicy/dump_storage.te
@@ -1,6 +1,8 @@
 pixel_bugreport(dump_storage)
 
 allow dump_storage vendor_toolbox_exec:file execute_no_trans;
+allow dump_storage sysfs_scsi_devices_0000:dir r_dir_perms;
+allow dump_storage sysfs_scsi_devices_0000:file r_file_perms;
 
 userdebug_or_eng(`
   allow dump_storage debugfs_f2fs:dir r_dir_perms;