diff options
author | wchang kim <wchang.kim@samsung.com> | 2016-07-05 14:43:02 +0900 |
---|---|---|
committer | wchang kim <wchang.kim@samsung.com> | 2016-07-05 14:43:02 +0900 |
commit | 5c851825b27703797bda2dfa292f568c0612a4e0 (patch) | |
tree | 525564cb4652cbc409530e6b871447ff181657b1 | |
parent | d0b08988e334877e07c0082d61c4c392f90a290f (diff) | |
download | system-plugin-5c851825b27703797bda2dfa292f568c0612a4e0.tar.gz system-plugin-5c851825b27703797bda2dfa292f568c0612a4e0.tar.bz2 system-plugin-5c851825b27703797bda2dfa292f568c0612a4e0.zip |
Description : Adding a service for fstrim for opt mount.submit/tizen/20160705.082718accepted/tizen/wearable/20160705.101926accepted/tizen/tv/20160705.101909accepted/tizen/mobile/20160705.101957accepted/tizen/ivi/20160705.101905accepted/tizen/common/20160705.170608
Adding a service for fstrim for opt mount.
Requested by profiling part.
Change-Id: I4da82cf6e5979cc57f56e0db69723b177de1a050
Signed-off-by: Woochang Kim <wchang.kim@samsung.com>
-rw-r--r-- | packaging/system-plugin.spec | 16 | ||||
-rw-r--r-- | scripts/tizen-fstrim-on-charge.sh | 45 | ||||
-rw-r--r-- | units/tizen-fstrim-user.service | 9 | ||||
-rw-r--r-- | units/tizen-fstrim-user.timer | 5 |
4 files changed, 75 insertions, 0 deletions
diff --git a/packaging/system-plugin.spec b/packaging/system-plugin.spec index ab656fc..a25d544 100644 --- a/packaging/system-plugin.spec +++ b/packaging/system-plugin.spec @@ -95,6 +95,14 @@ install -m 644 etc/fstab %{buildroot}%{_sysconfdir} # ugly temporary patch for initrd wearable install -m 644 etc/fstab_initrd %{buildroot}%{_sysconfdir} +# fstrim +mkdir -p %{buildroot}%{_unitdir}/graphical.target.wants +install -m 644 units/tizen-fstrim-user.timer %{buildroot}%{_unitdir} +ln -s ../tizen-fstrim-user.timer %{buildroot}%{_unitdir}/graphical.target.wants/tizen-fstrim-user.timer +install -m 644 units/tizen-fstrim-user.service %{buildroot}%{_unitdir} +mkdir -p %{buildroot}%{_bindir} +install -m 755 scripts/tizen-fstrim-on-charge.sh %{buildroot}%{_bindir} + %post systemctl daemon-reload @@ -118,6 +126,10 @@ systemctl daemon-reload %{_unitdir}/basic.target.wants/resize2fs@dev-disk-by\x2dlabel-user.service %{_unitdir}/basic.target.wants/resize2fs@dev-disk-by\x2dlabel-rootfs.service %{_sysconfdir}/fstab +%{_unitdir}/graphical.target.wants/tizen-fstrim-user.timer +%{_unitdir}/tizen-fstrim-user.timer +%{_unitdir}/tizen-fstrim-user.service +%{_bindir}/tizen-fstrim-on-charge.sh %files exynos %manifest %{name}.manifest @@ -157,3 +169,7 @@ mv %{_sysconfdir}/fstab_initrd %{_sysconfdir}/fstab %{_unitdir}/local-fs.target.wants/csa.mount %{_unitdir}/umount-opt.service %{_unitdir}/local-fs-pre.target.wants/umount-opt.service +%{_unitdir}/graphical.target.wants/tizen-fstrim-user.timer +%{_unitdir}/tizen-fstrim-user.timer +%{_unitdir}/tizen-fstrim-user.service +%{_bindir}/tizen-fstrim-on-charge.sh diff --git a/scripts/tizen-fstrim-on-charge.sh b/scripts/tizen-fstrim-on-charge.sh new file mode 100644 index 0000000..c08cd74 --- /dev/null +++ b/scripts/tizen-fstrim-on-charge.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +if [ "$#" -ne 1 ];then + echo "Argument was missed." + exit 1 +fi + +CHARGE_NOW_FILE=`/usr/bin/find /sys/devices -path */power_supply/battery/charge_now` +if [ "x$CHARGE_NOW_FILE" == "x" ]; then + echo "Can not find 'charge_now'." + CHARGE_NOW_VALUE=0 +else + CHARGE_NOW_VALUE=`/bin/cat $CHARGE_NOW_FILE` +fi + +BATTERY_STATUS_FILE=`/usr/bin/find /sys/devices -path */power_supply/battery/status` +if [ "x$BATTERY_STATUS_FILE" == "x" ]; then + echo "Can not find 'status'." + exit 1 +else + STATUS_VALUE=`/bin/cat $BATTERY_STATUS_FILE` +fi + +BATTERY_CAPACITY_FILE=`/usr/bin/find /sys/devices -path */power_supply/battery/capacity` +if [ "x$BATTERY_CAPACITY_FILE" == "x" ]; then + echo "Can not find 'capacity'." + exit 1 +else + CAPACITY_VALUE=`/bin/cat $BATTERY_CAPACITY_FILE` +fi + +echo $STATUS_VALUE +echo $CAPACITY_VALUE + +if [ "$CHARGE_NOW_VALUE" -gt 0 ];then + echo "Do fstrim(C1)." + /sbin/fstrim -v $* +else + if [ \( $STATUS_VALUE == "Charging" -o $STATUS_VALUE == "Full" \) -a \( $CAPACITY_VALUE -gt 30 \) ]; then + echo "Do fstrim(C2)." + /sbin/fstrim -v $* + else + echo "Not on charging." + fi +fi diff --git a/units/tizen-fstrim-user.service b/units/tizen-fstrim-user.service new file mode 100644 index 0000000..524086d --- /dev/null +++ b/units/tizen-fstrim-user.service @@ -0,0 +1,9 @@ +[Unit] +Description=Discard unused blocks on user partition +Requires=opt.mount + +[Service] +Type=oneshot +ExecStart=/usr/bin/tizen-fstrim-on-charge.sh /opt +StandardOutput=journal +StandardError=inherit diff --git a/units/tizen-fstrim-user.timer b/units/tizen-fstrim-user.timer new file mode 100644 index 0000000..049539e --- /dev/null +++ b/units/tizen-fstrim-user.timer @@ -0,0 +1,5 @@ +[Unit] +Description=Timer for tizen-fstrim + +[Timer] +OnCalendar=*-*-* 06:00:00 |