Kernel+LibC: Add stubs for POSIX shared memory API.

Specifically shm_open() and shm_unlink(). This patch just adds stubs.
This commit is contained in:
Andreas Kling 2019-04-08 23:44:12 +02:00
parent 7f2eeb0b35
commit 99f3cc26c3
Notes: sideshowbarker 2024-07-19 14:47:25 +09:00
6 changed files with 36 additions and 0 deletions

View file

@ -2454,3 +2454,17 @@ int Process::sys$rename(const char* oldpath, const char* newpath)
return -EFAULT;
return VFS::the().rename(String(oldpath), String(newpath), cwd_inode());
}
int Process::sys$shm_open(const char* name, int flags, mode_t mode)
{
if (!validate_read_str(name))
return -EFAULT;
return -ENOTIMPL;
}
int Process::sys$shm_unlink(const char* name)
{
if (!validate_read_str(name))
return -EFAULT;
return -ENOTIMPL;
}

View file

@ -99,6 +99,8 @@ public:
int sys$gettid();
int sys$donate(int tid);
int sys$shm_open(const char* name, int flags, mode_t);
int sys$shm_unlink(const char* name);
pid_t sys$setsid();
pid_t sys$getsid(pid_t);
int sys$setpgid(pid_t pid, pid_t pgid);

View file

@ -243,6 +243,10 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
return current->process().sys$create_thread((int(*)(void*))arg1, (void*)arg2);
case Syscall::SC_rename:
return current->process().sys$rename((const char*)arg1, (const char*)arg2);
case Syscall::SC_shm_open:
return current->process().sys$shm_open((const char*)arg1, (int)arg2, (mode_t)arg3);
case Syscall::SC_shm_close:
return current->process().sys$shm_unlink((const char*)arg1);
default:
kprintf("<%u> int0x82: Unknown function %u requested {%x, %x, %x}\n", current->process().pid(), function, arg1, arg2, arg3);
break;

View file

@ -96,6 +96,8 @@
__ENUMERATE_SYSCALL(gettid) \
__ENUMERATE_SYSCALL(donate) \
__ENUMERATE_SYSCALL(rename) \
__ENUMERATE_SYSCALL(shm_open) \
__ENUMERATE_SYSCALL(shm_close) \
namespace Syscall {

View file

@ -28,4 +28,16 @@ int set_mmap_name(void* addr, size_t size, const char* name)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int shm_open(const char* name, int flags, mode_t mode)
{
int rc = syscall(SC_shm_open, name, flags, mode);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int shm_unlink(const char* name)
{
int rc = syscall(SC_unlink, name);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -21,6 +21,8 @@ __BEGIN_DECLS
void* mmap(void* addr, size_t, int prot, int flags, int fd, off_t);
int munmap(void*, size_t);
int set_mmap_name(void*, size_t, const char*);
int shm_open(const char* name, int flags, mode_t);
int shm_unlink(const char* name);
__END_DECLS