termux / libandroid-shmem Goto Github PK
View Code? Open in Web Editor NEWSystem V shared memory emulation on Android using ashmem.
License: BSD 3-Clause "New" or "Revised" License
System V shared memory emulation on Android using ashmem.
License: BSD 3-Clause "New" or "Revised" License
I had compile a library but error
Undefined reference/symbol : shm_open
Undefined reference/symbol : shm_unlink
Using android ndk -r22
Or is there any way to use ashmem instead of shm? If yes then how to do it?
Dear specialists,
How complex would be to port this library to ARMHF or ARM 64 architecture when I would like to use yourslibrary from Debian stable, which will be run by using Proot module for Termux?
Do you think, that it would be possible to create shared memory file or shared executable stack by using procedures and functions inside this .so library? Or this is too much and those techniques can not be supported with no recompiling and changing source code of Android kernel?
I wanted to run many various apps from Debian stable including gnome-session
KDE-plasma, but some C or C++ developers are using shared memory file creation techniques inside their apps, others are using shared executable stack creation.
Sure, there are many other apps, which do not use those techniques, including many text editors, even Audacity, and even Pulseaudio contain two variants of code for using normal memory pool instead of shared memory pool.
Thank you very much for yours answers.
[23:47 test ]$ ipcs
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
[23:47 test ]$ ./cleanup-shared-memory.sh
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
[23:48 test ]$ e
[23:48 test ]$ ipcs
No command 'ipcs' found, did you mean:
Command 'apxs' from package 'apache2'
Command 'ocs' from package 'cscope'
Command 'pphs' from package 'ghostscript'
Command 'mpc' from package 'mpc'
Command 'ps' from package 'procps'
Command 'rcs' from package 'rcs'
Command 'ip' from package 'termux-tools'
[23:48 test ]$ ./cleanup-shared-memory.sh
./cleanup-shared-memory.sh: line 4: ipcs: command not found
BusyBox v1.28.3 (2018-04-08 23:41:12 UTC) multi-call binary.
Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...
$ pacman -Qo ipcs
/usr/bin/ipcs is owned by util-linux 2.32-3
what differences are there from the glibc api and this
Sometimes termux programs are launched inside proot environment, and sometimes happens they run on devices with sysvipc support enabled in kernel. It would be nice to make libandroid-shmem
detect if device/environment has shmat
/shmget
/shmdt
syscalls support and use them. It will be usefull, i.e. when user runs Xwayland/Xvfb/other X server inside proot and MIT-SHM extension works as expected. Reverse case is also possible, i.e. when user runs proot's Xvfb server and runs termux's x11vnc there.
Thank you.
It is possible to use libandroid-shmem inside proot/chroot distros to improve performance of programs and to improve communicating of termux programs with programs in proot/chroot.
To make this possible you should make using linux/ashmem.h
optional by embedding needed macros into shmem.c
and making DBG macro empty if __ANDROID__
is not defined.
Also it is possible to generate installable library automatically by creating Github Action which cross-compiles library for all popular architectures. It would be better to make script which installs library for needed architecture and writes /etc/ld.preload script. To not confuse people with different architectures and different package systems I recommend generating single file script with built-in libraries encoded as base64 strings. This script can be published with Github Releases.
I can make pull request if you tell it is needed.
Dear specialists,
Is it possible to use this library also while running Debian, Ubuntu or other Termux scripts for Linux environment creation? Because many many apps, which have been developed not only by using C or C++ are using shared dynamic memory a nd other shared memory technology. How complex would be to allow users of Debian, Ubuntu and other distro which run by using Termux to use apps, which are using shared memory? Such as gnome-session, KDE and other complex apps, which are based on shared memory. The next example is postgressql which is also using this technique for working with memory.
Shared memory appears to be important in many issues:
Arch Linux in Termux PRoot:
[19:09 libandroid-shmem ]$ make
cc -fpic -shared -std=c11 -Wall -Wextra -Wl,--version-script=exports.txt shmem.c -llog -o libandroid-shmem.so
shmem.c:1:10: fatal error: android/log.h: No such file or directory
#include <android/log.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:4: libandroid-shmem.so] Error 1
[19:09 libandroid-shmem ]$ l android/log.h
-rw-r--r-- 1 e 4452 Nov 9 09:57 android/log.h
[19:09 libandroid-shmem ]$ cd test/
[19:11 test ]$ make
cc -Wall -Wextra -Werror -std=c99 -DSYSV_ASHMEM_TEST_SYSTEM error-codes.c -o test-error-codes
./test-error-codes
shmget: Permission denied
make: *** [Makefile:19: testcase-error-codes] Error 1
Termux:
[21:40 libandroid-shmem ]$ make install cc -fpic -shared -std=c11 -Wall -Wextra -Wl,--version-script=exports.txt shmem.c -llog -o libandroid-shmem.so
install -D libandroid-shmem.so /data/data/com.termux/files/usr/lib/libandroid-shmem.so
install -D shm.h /data/data/com.termux/files/usr/include/sys/shm.h
The Arch Linux in Termux PRoot sudo error has changed:
[23:16 data ]$ env LD_PRELOAD=/data/data/com.termux/files/usr/lib/libandroid-shmem.so startarch su user sudo
sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: unable to load /usr/lib/sudo/sudoers.so: /usr/lib/sudo/sudoers.so: cannot stat shared object: Bad file descriptor
sudo: fatal error, unable to load plugins
[23:16 data ]$ env LD_PRELOAD=/data/data/com.termux/files/usr/lib/libandroid-shmem.so startarch l user
Welcome to Arch Linux in Termux!
Install a package: pacman -S package
More information: pacman [-D|F|Q|R|S|T|U]h
Search packages: pacman -Ss query
Upgrade packages: pacman -Syu
Chat: https://gitter.im/termux
Help: info query and man query
IRC: wiki.archlinux.org/index.php/IRC_channel
[23:17 ~ ]$ sudo
sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: unable to load /usr/lib/sudo/sudoers.so: /usr/lib/sudo/sudoers.so: cannot stat shared object: Bad file descriptor
sudo: fatal error, unable to load plugins
[23:17 ~ ]$ env LD_PRELOAD=/data/data/com.termux/files/usr/lib/libandroid-shmem.so sudo
sudo: error while loading shared libraries: liblog.so: cannot open shared object file: No such file or directory
make: gcc: Function not implemented
make: *** [Makefile:22: test-after-fork] Error 127
Do you think, that is it possible to use yours library to emulate shared memory while running Debian Buster ARM64 Bit edition by using Termux and Proot? If yes, would you tell Me how could I reach this goal?
If I would like to use yours library from Debian. What would I had to do?
Thank you very much for yours support.
@fornwall How to use this library for chroot?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.