mirror of
https://github.com/termux/termux-packages.git
synced 2024-11-23 14:56:16 +00:00
78 lines
2.2 KiB
Diff
78 lines
2.2 KiB
Diff
--- a/ipc/chromium/src/base/shared_memory_posix.cc
|
|
+++ b/ipc/chromium/src/base/shared_memory_posix.cc
|
|
@@ -40,6 +40,65 @@
|
|
#include "mozilla/UniquePtrExtensions.h"
|
|
#include "prenv.h"
|
|
|
|
+static int shm_unlink(const char *name) {
|
|
+ size_t namelen;
|
|
+ char *fname;
|
|
+
|
|
+ /* Construct the filename. */
|
|
+ while (name[0] == '/') ++name;
|
|
+
|
|
+ if (name[0] == '\0') {
|
|
+ /* The name "/" is not supported. */
|
|
+ errno = EINVAL;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ namelen = strlen(name);
|
|
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
|
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
|
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
|
+
|
|
+ return unlink(fname);
|
|
+}
|
|
+
|
|
+static int shm_open(const char *name, int oflag, mode_t mode) {
|
|
+ size_t namelen;
|
|
+ char *fname;
|
|
+ int fd;
|
|
+
|
|
+ /* Construct the filename. */
|
|
+ while (name[0] == '/') ++name;
|
|
+
|
|
+ if (name[0] == '\0') {
|
|
+ /* The name "/" is not supported. */
|
|
+ errno = EINVAL;
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ namelen = strlen(name);
|
|
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
|
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
|
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
|
+
|
|
+ fd = open(fname, oflag, mode);
|
|
+ if (fd != -1) {
|
|
+ /* We got a descriptor. Now set the FD_CLOEXEC bit. */
|
|
+ int flags = fcntl(fd, F_GETFD, 0);
|
|
+ flags |= FD_CLOEXEC;
|
|
+ flags = fcntl(fd, F_SETFD, flags);
|
|
+
|
|
+ if (flags == -1) {
|
|
+ /* Something went wrong. We cannot return the descriptor. */
|
|
+ int save_errno = errno;
|
|
+ close(fd);
|
|
+ fd = -1;
|
|
+ errno = save_errno;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return fd;
|
|
+}
|
|
+
|
|
namespace base {
|
|
|
|
void SharedMemory::MappingDeleter::operator()(void* ptr) {
|
|
@@ -153,7 +212,7 @@
|
|
// FreeBSD in version 13.
|
|
|
|
# if !defined(HAVE_MEMFD_CREATE) && defined(XP_LINUX) && \
|
|
- defined(SYS_memfd_create)
|
|
+ defined(SYS_memfd_create) && !defined(__TERMUX__)
|
|
|
|
// Older libc versions (e.g., glibc before 2.27) don't have the
|
|
// wrapper, but we can supply our own; see `linux_memfd_defs.h`.
|