blob: 715975a76d504ca6ce13691ec46a2a3b0969de5f [file] [log] [blame]
# Copyright 2011 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "cros-disks upstart job"
author "chromium-os-dev@chromium.org"
oom score -100
env CROS_DISKS_OPTS=''
# Set the default polling interval in milliseconds on block devices.
# This in-kernel polling mechanism is available since kernel 2.6.38.
# The poll timer slack is set to 25% in kernel (linux/block/genhd.c).
# With a polling interval <= 1 second, the system seems to react to
# eject requests from a CD-ROM drive more responsively.
env BLOCK_DEFAULT_POLL_MSECS=1000
env BLOCK_DEFAULT_POLL_MSECS_SYSFS_PATH=/sys/module/block/parameters/events_dfl_poll_msecs
# Minimum log level defined in base/logging.h.
# 0:INFO, 1:WARNING, 2:ERROR, 3:ERROR_REPORT, 4:FATAL
# -1:VLOG(1), -2:VLOG(2), etc
# Set to log only INFO or above by default.
env CROS_DISKS_LOG_LEVEL=1
# Importing the TZ environment variable to allow the time zone to be changed
# for tests.
import TZ
start on starting system-services
stop on stopping system-services
pre-start script
# The TZ variable is only allowed to exist in test builds for running
# autotests. The existence, even if set to empty, of TZ interferes with the
# regular functioning of the system timezone.
if crossystem "cros_debug?0" && [ -n "${TZ+set}" ]; then
logger -t "${UPSTART_JOB}" "TZ variable set in non-debug mode"
exit 1
fi
# Set default polling interval on block devices.
# This only affects block devices with removable media, which do not
# support asynchronous media change/eject events.
if [ -f "${BLOCK_DEFAULT_POLL_MSECS_SYSFS_PATH}" ]; then
echo "${BLOCK_DEFAULT_POLL_MSECS}" > "${BLOCK_DEFAULT_POLL_MSECS_SYSFS_PATH}"
fi
# Load the FUSE module, which is used by various FUSE mounters.
# cros-disks should still run even if the FUSE module fails to load.
logger -t "${UPSTART_JOB}" "Loading FUSE module"
modprobe fuse || logger -t "${UPSTART_JOB}" "Failed to load FUSE module"
end script
tmpfiles /usr/lib/tmpfiles.d/on-demand/cros-disks.conf
post-stop script
if [ -f "${BLOCK_DEFAULT_POLL_MSECS_SYSFS_PATH}" ]; then
# Disable default polling on block devices.
echo 0 > "${BLOCK_DEFAULT_POLL_MSECS_SYSFS_PATH}"
fi
end script
respawn
expect fork
exec minijail0 --config /usr/share/minijail/cros-disks.conf \
-- /usr/bin/cros-disks --foreground \
--log_level="${CROS_DISKS_LOG_LEVEL}" ${CROS_DISKS_OPTS}