This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new df099c09c7e libs/libc: Apply the file mode creation mask in mkfifo().
df099c09c7e is described below
commit df099c09c7ea304667e068476947b1ac1a62647a
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 19 00:12:50 2026 +0200
libs/libc: Apply the file mode creation mask in mkfifo().
POSIX: mkfifo() clears the bits of the file mode creation mask in the
permissions of the new FIFO. mkfifo() gave the mode to nx_mkfifo()
unchanged, so a FIFO had the permissions 0666 after umask(077) and
mkfifo(path, 0666). mknod() with S_IFIFO calls mkfifo() and had the
same problem.
mkfifo() now clears the bits of getumask() in the mode. The reference
documentation said that the mode is ignored. NuttX keeps the mode
with CONFIG_PSEUDOFS_ATTRIBUTES, so the documentation now says that.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
Documentation/reference/user/10_filesystem.rst | 7 +++++--
libs/libc/misc/lib_mkfifo.c | 5 +++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Documentation/reference/user/10_filesystem.rst
b/Documentation/reference/user/10_filesystem.rst
index 1cf5439b198..2eb42f0895b 100644
--- a/Documentation/reference/user/10_filesystem.rst
+++ b/Documentation/reference/user/10_filesystem.rst
@@ -432,7 +432,9 @@ Pipes and FIFOs
mkfifo() makes a FIFO device driver file with name pathname. Unlike Linux,
a NuttX FIFO is not a special file type but simply a device driver instance.
- mode specifies the FIFO's permissions (but is ignored in the current
implementation).
+ mode specifies the FIFO's permissions. The file mode creation mask
+ (``umask()``) clears bits in it. NuttX keeps the permissions only with
+ ``CONFIG_PSEUDOFS_ATTRIBUTES``.
Once the FIFO has been created by mkfifo(), any thread can open it for
reading
or writing, in the same way as an ordinary file. However, it must have been
@@ -449,7 +451,8 @@ Pipes and FIFOs
:param pathname: The full path to the FIFO instance to attach to or to
create (if not already created).
- :param mode: Ignored for now
+ :param mode: The permissions of the FIFO, less the bits in the file mode
+ creation mask.
:return: 0 is returned on success; otherwise, -1 is returned with errno set
appropriately.
diff --git a/libs/libc/misc/lib_mkfifo.c b/libs/libc/misc/lib_mkfifo.c
index bf0c907f2af..d0e6a6bab4b 100644
--- a/libs/libc/misc/lib_mkfifo.c
+++ b/libs/libc/misc/lib_mkfifo.c
@@ -61,7 +61,8 @@
* Input Parameters:
* pathname - The full path to the FIFO instance to attach to or to create
* (if not already created).
- * mode - Ignored for now
+ * mode - The permissions of the FIFO. The file mode creation mask
+ * (umask) clears bits in it.
*
* Returned Value:
* 0 is returned on success; otherwise, -1 is returned with errno set
@@ -73,7 +74,7 @@ int mkfifo(FAR const char *pathname, mode_t mode)
{
int ret;
- ret = nx_mkfifo(pathname, mode, CONFIG_DEV_FIFO_SIZE);
+ ret = nx_mkfifo(pathname, mode & ~getumask(), CONFIG_DEV_FIFO_SIZE);
if (ret < 0)
{
set_errno(-ret);