diff --git a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig index 0c570032f8..91c62c486c 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig +++ b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig @@ -34,7 +34,6 @@ CONFIG_DEV_GPIO=y CONFIG_ETH0_PHY_LAN8742A=y CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_EXCLUDE_ENVIRON=y -CONFIG_FS_PROCFS_MAX_TASKS=16 CONFIG_FS_PROCFS_REGISTER=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/fs/procfs/Kconfig b/fs/procfs/Kconfig index 77aa1d2f5e..b06e4313ff 100644 --- a/fs/procfs/Kconfig +++ b/fs/procfs/Kconfig @@ -21,12 +21,6 @@ config FS_PROCFS_REGISTER Support run-time registration of the new entries in the procfs file system. -config FS_PROCFS_MAX_TASKS - int "The maximum number of active tasks for procfs snapshot" - default 128 - ---help--- - The maximum number of active tasks for procfs snapshot. - menu "Exclude individual procfs entries" config FS_PROCFS_EXCLUDE_BLOCKS diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index 50381b7190..abf9b0673f 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -47,6 +47,7 @@ #include #include "mount/mount.h" +#include "sched/sched.h" /**************************************************************************** * External Definitions @@ -315,8 +316,8 @@ struct procfs_level0_s /* Our private data */ uint8_t lastlen; /* length of last reported static dir */ - pid_t pid[CONFIG_FS_PROCFS_MAX_TASKS]; /* Snapshot of all active task IDs */ FAR const char *lastread; /* Pointer to last static dir read */ + pid_t pid[1]; /* Snapshot of all active task IDs */ }; /* Level 1 is an internal virtual directory (such as /proc/fs) which @@ -355,14 +356,14 @@ static void procfs_enum(FAR struct tcb_s *tcb, FAR void *arg) /* Add the PID to the list */ - index = dir->base.nentries; - if (index >= CONFIG_FS_PROCFS_MAX_TASKS) + if (dir->base.index >= dir->base.nentries) { return; } + index = dir->base.index; dir->pid[index] = tcb->pid; - dir->base.nentries = index + 1; + dir->base.index = index + 1; } /**************************************************************************** @@ -633,12 +634,18 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, if (!relpath || relpath[0] == '\0') { + size_t num = 0; + /* The path refers to the top level directory. Allocate the level0 * dirent structure. */ +#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS + num = g_npidhash; +#endif + level0 = (FAR struct procfs_level0_s *) - kmm_zalloc(sizeof(struct procfs_level0_s)); + kmm_zalloc(sizeof(struct procfs_level0_s) + sizeof(pid_t) * num) ; if (!level0) { ferr("ERROR: Failed to allocate the level0 directory structure\n"); @@ -653,7 +660,11 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath, */ #ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS + level0->base.index = 0; + level0->base.nentries = num; nxsched_foreach(procfs_enum, level0); + level0->base.nentries = level0->base.index; + level0->base.index = 0; procfs_sort_pid(level0); #else level0->base.index = 0;