blob: c5aaa2ca0446da453ee784feb6008e8b9311ead8 [file] [edit]
# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Mount the removable media directory using mount-passthrough."
author "chromium-os-dev@chromium.org"
start on starting arcvm-media-sharing-services
stop on stopping arcvm-media-sharing-services
# Set the same oom score as arcvm-media-sharing-services.
oom score -100
# Set VM size soft limit to 1 GB. See arcvm-mount-myfiles.conf for rationale.
# TODO(b/164936284): Specify a lower limit after improving mount-passthrough.
limit as 1000000000 unlimited
import MEDIA_PROVIDER_UID
env SOURCE=/media/removable
env DEST=/run/arcvm/media/removable
env UMASK=007
env CONCIERGE_NAMESPACE_PATH=/run/namespaces/mnt_concierge
# Android's external_storage GID (not shifted).
env ANDROID_EXTERNAL_STORAGE_GID=1077
# The maximum number of file descriptors mount-passthrough can open.
# The number is taken from vm_concierge.conf, which defines the maximum number
# of fds that can be opened by virtio-fs devices.
# We use the same number here because files opened by this mount-passthrough
# process are expected to be the ones opend by a virtio-fs device, and we'd like
# to let virtio-fs devices open as many files as they like without imposing a
# new restriction on the number of files they can open.
env MAX_NUMBER_OF_OPEN_FDS=262144
pre-start exec nsenter --mount="${CONCIERGE_NAMESPACE_PATH}" --no-fork \
-- mkdir -p "${DEST}"
exec /usr/sbin/syslog-cat --identifier="${UPSTART_JOB}" -- \
mount-passthrough-jailed --source="${SOURCE}" --dest="${DEST}" \
--fuse_umask="${UMASK}" --fuse_uid="${MEDIA_PROVIDER_UID}" \
--fuse_gid="${ANDROID_EXTERNAL_STORAGE_GID}" \
--enter_concierge_namespace \
--max_number_of_open_fds="${MAX_NUMBER_OF_OPEN_FDS}"
post-stop script
# Termination by SIGKILL can result in a stale mount which needs clean-up.
nsenter --mount="${CONCIERGE_NAMESPACE_PATH}" --no-fork \
-- umount "${DEST}" || true
end script