Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/code-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

meson setup build \
-Dprefix=/data/share \
-Dinit-script=sysvinit \
-Dinit-script=monitd \
-Druntime-path=/data/local/tmp \
-Dstrip=true \
-Dd_lto=true \
Expand All @@ -48,3 +48,10 @@ jobs:
--cross-file aarch64-android-api30.txt

meson compile -C build
sudo /usr/local/bin/ninja -C build install

- name: Upload artifacts lxc
uses: actions/upload-artifact@v4.3.1
with:
name: android-aarch64-lxc-shared-api30
path: /data/share/*
26 changes: 26 additions & 0 deletions src/lxc/rexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
tmpfd = -EBADF;
int ret;
ssize_t bytes_sent = 0;
#if IS_BIONIC && __ANDROID_API__ >= 30
off_t fd_size = -1;
#else
#error "memfd_create() not implemented under Android 30"
struct stat st = {0};
#endif

memfd = memfd_create(memfd_name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
if (memfd < 0) {
Expand All @@ -121,15 +126,32 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
return;

/* sendfile() handles up to 2GB. */
#if IS_BIONIC
fd_size = lseek(fd, 0, SEEK_END);
if (fd_size < 0) {
return;
}

lseek(fd, 0, SEEK_SET);
#else
ret = fstat(fd, &st);
if (ret)
return;
#endif

#if IS_BIONIC
while (bytes_sent < fd_size) {
#else
while (bytes_sent < st.st_size) {
#endif
ssize_t sent;

sent = lxc_sendfile_nointr(memfd >= 0 ? memfd : tmpfd, fd, NULL,
#if IS_BIONIC
fd_size - (off_t)bytes_sent);
#else
st.st_size - bytes_sent);
#endif
if (sent < 0) {
/*
* Fallback to shoveling data between kernel- and
Expand Down Expand Up @@ -166,7 +188,11 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
if (execfd < 0)
return;

#if IS_BIONIC
execveat(execfd, "", argv, envp, AT_EMPTY_PATH);
#else
fexecve(execfd, argv, envp);
#endif
}

/*
Expand Down