1 | /* |
---|
2 | * NOTE: The structure of the routines is identical to that of POSIX |
---|
3 | * Message_queues to leave the option of having unnamed message |
---|
4 | * queues at a future date. They are currently not part of the |
---|
5 | * POSIX standard but unnamed message_queues are. This is also |
---|
6 | * the reason for the apparently unnecessary tracking of |
---|
7 | * the process_shared attribute. [In addition to the fact that |
---|
8 | * it would be trivial to add pshared to the mq_attr structure |
---|
9 | * and have process private message queues.] |
---|
10 | * |
---|
11 | * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open |
---|
12 | * time. |
---|
13 | * |
---|
14 | * COPYRIGHT (c) 1989-2007. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.com/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #if HAVE_CONFIG_H |
---|
23 | #include "config.h" |
---|
24 | #endif |
---|
25 | |
---|
26 | #include <stdarg.h> |
---|
27 | |
---|
28 | #include <pthread.h> |
---|
29 | #include <limits.h> |
---|
30 | #include <errno.h> |
---|
31 | #include <fcntl.h> |
---|
32 | #include <mqueue.h> |
---|
33 | |
---|
34 | #include <rtems/system.h> |
---|
35 | #include <rtems/score/watchdog.h> |
---|
36 | #include <rtems/seterr.h> |
---|
37 | #include <rtems/posix/mqueue.h> |
---|
38 | #include <rtems/posix/time.h> |
---|
39 | |
---|
40 | /* |
---|
41 | * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281 |
---|
42 | */ |
---|
43 | |
---|
44 | int mq_setattr( |
---|
45 | mqd_t mqdes, |
---|
46 | const struct mq_attr *mqstat, |
---|
47 | struct mq_attr *omqstat |
---|
48 | ) |
---|
49 | { |
---|
50 | POSIX_Message_queue_Control_fd *the_mq_fd; |
---|
51 | CORE_message_queue_Control *the_core_mq; |
---|
52 | Objects_Locations location; |
---|
53 | |
---|
54 | if ( !mqstat ) |
---|
55 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
56 | |
---|
57 | the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location ); |
---|
58 | switch ( location ) { |
---|
59 | |
---|
60 | case OBJECTS_LOCAL: |
---|
61 | |
---|
62 | the_core_mq = &the_mq_fd->Queue->Message_queue; |
---|
63 | |
---|
64 | /* |
---|
65 | * Return the old values. |
---|
66 | */ |
---|
67 | |
---|
68 | if ( omqstat ) { |
---|
69 | omqstat->mq_flags = the_mq_fd->oflag; |
---|
70 | omqstat->mq_msgsize = the_core_mq->maximum_message_size; |
---|
71 | omqstat->mq_maxmsg = the_core_mq->maximum_pending_messages; |
---|
72 | omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages; |
---|
73 | } |
---|
74 | |
---|
75 | the_mq_fd->oflag = mqstat->mq_flags; |
---|
76 | _Thread_Enable_dispatch(); |
---|
77 | return 0; |
---|
78 | |
---|
79 | #if defined(RTEMS_MULTIPROCESSING) |
---|
80 | case OBJECTS_REMOTE: |
---|
81 | #endif |
---|
82 | case OBJECTS_ERROR: |
---|
83 | break; |
---|
84 | } |
---|
85 | |
---|
86 | rtems_set_errno_and_return_minus_one( EBADF ); |
---|
87 | } |
---|