mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
fs/procfs/fs_procfs.c: procfs_initialize() is used only within fs/procfs/fs_procfs.c and, hence, should be marked 'static'.
This commit is contained in:
+30
-25
@@ -188,13 +188,13 @@ static const struct procfs_entry_s g_procfs_entries[] =
|
|||||||
|
|
||||||
#ifdef CONFIG_FS_PROCFS_REGISTER
|
#ifdef CONFIG_FS_PROCFS_REGISTER
|
||||||
static const uint8_t g_base_entrycount = sizeof(g_base_entries) /
|
static const uint8_t g_base_entrycount = sizeof(g_base_entries) /
|
||||||
sizeof(struct procfs_entry_s);
|
sizeof(struct procfs_entry_s);
|
||||||
|
|
||||||
static FAR struct procfs_entry_s *g_procfs_entries;
|
static FAR struct procfs_entry_s *g_procfs_entries;
|
||||||
static uint8_t g_procfs_entrycount;
|
static uint8_t g_procfs_entrycount;
|
||||||
#else
|
#else
|
||||||
static const uint8_t g_procfs_entrycount = sizeof(g_procfs_entries) /
|
static const uint8_t g_procfs_entrycount = sizeof(g_procfs_entries) /
|
||||||
sizeof(struct procfs_entry_s);
|
sizeof(struct procfs_entry_s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -244,15 +244,9 @@ static int procfs_stat(FAR struct inode *mountpt,
|
|||||||
/* Initialization */
|
/* Initialization */
|
||||||
|
|
||||||
#ifdef CONFIG_FS_PROCFS_REGISTER
|
#ifdef CONFIG_FS_PROCFS_REGISTER
|
||||||
int procfs_initialize(void);
|
static int procfs_initialize(void);
|
||||||
#else
|
|
||||||
# define procfs_initialize()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -616,12 +610,14 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
|
|
||||||
if (match(g_procfs_entries[x].pathpattern, relpath))
|
if (match(g_procfs_entries[x].pathpattern, relpath))
|
||||||
{
|
{
|
||||||
/* Match found! Call the handler's opendir routine. If successful,
|
/* Match found! Call the handler's opendir routine. If
|
||||||
* this opendir routine will create an entry derived from struct
|
* successful, this opendir routine will create an entry
|
||||||
* procfs_dir_priv_s as dir->u.procfs.
|
* derived from struct procfs_dir_priv_s as dir->u.procfs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(g_procfs_entries[x].ops && g_procfs_entries[x].ops->opendir);
|
DEBUGASSERT(g_procfs_entries[x].ops != NULL &&
|
||||||
|
g_procfs_entries[x].ops->opendir != NULL);
|
||||||
|
|
||||||
ret = g_procfs_entries[x].ops->opendir(relpath, dir);
|
ret = g_procfs_entries[x].ops->opendir(relpath, dir);
|
||||||
|
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
@@ -639,14 +635,15 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
|
|
||||||
/* Test for a sub-string match (e.g. "ls /proc/fs") */
|
/* Test for a sub-string match (e.g. "ls /proc/fs") */
|
||||||
|
|
||||||
else if (strncmp(g_procfs_entries[x].pathpattern, relpath, len) == 0)
|
else if (strncmp(g_procfs_entries[x].pathpattern, relpath,
|
||||||
|
len) == 0)
|
||||||
{
|
{
|
||||||
FAR struct procfs_level1_s *level1;
|
FAR struct procfs_level1_s *level1;
|
||||||
|
|
||||||
/* Doing an intermediate directory search */
|
/* Doing an intermediate directory search */
|
||||||
|
|
||||||
/* The path refers to the top level directory. Allocate the level1
|
/* The path refers to the top level directory. Allocate
|
||||||
* dirent structure.
|
* the level1 dirent structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
level1 = (FAR struct procfs_level1_s *)
|
level1 = (FAR struct procfs_level1_s *)
|
||||||
@@ -654,7 +651,8 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||||||
|
|
||||||
if (!level1)
|
if (!level1)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to allocate the level0 directory structure\n");
|
ferr("ERROR: Failed to allocate the level0 directory "
|
||||||
|
"structure\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,8 +848,8 @@ static int procfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
dir->fd_dir.d_type = DTYPE_DIRECTORY;
|
dir->fd_dir.d_type = DTYPE_DIRECTORY;
|
||||||
snprintf(dir->fd_dir.d_name, NAME_MAX + 1, "%d", (int)pid);
|
snprintf(dir->fd_dir.d_name, NAME_MAX + 1, "%d", (int)pid);
|
||||||
|
|
||||||
/* Set up the next directory entry offset. NOTE that we could use the
|
/* Set up the next directory entry offset. NOTE that we could use
|
||||||
* standard f_pos instead of our own private index.
|
* the standard f_pos instead of our own private index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
level0->base.index = index + 1;
|
level0->base.index = index + 1;
|
||||||
@@ -959,8 +957,8 @@ static int procfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
*
|
*
|
||||||
* Description: This implements a portion of the mount operation. This
|
* Description: This implements a portion of the mount operation. This
|
||||||
* function allocates and initializes the mountpoint private data and
|
* function allocates and initializes the mountpoint private data and
|
||||||
* binds the blockdriver inode to the filesystem private data. The final
|
* binds the block driver inode to the filesystem private data. The final
|
||||||
* binding of the private data (containing the blockdriver) to the
|
* binding of the private data (containing the block driver) to the
|
||||||
* mountpoint is performed by mount().
|
* mountpoint is performed by mount().
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -968,9 +966,12 @@ static int procfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|||||||
static int procfs_bind(FAR struct inode *blkdriver, const void *data,
|
static int procfs_bind(FAR struct inode *blkdriver, const void *data,
|
||||||
void **handle)
|
void **handle)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_FS_PROCFS_REGISTER
|
||||||
/* Make sure that we are properly initialized */
|
/* Make sure that we are properly initialized */
|
||||||
|
|
||||||
procfs_initialize();
|
procfs_initialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1063,7 +1064,8 @@ static int procfs_stat(struct inode *mountpt, const char *relpath,
|
|||||||
|
|
||||||
/* Test for an internal subdirectory stat */
|
/* Test for an internal subdirectory stat */
|
||||||
|
|
||||||
else if (strncmp(g_procfs_entries[x].pathpattern, relpath, len) == 0)
|
else if (strncmp(g_procfs_entries[x].pathpattern, relpath,
|
||||||
|
len) == 0)
|
||||||
{
|
{
|
||||||
/* It's an internal subdirectory */
|
/* It's an internal subdirectory */
|
||||||
|
|
||||||
@@ -1098,7 +1100,7 @@ int procfs_initialize(void)
|
|||||||
|
|
||||||
if (g_procfs_entries == NULL)
|
if (g_procfs_entries == NULL)
|
||||||
{
|
{
|
||||||
/* No.. allocate a modifyable list of entries */
|
/* No.. allocate a modifiable list of entries */
|
||||||
|
|
||||||
g_procfs_entries = (FAR struct procfs_entry_s *)
|
g_procfs_entries = (FAR struct procfs_entry_s *)
|
||||||
kmm_malloc(sizeof(g_base_entries));
|
kmm_malloc(sizeof(g_base_entries));
|
||||||
@@ -1168,7 +1170,9 @@ int procfs_register(FAR const struct procfs_entry_s *entry)
|
|||||||
newsize = newcount * sizeof(struct procfs_entry_s);
|
newsize = newcount * sizeof(struct procfs_entry_s);
|
||||||
|
|
||||||
sched_lock();
|
sched_lock();
|
||||||
newtable = (FAR struct procfs_entry_s *)kmm_realloc(g_procfs_entries, newsize);
|
newtable = (FAR struct procfs_entry_s *)
|
||||||
|
kmm_realloc(g_procfs_entries, newsize);
|
||||||
|
|
||||||
if (newtable == NULL)
|
if (newtable == NULL)
|
||||||
{
|
{
|
||||||
/* Reallocation failed! */
|
/* Reallocation failed! */
|
||||||
@@ -1179,7 +1183,8 @@ int procfs_register(FAR const struct procfs_entry_s *entry)
|
|||||||
{
|
{
|
||||||
/* Copy the new entry at the end of the reallocated table */
|
/* Copy the new entry at the end of the reallocated table */
|
||||||
|
|
||||||
memcpy(&newtable[g_procfs_entrycount], entry, sizeof(struct procfs_entry_s));
|
memcpy(&newtable[g_procfs_entrycount], entry,
|
||||||
|
sizeof(struct procfs_entry_s));
|
||||||
|
|
||||||
/* Instantiate the reallocated table */
|
/* Instantiate the reallocated table */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user