Add very basic implementation of os and fcntl modules for unix port.

Using ffi module. Both offer just 1-2 initial functions so far.
asyncio-segfault
Paul Sokolovsky 2014-04-02 19:04:43 +03:00
rodzic e71f9f41c4
commit 27ec4eb700
2 zmienionych plików z 37 dodań i 0 usunięć

23
fcntl/fcntl.py 100644
Wyświetl plik

@ -0,0 +1,23 @@
import ffi
libc = ffi.open("libc.so.6")
fcntl_l = libc.func("i", "fcntl", "iil")
fcntl_s = libc.func("i", "fcntl", "iis")
ioctl_l = libc.func("i", "ioctl", "iil")
ioctl_s = libc.func("i", "ioctl", "iis")
def fcntl(fd, op, arg):
if type(arg) is int:
return fcntl_l(fd, op, arg)
else:
raise NotImplementedError
def ioctl(fd, op, arg):
if type(arg) is int:
return ioctl_l(fd, op, arg)
else:
raise NotImplementedError

14
os/os.py 100644
Wyświetl plik

@ -0,0 +1,14 @@
import ffi
libc = ffi.open("libc.so.6")
errno = libc.var("i", "errno")
mkdir_ = libc.func("i", "mkdir", "si")
def mkdir(name, mode=0o777):
e = mkdir_(name, mode)
if not e:
return
raise OSError(errno.get())