All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [Patch] Anonymous (NULL-named) objects from user-space
@ 2005-10-19 20:18 Dmitry Adamushko
  2005-10-20 10:32 ` [Xenomai-core] " Philippe Gerum
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Adamushko @ 2005-10-19 20:18 UTC (permalink / raw)
  To: xenomai; +Cc: dmitry.adamushko

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]


Hi,

anonymous objects (name == NULL) from user-space get registered under unique 
names, - which is a string representation of the object's kernel-space 
address, - but remain not-exported via the /proc interface.

Not tested with the all objects yet (well, I have upgraded the system, a 
compiler in particular err..., so I cannot load the recently rebuilt xeno_* 
modules at the moment), but the changes are not intrusive so everything 
should work as expected.


---
Best regards,
Dmitry

[-- Attachment #2: anonym.patch --]
[-- Type: text/x-diff, Size: 357 bytes --]

--- types.h	2005-10-19 20:59:21.000000000 +0200
+++ types2.h	2005-10-19 21:07:44.000000000 +0200
@@ -91,6 +91,12 @@
 	*dst = '\0';
 }
 
+static inline int xnobject_create_name(
+		    char *dst, size_t n, void *obj)
+{
+    return snprintf(dst, n, "%p", obj);
+}
+
 #define minval(a,b) ((a) < (b) ? (a) : (b))
 #define maxval(a,b) ((a) > (b) ? (a) : (b))
 

[-- Attachment #3: anonym_objs.patch --]
[-- Type: text/x-diff, Size: 6950 bytes --]

diff -ur native/alarm.c native2/alarm.c
--- native/alarm.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/alarm.c	2005-10-19 21:14:59.000000000 +0200
@@ -208,9 +208,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(alarm->name,alarm,&alarm->handle,&__alarm_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__alarm_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(alarm->name,sizeof(alarm->name),(void*)alarm);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(alarm->name,alarm,&alarm->handle,pnode);
 
         if (err)
             rt_alarm_delete(alarm);
diff -ur native/cond.c native2/cond.c
--- native/cond.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/cond.c	2005-10-19 21:15:07.000000000 +0200
@@ -168,9 +168,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(cond->name,cond,&cond->handle,&__cond_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__cond_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(cond->name,sizeof(cond->name),(void*)cond);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(cond->name,cond,&cond->handle,pnode);
 
         if (err)
             rt_cond_delete(cond);
diff -ur native/event.c native2/event.c
--- native/event.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/event.c	2005-10-19 21:15:11.000000000 +0200
@@ -190,9 +190,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(event->name,event,&event->handle,&__event_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__event_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(event->name,sizeof(event->name),(void*)event);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(event->name,event,&event->handle,pnode);
 
         if (err)
             rt_event_delete(event);
diff -ur native/heap.c native2/heap.c
--- native/heap.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/heap.c	2005-10-19 21:17:42.000000000 +0200
@@ -287,9 +287,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(heap->name,heap,&heap->handle,&__heap_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__heap_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(heap->name,sizeof(heap->name),(void*)heap);
+	    pnode = NULL;
+	    }
+
+        err = rt_registry_enter(heap->name,heap,&heap->handle,pnode);
 
         if (err)
             rt_heap_delete(heap);
diff -ur native/mutex.c native2/mutex.c
--- native/mutex.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/mutex.c	2005-10-19 21:09:00.000000000 +0200
@@ -181,9 +181,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(mutex->name,mutex,&mutex->handle,&__mutex_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__mutex_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(mutex->name,sizeof(mutex->name),(void*)mutex);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(mutex->name,mutex,&mutex->handle,pnode);
 
         if (err)
             rt_mutex_delete(mutex);
diff -ur native/pipe.c native2/pipe.c
--- native/pipe.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/pipe.c	2005-10-19 21:22:42.000000000 +0200
@@ -257,9 +257,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(pipe->name,pipe,&pipe->handle,&__pipe_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__pipe_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(pipe->name,sizeof(pipe->name),(void*)pipe);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(pipe->name,pipe,&pipe->handle,pnode);
 
         if (err)
             rt_pipe_delete(pipe);
diff -ur native/queue.c native2/queue.c
--- native/queue.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/queue.c	2005-10-19 21:24:51.000000000 +0200
@@ -281,9 +281,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(q->name,q,&q->handle,&__queue_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__queue_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(q->name,sizeof(q->name),(void*)q);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(q->name,q,&q->handle,pnode);
 
         if (err)
             rt_queue_delete(q);
diff -ur native/sem.c native2/sem.c
--- native/sem.c	2005-10-10 19:15:08.000000000 +0200
+++ native2/sem.c	2005-10-19 21:26:47.000000000 +0200
@@ -193,9 +193,19 @@
        complete objects, so that the registry cannot return handles to
        half-baked objects... */
 
-    if (name && *name)
+    if (name)
         {
-        err = rt_registry_enter(sem->name,sem,&sem->handle,&__sem_pnode);
+	RT_OBJECT_PROCNODE *pnode = &__sem_pnode;
+	
+	if (!*name)
+	    {
+	    /* Since this is an anonymous object (NULL-named) from user-space,
+	       it gets registratred under an unique name but remains not-exported via /proc */
+	    xnobject_create_name(sem->name,sizeof(sem->name),(void*)sem);
+	    pnode = NULL;
+	    }
+	    
+        err = rt_registry_enter(sem->name,sem,&sem->handle,pnode);
 
         if (err)
             rt_sem_delete(sem);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Xenomai-core] Re: [Patch] Anonymous (NULL-named) objects from user-space
  2005-10-19 20:18 [Xenomai-core] [Patch] Anonymous (NULL-named) objects from user-space Dmitry Adamushko
@ 2005-10-20 10:32 ` Philippe Gerum
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Gerum @ 2005-10-20 10:32 UTC (permalink / raw)
  To: Dmitry Adamushko; +Cc: dmitry.adamushko, xenomai

