Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
ID(interrupt) \
ID(portCreate) \
ID(portDestroy) \
ID(portRegister) \
ID(sys_portRegister) \
ID(sys_portUnregister) \
ID(msgSend) \
ID(msgRecv) \
ID(msgRespond) \
Expand Down
8 changes: 5 additions & 3 deletions proc/name.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int proc_portRegister(unsigned int port, const char *name, oid_t *oid)
}


void proc_portUnregister(const char *name)
int proc_portUnregister(const char *name)
{
dcache_entry_t *entry, *prev = NULL;
unsigned int hash = dcache_strHash(name);
Expand All @@ -130,18 +130,20 @@ void proc_portUnregister(const char *name)
if (entry == NULL) {
/* There is no such entry, nothing to do */
(void)proc_lockClear(&name_common.dcache_lock);
return;
return -ENOENT;
}

if (prev != NULL) {
prev->next = entry->next;
}
else {
name_common.dcache[hash] = NULL;
name_common.dcache[hash] = entry->next;
}
(void)proc_lockClear(&name_common.dcache_lock);

vm_kfree(entry);

return EOK;
}


Expand Down
2 changes: 1 addition & 1 deletion proc/name.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
int proc_portRegister(u32 port, const char *name, oid_t *oid);


void proc_portUnregister(const char *name);
int proc_portUnregister(const char *name);


int proc_portLookup(const char *name, oid_t *file, oid_t *dev);
Expand Down
37 changes: 29 additions & 8 deletions syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,27 +758,48 @@ void syscalls_portDestroy(u8 *ustack)
}


int syscalls_portRegister(u8 *ustack)
int syscalls_sys_portRegister(u8 *ustack)
{
process_t *proc = proc_current()->process;
unsigned int port;
char *name;
u32 port;
const char *name;
size_t len;
oid_t *oid;

GETFROMSTACK(ustack, unsigned int, port, 0U);
GETFROMSTACK(ustack, char *, name, 1U);
GETFROMSTACK(ustack, oid_t *, oid, 2U);

/* FIXME: Pass strlen(name) from userspace */
GETFROMSTACK(ustack, u32, port, 0U);
GETFROMSTACK(ustack, const char *, name, 1U);
GETFROMSTACK(ustack, size_t, len, 2U);
GETFROMSTACK(ustack, oid_t *, oid, 3U);

if (vm_mapBelongs(proc, oid, sizeof(*oid)) < 0) {
return -EFAULT;
}

if (vm_mapBelongs(proc, name, len) < 0) {
return -EFAULT;
}

return proc_portRegister(port, name, oid);
}


int syscalls_sys_portUnregister(u8 *ustack)
{
process_t *proc = proc_current()->process;
const char *name;
size_t len;

GETFROMSTACK(ustack, const char *, name, 0U);
GETFROMSTACK(ustack, size_t, len, 1U);

if (vm_mapBelongs(proc, name, len) < 0) {
return -EFAULT;
}

return proc_portUnregister(name);
}


int syscalls_msgSend(u8 *ustack)
{
process_t *proc = proc_current()->process;
Expand Down
Loading