Commit 057adc41 authored by Florian Bezdeka's avatar Florian Bezdeka Committed by Jan Kiszka
Browse files

cobalt/posix/semaphore: Export named semaphores to procfs



Exporting named semaphores to /proc/xenomai/registry/posix/sem helps
to identify resource leaks by making registered semaphores visible. The
content of all created virtual files is empty. Removal of such files is
not possible and reports "operation not supported".
Signed-off-by: default avatarFlorian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent db52c656
......@@ -26,6 +26,38 @@
#include "sem.h"
#include <trace/events/cobalt-posix.h>
#ifdef CONFIG_XENO_OPT_VFILE
static int sem_vfile_show(struct xnvfile_regular_iterator *it, void *data)
{
return 0;
}
static struct xnvfile_regular_ops sem_vfile_ops = {
.show = sem_vfile_show,
};
static struct xnpnode_regular __sem_pnode = {
.node = {
.dirname = "sem",
.root = &posix_ptree,
.ops = &xnregistry_vfreg_ops,
},
.vfile = {
.ops = &sem_vfile_ops,
},
};
#else /* !CONFIG_XENO_OPT_VFILE */
static struct xnpnode_link __sem_pnode = {
.node = {
.dirname = "sem",
}
};
#endif /* !CONFIG_XENO_OPT_VFILE */
static inline struct cobalt_resources *sem_kqueue(struct cobalt_sem *sem)
{
int pshared = !!(sem->flags & SEM_PSHARED);
......@@ -134,7 +166,8 @@ __cobalt_sem_init(const char *name, struct cobalt_sem_shadow *sm,
goto err_lock_put;
}
ret = xnregistry_enter(name ?: "", sem, &sem->resnode.handle, NULL);
ret = xnregistry_enter(name ?: "", sem, &sem->resnode.handle,
name ? &__sem_pnode.node : NULL);
if (ret < 0)
goto err_lock_put;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment