Skip to content

Commit 8c47fcd

Browse files
authored
Merge branch 'master' into dockerfile
2 parents a777442 + 66b4528 commit 8c47fcd

File tree

20 files changed

+363
-18
lines changed

20 files changed

+363
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ build*/
22
parts/
33
stage/
44
prime/
5+
snap/.snapcraft
56
android-images/
67
*.snap
78
CMakeLists.txt.user

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ if (ENABLE_MIR)
9292
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMIR_SUPPORT")
9393
endif()
9494

95+
if (NOT BINDERFS_PATH)
96+
set(BINDERFS_PATH "/dev/binderfs")
97+
endif()
98+
9599
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEGL_NO_X11")
96100

97-
if((Protobuf_VERSION GREATER "3.7") OR (Protobuf_VERSION EQUAL "3.7"))
101+
if((Protobuf_VERSION VERSION_GREATER "3.7") OR (Protobuf_VERSION VERSION_EQUAL "3.7"))
98102
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_PROTOBUF_CALLBACK_HEADER")
99103
endif()
100104

external/process-cpp-minimal/src/core/posix/signal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class SignalTrap : public core::posix::SignalTrap
155155
{
156156
auto result = ::read(scope.signal_fd, signal_info, sizeof(signal_info));
157157

158-
for (uint i = 0; i < result / sizeof(signalfd_siginfo); i++)
158+
for (unsigned int i = 0; i < result / sizeof(signalfd_siginfo); i++)
159159
{
160160
if (has(static_cast<core::posix::Signal>(signal_info[i].ssi_signo)))
161161
{

scripts/container-manager.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ start() {
8585
EXTRA_ARGS="$EXTRA_ARGS --container-network-dns-servers=$container_network_dns"
8686
fi
8787

88+
# Load all relevant kernel modules
89+
modprobe binder_linux
90+
modprobe ashmem_linux
91+
92+
# Ensure we have binderfs mounted when our kernel supports it
93+
if cat /proc/filesystems | grep -q binder ; then
94+
mkdir -p "$SNAP_COMMON"/binderfs
95+
# Remove old mounts so that we start fresh without any devices allocated
96+
if cat /proc/mounts | grep -q "binder $SNAP_COMMON/binderfs" ; then
97+
umount "$SNAP_COMMON"/binderfs
98+
fi
99+
mount -t binder none "$SNAP_COMMON"/binderfs
100+
fi
101+
88102
exec "$SNAP"/bin/anbox-wrapper.sh container-manager \
89103
--data-path="$DATA_PATH" \
90104
--android-image="$ANDROID_IMG" \

scripts/snap-wrapper.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ if [ "$(snapctl get touch-emulation.enable)" = false ]; then
4747
export ANBOX_ENABLE_TOUCH_EMULATION=false
4848
fi
4949

50-
exec "$SNAP"/usr/bin/anbox "$@"
50+
# Use custom Anbox binary for debugging purposes if available
51+
ANBOX="$SNAP"/usr/bin/anbox
52+
if [ -e "$SNAP_COMMON"/anbox.debug ]; then
53+
ANBOX="$SNAP_COMMON"/anbox.debug
54+
fi
55+
56+
exec "$ANBOX" "$@"

snap/snapcraft.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ parts:
257257
# that is fixed we can avoid using a prefix here.
258258
- -DCMAKE_INSTALL_PREFIX:PATH=/usr
259259
- -DANBOX_VERSION=$SNAPCRAFT_PROJECT_VERSION
260+
- -DBINDERFS_PATH=/var/snap/anbox/common/binderfs
260261
# FIXME: Once we have everything in place for full snap confinement we
261262
# can securely enable this.
262263
# - -DSNAP_CONFINEMENT=ON

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ include_directories(
2929
${CMAKE_SOURCE_DIR}/external/cpu_features/include
3030
)
3131

32+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBINDERFS_PATH=\"\\\"${BINDERFS_PATH}\\\"\"")
33+
3234
protobuf_generate_cpp(
3335
GENERATED_PROTOBUF_RPC_SRCS GENERATED_PROTOBUF_RPC_HDRS
3436
anbox/protobuf/anbox_rpc.proto)
@@ -121,6 +123,11 @@ set(SOURCES
121123
anbox/common/variable_length_array.h
122124
anbox/common/wait_handle.cpp
123125
anbox/common/wait_handle.h
126+
anbox/common/binderfs.h
127+
anbox/common/binder_device.cpp
128+
anbox/common/binder_device.h
129+
anbox/common/binder_device_allocator.cpp
130+
anbox/common/binder_device_allocator.h
124131

125132
anbox/container/client.cpp
126133
anbox/container/client.h

src/anbox/cmds/check_features.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
#include "anbox/utils.h"
2020

2121
#include "cpu_features_macros.h"
22+
#if defined(CPU_FEATURES_ARCH_X86)
2223
#include "cpuinfo_x86.h"
24+
#endif
2325

2426
namespace {
2527
std::vector<std::string> cpu_whitelist = {

src/anbox/cmds/session_manager.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ anbox::cmds::SessionManager::SessionManager()
129129
return EXIT_FAILURE;
130130
}
131131

132-
if (!fs::exists("/dev/binder") || !fs::exists("/dev/ashmem")) {
132+
if ((!fs::exists("/dev/binder") && !fs::exists(BINDERFS_PATH)) || !fs::exists("/dev/ashmem")) {
133133
ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded");
134134
return EXIT_FAILURE;
135135
}
@@ -269,8 +269,6 @@ anbox::cmds::SessionManager::SessionManager()
269269
};
270270

271271
container_configuration.devices = {
272-
{"/dev/binder", {0666}},
273-
{"/dev/ashmem", {0666}},
274272
{"/dev/fuse", {0666}},
275273
};
276274

src/anbox/cmds/system_info.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "OpenGLESDispatch/EGLDispatch.h"
3232

3333
#include "cpu_features_macros.h"
34+
#if defined(CPU_FEATURES_ARCH_X86)
3435
#include "cpuinfo_x86.h"
36+
#endif
3537

3638
namespace fs = boost::filesystem;
3739

0 commit comments

Comments
 (0)