fs: Allocate unique serial number for the root pseduo file system node

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-09-16 14:24:55 +08:00 committed by archer
parent 8df223a1ef
commit db518bf0df
3 changed files with 9 additions and 0 deletions

View file

@ -32,6 +32,12 @@
#include "inode/inode.h"
/****************************************************************************
* Private Data
****************************************************************************/
static ino_t g_ino;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -78,6 +84,7 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode)
node = (FAR struct inode *)kmm_zalloc(FSNODE_SIZE(namelen));
if (node)
{
node->i_ino = g_ino++;
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
node->i_mode = mode;
clock_gettime(CLOCK_REALTIME, &node->i_atime);

View file

@ -438,6 +438,7 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve)
buf->st_mtim = inode->i_mtime;
buf->st_ctim = inode->i_ctime;
#endif
buf->st_ino = inode->i_ino;
return OK;
}

View file

@ -393,6 +393,7 @@ struct inode
int16_t i_crefs; /* References to inode */
uint16_t i_flags; /* Flags for inode */
union inode_ops_u u; /* Inode operations */
ino_t i_ino; /* Inode serial number */
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
mode_t i_mode; /* Access mode flags */
uid_t i_owner; /* Owner */