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

   > > what's your motivation to add d_ino?
   > 
   > @yamt I'm porting Rust std library to NuttX, the `ino` is required by it: 
https://doc.rust-lang.org/std/os/unix/fs/trait.DirEntryExt.html#tymethod.ino
   > 
   > But this is not used by Rust itself, leave it to 0 is OK if nobody really 
need it. So in the first PR I just add the missing field to make the compiler 
happy.
   
   as it can be a bit expensive to perform fstat equivalent on each entries, it 
might be better to avoid doing that by default.
   
   however, unfortunately, there is no reserved values for inode numbers to 
indicate the "no inode number available" situation as far as i know.
   that is, 0 is not really a special value.
   it's unfortunate because, even on a posix environment, it's often tricky to 
provide inode numbers for some filesystems w/o hard links.
   having said that, my impression is that it isn't too uncommon to use 0 for 
that purpose. (at least it's certainly better than uninitialized stack garbage.)
   
   wrt rust, depending on how serious your port is, you might need to consider 
emulating the inode number by yourself.
   (not only d_ino, but also st_ino.)
   otoh, maybe the least invasive thing is to patch your rust port to provide 0 
by itself, rather than modifying nuttx.
   
   FYI, wasi-libc tries to emulate d_ino by itself for similar reasons. (well, 
another motivation there is windows support)
   
https://github.com/WebAssembly/wasi-libc/blob/7d4d3b83fc66c79b3faa5989e67ed2d1042dacaf/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c#L87-L110
   


-- 
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