mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
fs/procfs: Remove the unnecessary critical section
This commit is contained in:
@@ -553,7 +553,6 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
FAR struct procfs_level0_s *level0;
|
FAR struct procfs_level0_s *level0;
|
||||||
FAR struct procfs_dir_priv_s *dirpriv;
|
FAR struct procfs_dir_priv_s *dirpriv;
|
||||||
FAR void *priv = NULL;
|
FAR void *priv = NULL;
|
||||||
irqstate_t flags;
|
|
||||||
|
|
||||||
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
||||||
DEBUGASSERT(mountpt && relpath && dir && !dir->u.procfs);
|
DEBUGASSERT(mountpt && relpath && dir && !dir->u.procfs);
|
||||||
@@ -587,9 +586,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
|
#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
|
||||||
flags = enter_critical_section();
|
|
||||||
sched_foreach(procfs_enum, level0);
|
sched_foreach(procfs_enum, level0);
|
||||||
leave_critical_section(flags);
|
|
||||||
#else
|
#else
|
||||||
level0->base.index = 0;
|
level0->base.index = 0;
|
||||||
level0->base.nentries = 0;
|
level0->base.nentries = 0;
|
||||||
@@ -715,7 +712,6 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
FAR const char *name = NULL;
|
FAR const char *name = NULL;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
irqstate_t flags;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret = -ENOENT;
|
int ret = -ENOENT;
|
||||||
|
|
||||||
@@ -839,10 +835,7 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = level0->pid[index];
|
pid = level0->pid[index];
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||||
|
|||||||
@@ -1268,7 +1268,6 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
FAR const struct proc_node_s *node;
|
FAR const struct proc_node_s *node;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
FAR char *ptr;
|
FAR char *ptr;
|
||||||
irqstate_t flags;
|
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
@@ -1326,10 +1325,7 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
if (tcb == NULL)
|
if (tcb == NULL)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||||
@@ -1404,7 +1400,6 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
{
|
{
|
||||||
FAR struct proc_file_s *procfile;
|
FAR struct proc_file_s *procfile;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
irqstate_t flags;
|
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
|
||||||
@@ -1416,13 +1411,10 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
|
|
||||||
/* Verify that the thread is still valid */
|
/* Verify that the thread is still valid */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(procfile->pid);
|
tcb = sched_gettcb(procfile->pid);
|
||||||
|
|
||||||
if (tcb == NULL)
|
if (tcb == NULL)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is not valid\n", (int)procfile->pid);
|
ferr("ERROR: PID %d is not valid\n", (int)procfile->pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1471,8 +1463,6 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
/* Update the file offset */
|
/* Update the file offset */
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
@@ -1535,7 +1525,6 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
|
|||||||
FAR struct proc_dir_s *procdir;
|
FAR struct proc_dir_s *procdir;
|
||||||
FAR const struct proc_node_s *node;
|
FAR const struct proc_node_s *node;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
irqstate_t flags;
|
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
FAR char *ptr;
|
FAR char *ptr;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -1586,10 +1575,7 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
if (tcb == NULL)
|
if (tcb == NULL)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is not valid\n", (int)pid);
|
ferr("ERROR: PID %d is not valid\n", (int)pid);
|
||||||
@@ -1690,7 +1676,6 @@ static int proc_readdir(struct fs_dirent_s *dir)
|
|||||||
FAR const struct proc_node_s *node = NULL;
|
FAR const struct proc_node_s *node = NULL;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
irqstate_t flags;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -1718,10 +1703,7 @@ static int proc_readdir(struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = procdir->pid;
|
pid = procdir->pid;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
if (tcb == NULL)
|
if (tcb == NULL)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||||
@@ -1794,7 +1776,6 @@ static int proc_stat(const char *relpath, struct stat *buf)
|
|||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
FAR char *ptr;
|
FAR char *ptr;
|
||||||
irqstate_t flags;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
/* Two path forms are accepted:
|
/* Two path forms are accepted:
|
||||||
@@ -1837,10 +1818,7 @@ static int proc_stat(const char *relpath, struct stat *buf)
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
leave_critical_section(flags);
|
|
||||||
|
|
||||||
if (tcb == NULL)
|
if (tcb == NULL)
|
||||||
{
|
{
|
||||||
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
ferr("ERROR: PID %d is no longer valid\n", (int)pid);
|
||||||
|
|||||||
Reference in New Issue
Block a user