Add basic syscalls (#270)

* Add sys_umask and sys_chdir
This commit is contained in:
Yan 2017-05-26 11:50:39 -04:00 committed by GitHub
parent 8354ded7e0
commit 0b710dd86a

View File

@ -949,6 +949,28 @@ class Linux(Platform):
def _is_open(self, fd):
return fd >= 0 and fd < len(self.files) and self.files[fd] is not None
def sys_umask(self, mask):
'''
umask - Set file creation mode mask
:param int mask: New mask
'''
logger.debug("umask({:o})".format(mask))
return os.umask(mask)
def sys_chdir(self, path):
'''
chdir - Change current working directory
:param int path: Pointer to path
'''
path_str = self.current.read_string(path)
logger.debug("chdir({})".format(path_str))
try:
os.chdir(path_str)
return 0
except OSError as e:
return e.errno
def sys_lseek(self, fd, offset, whence):
'''
lseek - reposition read/write file offset