sys_mq_open  [ipc/mqueue.c]


Creates new POSIX message queue or opens an existing queue.

Arguments

eax 277
ebx Pointer to a null-terminated string specifying the message queue name.
ecx Message queue access mode. Which must be include following flags:
O_RDONLY Open the queue to receive messages only.
O_WRONLY Open the queue to send messages only.
O_RDWR Open the queue to both send and receive messages.
And may include also the following flags:
O_NONBLOCK Open the queue in non-blocking mode.
O_CREAT Create the message queue if it does not exist. The owner (user ID) of the message queue is set to the effective user ID of the calling process. The group ownership (group ID) is set to the effective group ID of the calling process.
O_EXCL If O_CREAT was specified in ecx, and a queue with the given name already exists, then fail with the error -EEXIST.
edx Permissions to be placed on the new queue:
S_IRUSR  - owner has read permission
S_IWUSR  - owner has write permission
S_IRGRP  - group has read permission
S_IWGRP  - group has write permission
S_IROTH  - others have read permission
S_IWOTH  - others have write permission
esi Pointer to a mq_attr structure specifying attributes for the queue. If esi is NULL, then the queue is created with implementation-defined default attributes.
mq_attr defined as follows:
struc mq_attr
{
.mq_flags   rd 1
.mq_maxmsg  rd 1
.mq_msgsize rd 1
.mq_curmsgs rd 1
.__reserved rd 4
}

mq_attr members:

mq_flags

Message queue flags.
mq_maxmsg
The maximum number of messages allowed.
mq_msgsize
The maximum message size.
mq_curmsg
Number of messages on the queue.
__reserved
Not used.

Return values

If the system call succeeds the return value is a message queue descriptor for use by other message queue functions.
If the system call fails the return value is one of the following errno values:

-EACCESS The queue exists, but the caller does not have permission to open it in the specified mode.
-EEXIST Both O_CREAT and O_EXCL were specified in ecx, but a queue with the given name already exists
-EMFILE The process already has the maximum number of files and message queues open.
-ENAMETOOLONG name was too long.
-ENFILE The system limit on the total number of open files and message queues has been reached.
-ENOENT The O_CREAT flag was not specified in ecx, and no queue with this name exists.
-ENOMEM Insufficient memory.
-ENOSPC Insufficient space for the creation of a new message queue. This probably occurred because the queues_max limit was encountered;

Remarks

In kernels before 2.6.14, the process umask was not applied to the permissions specified in edx.

See samples/ipc/posix_msg.asm for an example.

Compatibility

n/a