diff --git a/fs/inode/inode.h b/fs/inode/inode.h index 5e5445cd337..a43993096b7 100644 --- a/fs/inode/inode.h +++ b/fs/inode/inode.h @@ -229,9 +229,12 @@ int inode_find(FAR struct inode_search_s *desc); * * Input Parameters: * inode - The inode of interest - * buf - The caller provide location in which to return information + * buf - The caller-provided location in which to return information * about the inode. - * resolve - Whether to resolve the symbolic link + * resolve - Whether to resolve the symbolic link: + * 0: Don't resolve the symbolic line + * 1: Resolve the symbolic link + * >=2: The recursive count in the resolving process * * Returned Value: * Zero (OK) returned on success. Otherwise, a negated errno value is diff --git a/fs/vfs/fs_stat.c b/fs/vfs/fs_stat.c index ad31c586474..257a9e5f6ac 100644 --- a/fs/vfs/fs_stat.c +++ b/fs/vfs/fs_stat.c @@ -38,20 +38,7 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_PSEUDOFS_SOFTLINKS -/* Reset, preserving the number of symbolic links encountered so far */ - -# define RESET_BUF(b) \ - { \ - uint16_t save = (b)->st_count; \ - memset((b), 0, sizeof(struct stat)); \ - (b)->st_count = save; \ - } -#else -/* Reset everything */ - -# define RESET_BUF(b) memset((b), 0, sizeof(struct stat)); -#endif +#define RESET_BUF(b) memset((b), 0, sizeof(struct stat)); /**************************************************************************** * Private Function Prototypes @@ -67,6 +54,15 @@ static int stat_recursive(FAR const char *path, /**************************************************************************** * Name: stat_recursive * + * Input Parameters: + * path - The inode of interest + * buf - The caller-provided location in which to return information + * about the inode. + * resolve - Whether to resolve the symbolic link: + * 0: Don't resolve the symbolic line + * 1: Resolve the symbolic link + * >=2: The recursive count in the resolving process + * * Returned Value: * Zero on success; < 0 on failure: * @@ -177,9 +173,6 @@ int nx_stat(FAR const char *path, FAR struct stat *buf, int resolve) * recursive if soft link support is enabled. */ -#ifdef CONFIG_PSEUDOFS_SOFTLINKS - buf->st_count = 0; -#endif return stat_recursive(path, buf, resolve); } @@ -239,9 +232,12 @@ int lstat(FAR const char *path, FAR struct stat *buf) * * Input Parameters: * inode - The inode of interest - * buf - The caller provide location in which to return information + * buf - The caller-provided location in which to return information * about the inode. - * resolve - Whether to resolve the symbolic link + * resolve - Whether to resolve the symbolic link: + * 0: Don't resolve the symbolic line + * 1: Resolve the symbolic link + * >=2: The recursive count in the resolving process * * Returned Value: * Zero (OK) returned on success. Otherwise, a negated errno value is @@ -329,16 +325,14 @@ int inode_stat(FAR struct inode *inode, FAR struct stat *buf, int resolve) * will not be included in the total. */ - if (++buf->st_count > SYMLOOP_MAX) + if (resolve > SYMLOOP_MAX) { return -ELOOP; } - DEBUGASSERT(buf->st_count > 0); /* Check for unsigned integer overflow */ - /* stat() the target of the soft link. */ - ret = stat_recursive(inode->u.i_link, buf, 1); + ret = stat_recursive(inode->u.i_link, buf, ++resolve); /* If stat() fails, then there is a problem with the target of * the symbolic link, but not with the symbolic link itself. diff --git a/include/sys/stat.h b/include/sys/stat.h index c812385a588..61e2afd30a8 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -141,14 +141,6 @@ struct stat struct timespec st_ctim; /* Time of last status change */ blksize_t st_blksize; /* Block size used for filesystem I/O */ blkcnt_t st_blocks; /* Number of blocks allocated */ - - /* Internal fields. These are part this specific implementation and - * should not referenced by application code for portability reasons. - */ - -#ifdef CONFIG_PSEUDOFS_SOFTLINKS - uint8_t st_count; /* Used internally to limit traversal of links */ -#endif }; /****************************************************************************