| # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "ARC sensor service" |
| author "chromium-os-dev@chromium.org" |
| |
| start on starting arcvm-pre-login-services |
| stop on stopping arcvm-pre-login-services |
| |
| limit as 100000000 unlimited |
| oom score -100 |
| |
| pre-start script |
| { |
| echo "Pre-start ${UPSTART_JOB}" |
| set -x |
| |
| # This code was imported from arc/setup/etc/arc-sensor.conf. |
| ring_buffer_dir="$(find /sys/devices -path '*cros-ec-ring*' -name buffer)" |
| ring_dir=$(dirname "${ring_buffer_dir}") |
| if [ -d "${ring_buffer_dir}" ]; then |
| # Enable all channels for ARC++, be sure the buffer is not. |
| echo 0 > "${ring_buffer_dir}/enable" |
| for channel in ${ring_dir}/scan_elements/*_en; do |
| echo 1 > "${channel}" |
| done |
| fi |
| } 2>&1 | logger -t "${UPSTART_JOB}" |
| end script |
| |
| script |
| logger -t "${UPSTART_JOB}" "Start ${UPSTART_JOB}" |
| set -x |
| |
| # List all IIO device files. |
| for DEVICE in /dev/iio:device*; do |
| IIO_DEVICE_BIND_ARGS="${IIO_DEVICE_BIND_ARGS} -b ${DEVICE}" |
| done |
| |
| # List all directories referenced by IIO sysfs symlinks. |
| for DEVICE in /sys/bus/iio/devices/*; do |
| if [ -L "${DEVICE}" ]; then |
| LINKED="$(readlink -f ${DEVICE})" |
| IIO_DEVICE_BIND_ARGS="${IIO_DEVICE_BIND_ARGS} -b ${LINKED},${LINKED},1" |
| fi |
| done |
| |
| exec minijail0 \ |
| --profile=minimalistic-mountns \ |
| -e \ |
| -p \ |
| -l \ |
| --uts \ |
| -N \ |
| -k 'tmpfs,/sys,tmpfs,MS_NOSUID|MS_NODEV|MS_NOEXEC' \ |
| -b /sys/bus/iio/devices \ |
| -k 'tmpfs,/run,tmpfs,MS_NOSUID|MS_NODEV|MS_NOEXEC' \ |
| -b /run/dbus \ |
| ${IIO_DEVICE_BIND_ARGS} \ |
| -- /usr/bin/arc_sensor_service |
| end script |
| |
| post-stop exec logger -t "${UPSTART_JOB}" "Post-stop ${UPSTART_JOB}" |