summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/mqueuecreatesupp.c21
-rw-r--r--cpukit/posix/src/mqueuenametoid.c67
-rw-r--r--cpukit/posix/src/mqueueopen.c4
-rw-r--r--cpukit/posix/src/mqueuesendsupp.c4
-rw-r--r--cpukit/posix/src/mqueueunlink.c3
-rw-r--r--cpukit/posix/src/psxnametoid.c58
-rw-r--r--cpukit/posix/src/semaphorecreatesupp.c32
-rw-r--r--cpukit/posix/src/semaphorenametoid.c62
-rw-r--r--cpukit/posix/src/seminit.c1
-rw-r--r--cpukit/posix/src/semopen.c14
-rw-r--r--cpukit/posix/src/semunlink.c5
11 files changed, 104 insertions, 167 deletions
diff --git a/cpukit/posix/src/mqueuecreatesupp.c b/cpukit/posix/src/mqueuecreatesupp.c
index bad22b536d..5941137d3e 100644
--- a/cpukit/posix/src/mqueuecreatesupp.c
+++ b/cpukit/posix/src/mqueuecreatesupp.c
@@ -42,9 +42,6 @@
#include <rtems/posix/mqueue.h>
#include <rtems/posix/time.h>
-/* pure ANSI mode does not have this prototype */
-size_t strnlen(const char *, size_t);
-
/*
* _POSIX_Message_queue_Create_support
*
@@ -54,6 +51,7 @@ size_t strnlen(const char *, size_t);
int _POSIX_Message_queue_Create_support(
const char *name_arg,
+ size_t name_len,
int pshared,
struct mq_attr *attr_ptr,
POSIX_Message_queue_Control **message_queue
@@ -63,9 +61,7 @@ int _POSIX_Message_queue_Create_support(
CORE_message_queue_Attributes *the_mq_attr;
struct mq_attr attr;
char *name;
- size_t n;
- n = strnlen( name_arg, NAME_MAX );
/* length of name has already been validated */
_Thread_Disable_dispatch();
@@ -99,22 +95,21 @@ int _POSIX_Message_queue_Create_support(
rtems_set_errno_and_return_minus_one( ENFILE );
}
- the_mq->process_shared = pshared;
- the_mq->named = true;
- the_mq->open_count = 1;
- the_mq->linked = true;
-
/*
* Make a copy of the user's string for name just in case it was
* dynamically constructed.
*/
- name = _Workspace_Allocate(n+1);
- if (!name) {
+ name = _Workspace_String_duplicate( name_arg, name_len );
+ if ( !name ) {
_POSIX_Message_queue_Free( the_mq );
_Thread_Enable_dispatch();
rtems_set_errno_and_return_minus_one( ENOMEM );
}
- strncpy( name, name_arg, n+1 );
+
+ the_mq->process_shared = pshared;
+ the_mq->named = true;
+ the_mq->open_count = 1;
+ the_mq->linked = true;
/*
* NOTE: That thread blocking discipline should be based on the
diff --git a/cpukit/posix/src/mqueuenametoid.c b/cpukit/posix/src/mqueuenametoid.c
deleted file mode 100644
index f52e3383c2..0000000000
--- a/cpukit/posix/src/mqueuenametoid.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * COPYRIGHT (c) 1989-2009.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- *
- * $Id$
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdarg.h>
-
-#include <pthread.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <mqueue.h>
-
-#include <rtems/system.h>
-#include <rtems/score/watchdog.h>
-#include <rtems/seterr.h>
-#include <rtems/posix/mqueue.h>
-#include <rtems/posix/time.h>
-
-/* pure ANSI mode does not have this prototype */
-size_t strnlen(const char *, size_t);
-
-/*
- * _POSIX_Message_queue_Name_to_id
- *
- * Look up the specified name and attempt to locate the id
- * for the associated message queue.
- */
-int _POSIX_Message_queue_Name_to_id(
- const char *name,
- Objects_Id *id
-)
-{
- Objects_Name_or_id_lookup_errors status;
- Objects_Id the_id;
-
- if ( !name )
- return EINVAL;
-
- if ( !name[0] )
- return EINVAL;
-
- if ( strnlen( name, NAME_MAX ) >= NAME_MAX )
- return ENAMETOOLONG;
-
- status = _Objects_Name_to_id_string(
- &_POSIX_Message_queue_Information,
- name,
- &the_id
- );
- *id = the_id;
-
- if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL )
- return 0;
-
- return ENOENT;
-}
diff --git a/cpukit/posix/src/mqueueopen.c b/cpukit/posix/src/mqueueopen.c
index 96ec4dd40f..b6c9e0dc19 100644
--- a/cpukit/posix/src/mqueueopen.c
+++ b/cpukit/posix/src/mqueueopen.c
@@ -58,6 +58,7 @@ mqd_t mq_open(
POSIX_Message_queue_Control *the_mq;
POSIX_Message_queue_Control_fd *the_mq_fd;
Objects_Locations location;
+ size_t name_len;
_Thread_Disable_dispatch();
@@ -75,7 +76,7 @@ mqd_t mq_open(
}
the_mq_fd->oflag = oflag;
- status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
+ status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
/*
* If the name to id translation worked, then the message queue exists
@@ -128,6 +129,7 @@ mqd_t mq_open(
*/
status = _POSIX_Message_queue_Create_support(
name,
+ name_len,
true, /* shared across processes */
attr,
&the_mq
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 5fda0f1fe5..b04422dd2f 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -48,7 +48,7 @@ int _POSIX_Message_queue_Send_support(
mqd_t mqdes,
const char *msg_ptr,
size_t msg_len,
- uint32_t msg_prio,
+ unsigned int msg_prio,
bool wait,
Watchdog_Interval timeout
)
@@ -91,7 +91,7 @@ int _POSIX_Message_queue_Send_support(
*/
msg_status = _CORE_message_queue_Submit(
&the_mq->Message_queue,
- (void *)msg_ptr,
+ msg_ptr,
msg_len,
mqdes, /* mqd_t is an object id */
NULL,
diff --git a/cpukit/posix/src/mqueueunlink.c b/cpukit/posix/src/mqueueunlink.c
index c3ce967606..eced328a69 100644
--- a/cpukit/posix/src/mqueueunlink.c
+++ b/cpukit/posix/src/mqueueunlink.c
@@ -51,10 +51,11 @@ int mq_unlink(
int status;
register POSIX_Message_queue_Control *the_mq;
Objects_Id the_mq_id;
+ size_t name_len;
_Thread_Disable_dispatch();
- status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
+ status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id, &name_len );
if ( status != 0 ) {
_Thread_Enable_dispatch();
rtems_set_errno_and_return_minus_one( status );
diff --git a/cpukit/posix/src/psxnametoid.c b/cpukit/posix/src/psxnametoid.c
new file mode 100644
index 0000000000..b91f58e644
--- /dev/null
+++ b/cpukit/posix/src/psxnametoid.c
@@ -0,0 +1,58 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/posix/posixapi.h>
+
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+/* pure ANSI mode does not have this prototype */
+size_t strnlen(const char *, size_t);
+
+int _POSIX_Name_to_id(
+ Objects_Information *information,
+ const char *name,
+ Objects_Id *id,
+ size_t *len
+)
+{
+ int eno = EINVAL;
+ size_t n = 0;
+
+ if ( name != NULL && name [0] != '\0' ) {
+ n = strnlen( name, NAME_MAX );
+
+ if ( n < NAME_MAX ) {
+ Objects_Name_or_id_lookup_errors status = _Objects_Name_to_id_string(
+ information,
+ name,
+ id
+ );
+
+ if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) {
+ eno = 0;
+ } else {
+ eno = ENOENT;
+ }
+ } else {
+ eno = ENAMETOOLONG;
+ }
+ }
+
+ *len = n;
+
+ return eno;
+}
diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c
index 42e530bf07..7673b51752 100644
--- a/cpukit/posix/src/semaphorecreatesupp.c
+++ b/cpukit/posix/src/semaphorecreatesupp.c
@@ -24,13 +24,11 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
+#include <rtems/score/wkspace.h>
#include <rtems/posix/semaphore.h>
#include <rtems/posix/time.h>
#include <rtems/seterr.h>
-/* pure ANSI mode does not have this prototype */
-size_t strnlen(const char *, size_t);
-
/*
* _POSIX_Semaphore_Create_support
*
@@ -39,7 +37,8 @@ size_t strnlen(const char *, size_t);
* sem_open.
*/
int _POSIX_Semaphore_Create_support(
- const char *name,
+ const char *name_arg,
+ size_t name_len,
int pshared,
unsigned int value,
POSIX_Semaphore_Control **the_sem
@@ -47,26 +46,35 @@ int _POSIX_Semaphore_Create_support(
{
POSIX_Semaphore_Control *the_semaphore;
CORE_semaphore_Attributes *the_sem_attr;
- char *name_p = (char *)name;
+ char *name;
/* Sharing semaphores among processes is not currently supported */
if (pshared != 0)
rtems_set_errno_and_return_minus_one( ENOSYS );
- if ( name ) {
- if ( strnlen( name, NAME_MAX ) >= NAME_MAX )
- rtems_set_errno_and_return_minus_one( ENAMETOOLONG );
- }
-
_Thread_Disable_dispatch();
the_semaphore = _POSIX_Semaphore_Allocate();
-
if ( !the_semaphore ) {
_Thread_Enable_dispatch();
rtems_set_errno_and_return_minus_one( ENOSPC );
}
+ /*
+ * Make a copy of the user's string for name just in case it was
+ * dynamically constructed.
+ */
+ if ( name_arg != NULL ) {
+ name = _Workspace_String_duplicate( name_arg, name_len );
+ if ( !name ) {
+ _POSIX_Semaphore_Free( the_semaphore );
+ _Thread_Enable_dispatch();
+ rtems_set_errno_and_return_minus_one( ENOMEM );
+ }
+ } else {
+ name = NULL;
+ }
+
the_semaphore->process_shared = pshared;
if ( name ) {
@@ -103,7 +111,7 @@ int _POSIX_Semaphore_Create_support(
_Objects_Open_string(
&_POSIX_Semaphore_Information,
&the_semaphore->Object,
- name_p
+ name
);
*the_sem = the_semaphore;
diff --git a/cpukit/posix/src/semaphorenametoid.c b/cpukit/posix/src/semaphorenametoid.c
deleted file mode 100644
index a79d6d7233..0000000000
--- a/cpukit/posix/src/semaphorenametoid.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * COPYRIGHT (c) 1989-2007.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- *
- * $Id$
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <limits.h>
-
-#include <rtems/system.h>
-#include <rtems/score/object.h>
-#include <rtems/posix/semaphore.h>
-#include <rtems/posix/time.h>
-#include <rtems/seterr.h>
-
-/*
- * _POSIX_Semaphore_Name_to_id
- *
- * Look up the specified name and attempt to locate the id
- * for the associated semaphore.
- */
-
-int _POSIX_Semaphore_Name_to_id(
- const char *name,
- sem_t *id
-)
-{
- Objects_Name_or_id_lookup_errors status;
- Objects_Id the_id;
-
- if ( !name )
- return EINVAL;
-
- if ( !name[0] )
- return EINVAL;
-
- status = _Objects_Name_to_id_string(
- &_POSIX_Semaphore_Information,
- name,
- &the_id
- );
- *id = the_id;
-
- if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL )
- return 0;
-
- return ENOENT;
-}
diff --git a/cpukit/posix/src/seminit.c b/cpukit/posix/src/seminit.c
index 64848d8785..2ec803b8c4 100644
--- a/cpukit/posix/src/seminit.c
+++ b/cpukit/posix/src/seminit.c
@@ -45,6 +45,7 @@ int sem_init(
status = _POSIX_Semaphore_Create_support(
NULL,
+ 0,
pshared,
value,
&the_semaphore
diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
index 3354935eba..398d9e8450 100644
--- a/cpukit/posix/src/semopen.c
+++ b/cpukit/posix/src/semopen.c
@@ -51,10 +51,10 @@ sem_t *sem_open(
mode_t mode;
unsigned int value = 0;
int status;
- sem_t the_semaphore_id;
- sem_t *id;
+ Objects_Id the_semaphore_id;
POSIX_Semaphore_Control *the_semaphore;
Objects_Locations location;
+ size_t name_len;
_Thread_Disable_dispatch();
@@ -65,7 +65,7 @@ sem_t *sem_open(
va_end(arg);
}
- status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
+ status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
/*
* If the name to id translation worked, then the semaphore exists
@@ -96,7 +96,7 @@ sem_t *sem_open(
rtems_set_errno_and_return_minus_one_cast( EEXIST, sem_t * );
}
- the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location );
+ the_semaphore = _POSIX_Semaphore_Get( (sem_t *) &the_semaphore_id, &location );
the_semaphore->open_count += 1;
_Thread_Enable_dispatch();
_Thread_Enable_dispatch();
@@ -110,6 +110,7 @@ sem_t *sem_open(
status =_POSIX_Semaphore_Create_support(
name,
+ name_len,
false, /* not shared across processes */
value,
&the_semaphore
@@ -127,9 +128,8 @@ sem_t *sem_open(
return_id:
#if defined(RTEMS_USE_16_BIT_OBJECT)
the_semaphore->Semaphore_id = the_semaphore->Object.id;
- id = &the_semaphore->Semaphore_id;
+ return &the_semaphore->Semaphore_id;
#else
- id = (sem_t *)&the_semaphore->Object.id;
+ return (sem_t *)&the_semaphore->Object.id;
#endif
- return id;
}
diff --git a/cpukit/posix/src/semunlink.c b/cpukit/posix/src/semunlink.c
index 0292e8008b..ca566a6f9b 100644
--- a/cpukit/posix/src/semunlink.c
+++ b/cpukit/posix/src/semunlink.c
@@ -42,11 +42,12 @@ int sem_unlink(
{
int status;
register POSIX_Semaphore_Control *the_semaphore;
- sem_t the_semaphore_id;
+ Objects_Id the_semaphore_id;
+ size_t name_len;
_Thread_Disable_dispatch();
- status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id );
+ status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id, &name_len );
if ( status != 0 ) {
_Thread_Enable_dispatch();
rtems_set_errno_and_return_minus_one( status );