no1wudi commented on PR #13556:
URL: https://github.com/apache/nuttx/pull/13556#issuecomment-2363712691

   > 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 impl of VFS, did you mean something like this?
   ```c
   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);
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to