Python Forum

Full Version: calling os functions not in module os
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i recall seeing a way to make calls to libc functions and/or kernel syscalls but now that i need it it can't find it. i did find module dl but it was depricated in version 2.6 so that is not what i would use, even if i could. i'd rather not name the calls i want to make so that any answers can stay focused on what is a general way to do Linux syscalls. at least one of the syscalls i want to do is not even in gnu libc. i also recall seeing a way to call a C library. but that might not help for the one syscall that is not in libc unless i can find a way to build my own C library to do it.
see Calling functions here: https://docs.python.org/3/library/ctypes.html
simple example:
>>> print(libc.time(None))  
1150640792
>>> print(hex(windll.kernel32.GetModuleHandleA(None)))  
0x1d000000
>>>
that was the thing i saw a while back. thanks!!

i think i might have overlooked it in my google searches because of the name.

now i can say what it is for. i will be calling some or all of these kernel syscalls: chroot(), clone(), kcmp(), pivot_root(), setns(), syscall(), and unshare(). the project is to use the Linux container facility to run 2 or more Linux distros is parallel without a parent (which means i have to do it directly, not with LXC). and i want Python to be the system programming language of choice. another project is to run a distro entirely in RAM, unmounting the system volumes (and detaching them where possible in container and cloud environments).