From 96cd2e390fc96fd0bf2e1f43c91c8fc9d80f302a Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Mon, 2 Dec 2024 14:39:16 -0300 Subject: [PATCH] dirent.h: Add `d_ino` member to `struct dirent` This commit adds the `d_ino` member (`ino_t` type) to struct dirent to make it compatible with the POSIX definition of the structure. According to https://pubs.opengroup.org/onlinepubs/9799919799/, the structure `dirent` shall include the following members: ``` ino_t d_ino File serial number. char d_name[] Filename string of entry. ``` https://www.man7.org/linux/man-pages/man3/readdir.3.html also states that: " Only the fields d_name and (as an XSI extension) d_ino are specified in POSIX.1. Other than Linux, the d_type field is available mainly only on BSD systems. The remaining fields are available on many, but not all systems. " Although `d_ino` isn't being used by NuttX directly, the structure `dirent` may be used by third-party applications and it's important to have all the required members defined to avoid compatibility issues. --- include/dirent.h | 1 + include/nuttx/fs/hostfs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/dirent.h b/include/dirent.h index 23da8e06bb994..e252fae12e910 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -112,6 +112,7 @@ struct dirent { + ino_t d_ino; /* file number */ uint8_t d_type; /* Type of file */ char d_name[NAME_MAX + 1]; /* File name */ }; diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h index fbf1e8bca180c..88bed488edc18 100644 --- a/include/nuttx/fs/hostfs.h +++ b/include/nuttx/fs/hostfs.h @@ -152,6 +152,7 @@ struct nuttx_timespec struct nuttx_dirent_s { + ino_t d_ino; /* file number */ uint8_t d_type; /* type of file */ char d_name[CONFIG_NAME_MAX + 1]; /* filename */ };