I'm calling mq_open
on linux 5.5.6
like so:
mq_open("/testing12345", O_RDWR | O_CREAT | O_NONBLOCK, 0777, & (struct mq_attr) {0, 10, 255, 0));
Note that I passed 0777
as the 3rd argument.
The function succeeds and the appropriate mqueue is created, after which I mount the mqueue filesystem from my shell:
mount -t mqueue none ./mqueue_dir
However, stat-ing the new mqueue's node reveals 0755
as the access bits:
stat -c %a ./mqueue_dir/testing12345
0755
Why is that? I clearly passed the 0777
constant when calling mq_open.
Reproducible example
compiled with gcc -Wall -Werror -lrt a.c -o ./a
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <mqueue.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(void) {
const mqd_t descriptor = mq_open("/testing12345", O_RDWR | O_CREAT | O_NONBLOCK, 0777, & (struct mq_attr) {0, 10, 255, 0});
if(descriptor == -1) {
perror("parent: failed opening mqueue");
return EXIT_FAILURE;
}
sleep(30u);
mq_unlink("/testing123");
return EXIT_SUCCESS;
}