diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 5ba4cfb3da..8fd3f821d6 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -787,7 +787,13 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir) strncpy(dir->fd_dir.d_name, name, level0->lastlen); dir->fd_dir.d_name[level0->lastlen] = '\0'; - if (entry->type == PROCFS_DIR_TYPE) + /* If the entry is a directory type OR if the reported name is + * only a sub-string of the entry (meaning that it contains + * '/'), then report this entry as a directory. + */ + + if (entry->type == PROCFS_DIR_TYPE || + level0->lastlen != strlen(name)) { dir->fd_dir.d_type = DTYPE_DIRECTORY; }