blob: 0ccb4bf706c5048e9168faf2d4864f2da09e71ec [file] [log] [blame]
# Copyright (c) 2011 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.
# cros-disks upstart job
env CROS_DISKS_UID=213
env CROS_DISKS_GID=213
# 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
start on starting system-services
stop on stopping system-services
pre-start script
# 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 a dependency for AVFS.
# cros-disks should still run even the FUSE module is failed to load.
logger -t "$UPSTART_JOB" "Loading FUSE module"
modprobe fuse || logger -t "$UPSTART_JOB" "Failed to load FUSE module"
end script
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 /opt/google/cros-disks/disks --log-level="${CROS_DISKS_LOG_LEVEL}"