Update some comments; link counter can be uint8_t; Add a debug assertion.

This commit is contained in:
Gregory Nutt 2017-02-07 15:50:39 -06:00
parent cabc6cd413
commit 2d2fe301cb
2 changed files with 10 additions and 1 deletions

View File

@ -129,6 +129,8 @@ static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf)
return -ELOOP; return -ELOOP;
} }
DEBUGASSERT(buff->st_count > 0); /* Check for unsigned integer overflow */
/* stat() the target of the soft link. */ /* stat() the target of the soft link. */
ret = stat_recursive((FAR const char *)inode->u.i_link, buf); ret = stat_recursive((FAR const char *)inode->u.i_link, buf);

View File

@ -120,6 +120,8 @@
struct stat struct stat
{ {
/* Required, standard fields */
mode_t st_mode; /* File type, atributes, and access mode bits */ mode_t st_mode; /* File type, atributes, and access mode bits */
off_t st_size; /* Size of file/directory, in bytes */ off_t st_size; /* Size of file/directory, in bytes */
blksize_t st_blksize; /* Blocksize used for filesystem I/O */ blksize_t st_blksize; /* Blocksize used for filesystem I/O */
@ -127,8 +129,13 @@ struct stat
time_t st_atime; /* Time of last access */ time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last modification */ time_t st_mtime; /* Time of last modification */
time_t st_ctime; /* Time of last status change */ time_t st_ctime; /* Time of last status change */
/* Internal fields. These are part this specifi instance and should not
* referenced by application code for portability reasons.
*/
#ifdef CONFIG_PSEUDOFS_SOFTLINKS #ifdef CONFIG_PSEUDOFS_SOFTLINKS
uint16_t st_count; /* Used internally to limit traversal of links */ uint8_t st_count; /* Used internally to limit traversal of links */
#endif #endif
}; };