mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
nuttx/fs: Replace irqsave() with enter_critical_section(); replace irqrestore() with leave_critical_section()
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
@@ -61,8 +62,6 @@
|
|||||||
#include <nuttx/fs/dirent.h>
|
#include <nuttx/fs/dirent.h>
|
||||||
#include <nuttx/regex.h>
|
#include <nuttx/regex.h>
|
||||||
|
|
||||||
#include <arch/irq.h>
|
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -509,9 +508,9 @@ 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 = irqsave();
|
flags = enter_critical_section();
|
||||||
sched_foreach(procfs_enum, level0);
|
sched_foreach(procfs_enum, level0);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
#else
|
#else
|
||||||
level0->base.index = 0;
|
level0->base.index = 0;
|
||||||
level0->base.nentries = 0;
|
level0->base.nentries = 0;
|
||||||
@@ -752,9 +751,9 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = level0->pid[index];
|
pid = level0->pid[index];
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
|
|||||||
+13
-14
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/procfs/fs_procfsproc.c
|
* fs/procfs/fs_procfsproc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
@@ -64,8 +65,6 @@
|
|||||||
# include <nuttx/clock.h>
|
# include <nuttx/clock.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <arch/irq.h>
|
|
||||||
|
|
||||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
|
||||||
#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
|
#ifndef CONFIG_FS_PROCFS_EXCLUDE_PROCESS
|
||||||
|
|
||||||
@@ -1032,9 +1031,9 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
@@ -1122,13 +1121,13 @@ 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 = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(procfile->pid);
|
tcb = sched_gettcb(procfile->pid);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
fdbg("ERROR: PID %d is not valid\n", (int)procfile->pid);
|
fdbg("ERROR: PID %d is not valid\n", (int)procfile->pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1166,7 +1165,7 @@ static ssize_t proc_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
/* Update the file offset */
|
/* Update the file offset */
|
||||||
|
|
||||||
@@ -1271,9 +1270,9 @@ static int proc_opendir(FAR const char *relpath, FAR struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
@@ -1403,9 +1402,9 @@ static int proc_readdir(struct fs_dirent_s *dir)
|
|||||||
|
|
||||||
pid = procdir->pid;
|
pid = procdir->pid;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
@@ -1513,9 +1512,9 @@ static int proc_stat(const char *relpath, struct stat *buf)
|
|||||||
|
|
||||||
pid = (pid_t)tmp;
|
pid = (pid_t)tmp;
|
||||||
|
|
||||||
flags = irqsave();
|
flags = enter_critical_section();
|
||||||
tcb = sched_gettcb(pid);
|
tcb = sched_gettcb(pid);
|
||||||
irqrestore(flags);
|
leave_critical_section(flags);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user