-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dirent.h: Add missing field d_ino #13556
base: master
Are you sure you want to change the base?
Conversation
Currently implementations of dirent.h do not have a field for the inode number, but it is required by POSIX. For better compatibility with POSIX based applications, it is should be added even if it is not actually implemented. Signed-off-by: Huang Qi <[email protected]>
Refer to apache/nuttx#13556, should be merged together. Signed-off-by: Huang Qi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add the field, i guess we should set a sane value.
at least it should be consistent with st_ino.
I'm not familiar with implementations of VFS, did you mean something like this? static ssize_t dir_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct fs_dirent_s *dir = filep->f_priv;
#ifndef CONFIG_DISABLE_MOUNTPOINT
FAR struct inode *inode = dir->fd_root;
#endif
FAR struct dirent *dirent = (FAR struct dirent *)buffer;
int ret;
/* Verify that we were provided with a valid directory structure */
if (buffer == NULL || buflen < sizeof(struct dirent))
{
return -EINVAL;
}
/* The way we handle the readdir depends on the type of inode
* that we are dealing with.
*/
#ifndef CONFIG_DISABLE_MOUNTPOINT
if (INODE_IS_MOUNTPT(inode))
{
ret = inode->u.i_mops->readdir(inode, dir, dirent);
}
else
#endif
{
/* The node is part of the root pseudo file system */
ret = read_pseudodir(dir, dirent);
}
/* ret < 0 is an error. Special case: ret = -ENOENT is end of file */
if (ret < 0)
{
if (ret == -ENOENT)
{
ret = 0;
}
return ret;
}
>>> New added here <<<
dirent->d_ino = dir->fd_root->i_ino;
filep->f_pos++;
return sizeof(struct dirent);
} |
Summary
Currently implementations of dirent.h do not have a field for the inode number, but it is required by POSIX.
For better compatibility with POSIX based applications, it is should be added even if it is not actually implemented.
PR coupled with nuttx-apps PR apache/nuttx-apps#2593.
Impact
include/dirent.h
.include/nuttx/fs/hostfs.h
.Testing
CI and local machine