Changeset d4548d1 in rtems


Ignore:
Timestamp:
Dec 23, 1999, 10:07:11 PM (20 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
96d4aea
Parents:
e1786ee3
Message:

+ Made work
+ Added checks for valid attribute maxmsg and msgsize
+ Added check for ENAMETOOLONG

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/posix/src/mqueuecreatesupp.c

    re1786ee3 rd4548d1  
    3838  int                            pshared,
    3939  unsigned int                   oflag,
    40   struct mq_attr                *attr,
     40  struct mq_attr                *attr_ptr,
    4141  POSIX_Message_queue_Control  **message_queue
    4242)
    4343{
    4444  POSIX_Message_queue_Control   *the_mq;
    45  
     45  CORE_message_queue_Attributes *the_mq_attr;
     46  struct mq_attr                 attr;
     47
    4648  _Thread_Disable_dispatch();
    4749 
    48   the_mq = _POSIX_Message_queue_Allocate();
    49  
    50   if ( !the_mq ) {
    51     _Thread_Enable_dispatch();
    52     set_errno_and_return_minus_one( ENFILE );
     50  if ( attr_ptr == NULL ) {
     51    attr.mq_maxmsg  = 0;  /* XXX */
     52    attr.mq_msgsize = 0;  /* XXX */
     53  } else {
     54    if ( attr_ptr->mq_maxmsg < 0 ){
     55      _Thread_Enable_dispatch();
     56      set_errno_and_return_minus_one( EINVAL );
     57    }
     58
     59    if ( attr_ptr->mq_msgsize < 0 ){
     60      _Thread_Enable_dispatch();
     61      set_errno_and_return_minus_one( EINVAL );
     62    }
     63
     64    attr = *attr_ptr;
    5365  }
    54  
     66
    5567#if defined(RTEMS_MULTIPROCESSING)
    5668  if ( pshared == PTHREAD_PROCESS_SHARED &&
     
    6375#endif
    6476 
     77  if ( name ) {
     78
     79    if( strlen(name) > PATH_MAX ) {  /* XXX - Is strlen ok to use here ? */
     80      _Thread_Enable_dispatch();
     81      set_errno_and_return_minus_one( ENAMETOOLONG );
     82    }
     83
     84    /*
     85     * XXX Greater than NAME_MAX while POSIX_NO_TRUNC in effect.
     86     * XXX Error description in POSIX book different for mq_open and mq_unlink
     87     *     Why???
     88     */
     89  }
     90
     91  the_mq = _POSIX_Message_queue_Allocate();
     92  if ( !the_mq ) {
     93    _Thread_Enable_dispatch();
     94    set_errno_and_return_minus_one( ENFILE );
     95  }
     96 
    6597  the_mq->process_shared  = pshared;
    6698 
     
    69101    the_mq->open_count = 1;
    70102    the_mq->linked = TRUE;
     103 }
     104  else {
     105    the_mq->named = FALSE;
     106
    71107  }
    72   else
    73     the_mq->named = FALSE;
    74  
     108
    75109  if ( oflag & O_NONBLOCK )
    76110    the_mq->blocking = FALSE;
     
    91125  the_mq_attr->waiting_discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    92126 */
     127   
    93128
    94129  the_mq->Message_queue.Attributes.discipline =
    95130                                         CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    96  
     131  the_mq_attr = &the_mq->Message_queue.Attributes;
     132
    97133  if ( ! _CORE_message_queue_Initialize(
    98134           &the_mq->Message_queue,
    99135           OBJECTS_POSIX_MESSAGE_QUEUES,
    100            &the_mq->Message_queue.Attributes,
    101            attr->mq_maxmsg,
    102            attr->mq_msgsize,
     136           the_mq_attr,
     137           attr.mq_maxmsg,
     138           attr.mq_msgsize,
    103139#if defined(RTEMS_MULTIPROCESSING)
    104140           _POSIX_Message_queue_MP_Send_extract_proxy
     
    142178}
    143179
     180
     181
     182
     183
  • cpukit/posix/src/mqueuecreatesupp.c

    re1786ee3 rd4548d1  
    3838  int                            pshared,
    3939  unsigned int                   oflag,
    40   struct mq_attr                *attr,
     40  struct mq_attr                *attr_ptr,
    4141  POSIX_Message_queue_Control  **message_queue
    4242)
    4343{
    4444  POSIX_Message_queue_Control   *the_mq;
    45  
     45  CORE_message_queue_Attributes *the_mq_attr;
     46  struct mq_attr                 attr;
     47
    4648  _Thread_Disable_dispatch();
    4749 
    48   the_mq = _POSIX_Message_queue_Allocate();
    49  
    50   if ( !the_mq ) {
    51     _Thread_Enable_dispatch();
    52     set_errno_and_return_minus_one( ENFILE );
     50  if ( attr_ptr == NULL ) {
     51    attr.mq_maxmsg  = 0;  /* XXX */
     52    attr.mq_msgsize = 0;  /* XXX */
     53  } else {
     54    if ( attr_ptr->mq_maxmsg < 0 ){
     55      _Thread_Enable_dispatch();
     56      set_errno_and_return_minus_one( EINVAL );
     57    }
     58
     59    if ( attr_ptr->mq_msgsize < 0 ){
     60      _Thread_Enable_dispatch();
     61      set_errno_and_return_minus_one( EINVAL );
     62    }
     63
     64    attr = *attr_ptr;
    5365  }
    54  
     66
    5567#if defined(RTEMS_MULTIPROCESSING)
    5668  if ( pshared == PTHREAD_PROCESS_SHARED &&
     
    6375#endif
    6476 
     77  if ( name ) {
     78
     79    if( strlen(name) > PATH_MAX ) {  /* XXX - Is strlen ok to use here ? */
     80      _Thread_Enable_dispatch();
     81      set_errno_and_return_minus_one( ENAMETOOLONG );
     82    }
     83
     84    /*
     85     * XXX Greater than NAME_MAX while POSIX_NO_TRUNC in effect.
     86     * XXX Error description in POSIX book different for mq_open and mq_unlink
     87     *     Why???
     88     */
     89  }
     90
     91  the_mq = _POSIX_Message_queue_Allocate();
     92  if ( !the_mq ) {
     93    _Thread_Enable_dispatch();
     94    set_errno_and_return_minus_one( ENFILE );
     95  }
     96 
    6597  the_mq->process_shared  = pshared;
    6698 
     
    69101    the_mq->open_count = 1;
    70102    the_mq->linked = TRUE;
     103 }
     104  else {
     105    the_mq->named = FALSE;
     106
    71107  }
    72   else
    73     the_mq->named = FALSE;
    74  
     108
    75109  if ( oflag & O_NONBLOCK )
    76110    the_mq->blocking = FALSE;
     
    91125  the_mq_attr->waiting_discipline = CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    92126 */
     127   
    93128
    94129  the_mq->Message_queue.Attributes.discipline =
    95130                                         CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO;
    96  
     131  the_mq_attr = &the_mq->Message_queue.Attributes;
     132
    97133  if ( ! _CORE_message_queue_Initialize(
    98134           &the_mq->Message_queue,
    99135           OBJECTS_POSIX_MESSAGE_QUEUES,
    100            &the_mq->Message_queue.Attributes,
    101            attr->mq_maxmsg,
    102            attr->mq_msgsize,
     136           the_mq_attr,
     137           attr.mq_maxmsg,
     138           attr.mq_msgsize,
    103139#if defined(RTEMS_MULTIPROCESSING)
    104140           _POSIX_Message_queue_MP_Send_extract_proxy
     
    142178}
    143179
     180
     181
     182
     183
Note: See TracChangeset for help on using the changeset viewer.