Dmitry Adamushko wrote:
> Hi,
> 
> anonymous objects (name == NULL) from user-space get registered under unique 
> names, - which is a string representation of the object's kernel-space 
> address, - but remain not-exported via the /proc interface.
> 

Applied (fixing the comment), thanks.

> Not tested with the all objects yet (well, I have upgraded the system, a 
> compiler in particular err..., so I cannot load the recently rebuilt xeno_* 
> modules at the moment), but the changes are not intrusive so everything 
> should work as expected.
> 

Should be ok.

> 
> ---
> Best regards,
> Dmitry
> 
> 
> ------------------------------------------------------------------------
> 
> --- types.h	2005-10-19 20:59:21.000000000 +0200
> +++ types2.h	2005-10-19 21:07:44.000000000 +0200
> @@ -91,6 +91,12 @@
>  	*dst = '\0';
>  }
>  
> +static inline int xnobject_create_name(
> +		    char *dst, size_t n, void *obj)
> +{
> +    return snprintf(dst, n, "%p", obj);
> +}
> +
>  #define minval(a,b) ((a) < (b) ? (a) : (b))
>  #define maxval(a,b) ((a) > (b) ? (a) : (b))
>  
> 
> 
> ------------------------------------------------------------------------
> 
> diff -ur native/alarm.c native2/alarm.c
> --- native/alarm.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/alarm.c	2005-10-19 21:14:59.000000000 +0200
> @@ -208,9 +208,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(alarm->name,alarm,&alarm->handle,&__alarm_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__alarm_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(alarm->name,sizeof(alarm->name),(void*)alarm);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(alarm->name,alarm,&alarm->handle,pnode);
>  
>          if (err)
>              rt_alarm_delete(alarm);
> diff -ur native/cond.c native2/cond.c
> --- native/cond.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/cond.c	2005-10-19 21:15:07.000000000 +0200
> @@ -168,9 +168,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(cond->name,cond,&cond->handle,&__cond_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__cond_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(cond->name,sizeof(cond->name),(void*)cond);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(cond->name,cond,&cond->handle,pnode);
>  
>          if (err)
>              rt_cond_delete(cond);
> diff -ur native/event.c native2/event.c
> --- native/event.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/event.c	2005-10-19 21:15:11.000000000 +0200
> @@ -190,9 +190,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(event->name,event,&event->handle,&__event_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__event_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(event->name,sizeof(event->name),(void*)event);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(event->name,event,&event->handle,pnode);
>  
>          if (err)
>              rt_event_delete(event);
> diff -ur native/heap.c native2/heap.c
> --- native/heap.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/heap.c	2005-10-19 21:17:42.000000000 +0200
> @@ -287,9 +287,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(heap->name,heap,&heap->handle,&__heap_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__heap_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(heap->name,sizeof(heap->name),(void*)heap);
> +	    pnode = NULL;
> +	    }
> +
> +        err = rt_registry_enter(heap->name,heap,&heap->handle,pnode);
>  
>          if (err)
>              rt_heap_delete(heap);
> diff -ur native/mutex.c native2/mutex.c
> --- native/mutex.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/mutex.c	2005-10-19 21:09:00.000000000 +0200
> @@ -181,9 +181,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(mutex->name,mutex,&mutex->handle,&__mutex_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__mutex_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(mutex->name,sizeof(mutex->name),(void*)mutex);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(mutex->name,mutex,&mutex->handle,pnode);
>  
>          if (err)
>              rt_mutex_delete(mutex);
> diff -ur native/pipe.c native2/pipe.c
> --- native/pipe.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/pipe.c	2005-10-19 21:22:42.000000000 +0200
> @@ -257,9 +257,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(pipe->name,pipe,&pipe->handle,&__pipe_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__pipe_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(pipe->name,sizeof(pipe->name),(void*)pipe);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(pipe->name,pipe,&pipe->handle,pnode);
>  
>          if (err)
>              rt_pipe_delete(pipe);
> diff -ur native/queue.c native2/queue.c
> --- native/queue.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/queue.c	2005-10-19 21:24:51.000000000 +0200
> @@ -281,9 +281,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(q->name,q,&q->handle,&__queue_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__queue_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(q->name,sizeof(q->name),(void*)q);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(q->name,q,&q->handle,pnode);
>  
>          if (err)
>              rt_queue_delete(q);
> diff -ur native/sem.c native2/sem.c
> --- native/sem.c	2005-10-10 19:15:08.000000000 +0200
> +++ native2/sem.c	2005-10-19 21:26:47.000000000 +0200
> @@ -193,9 +193,19 @@
>         complete objects, so that the registry cannot return handles to
>         half-baked objects... */
>  
> -    if (name && *name)
> +    if (name)
>          {
> -        err = rt_registry_enter(sem->name,sem,&sem->handle,&__sem_pnode);
> +	RT_OBJECT_PROCNODE *pnode = &__sem_pnode;
> +	
> +	if (!*name)
> +	    {
> +	    /* Since this is an anonymous object (NULL-named) from user-space,
> +	       it gets registratred under an unique name but remains not-exported via /proc */
> +	    xnobject_create_name(sem->name,sizeof(sem->name),(void*)sem);
> +	    pnode = NULL;
> +	    }
> +	    
> +        err = rt_registry_enter(sem->name,sem,&sem->handle,pnode);
>  
>          if (err)
>              rt_sem_delete(sem);


-- 

Philippe.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-10-20 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-19 20:18 [Xenomai-core] [Patch] Anonymous (NULL-named) objects from user-space Dmitry Adamushko
2005-10-20 10:32 ` [Xenomai-core] " Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.