fs/procfs: Optimization of previous commits. /proc/umm and proc/progmem are deleted. /proc/kmm is renamed /proc/meminfo and contains the output that was in all three files previously.

This commit is contained in:
Gregory Nutt 2017-11-13 13:33:12 -06:00
parent 070d40260b
commit a6aa4ac5f5
5 changed files with 125 additions and 420 deletions

View File

@ -75,10 +75,14 @@ config FS_PROCFS_EXCLUDE_CPULOAD
default n
depends on SCHED_CPULOAD
config FS_PROCFS_EXCLUDE_KMM
bool "Exclude kmm"
config FS_PROCFS_EXCLUDE_MEMINFO
bool "Exclude meminfo"
default n
depends on MM_KERNEL_HEAP
config FS_PROCFS_INCLUDE_PROGMEM
bool "Include prog mem"
default n
depends on ARCH_HAVE_PROGMEM && !FS_PROCFS_EXCLUDE_MEMINFO
config FS_PROCFS_EXCLUDE_MOUNTS
bool "Exclude mounts"
@ -90,11 +94,6 @@ config FS_PROCFS_EXCLUDE_NET
depends on NET
default n
config FS_PROCFS_EXCLUDE_PROGMEM
bool "Exclude progmem"
depends on ARCH_HAVE_PROGMEM
default y
config FS_PROCFS_EXCLUDE_MTD
bool "Exclude mtd"
depends on MTD
@ -115,10 +114,5 @@ config FS_PROCFS_EXCLUDE_SMARTFS
depends on FS_SMARTFS
default n
config FS_PROCFS_EXCLUDE_UMM
bool "Exclude umm"
depends on !BUILD_KERNEL
default n
endmenu #
endif # FS_PROCFS

View File

@ -38,15 +38,7 @@ ifeq ($(CONFIG_FS_PROCFS),y)
ASRCS +=
CSRCS += fs_procfs.c fs_procfsutil.c fs_procfsproc.c fs_procfsuptime.c
CSRCS += fs_procfscpuload.c fs_procfskmm.c
ifneq ($(CONFIG_BUILD_KERNEL),y)
CSRCS += fs_procfsumm.c
endif
ifeq ($(CONFIG_ARCH_HAVE_PROGMEM),y)
CSRCS += fs_procfsprogmem.c
endif
CSRCS += fs_procfscpuload.c fs_procfsmeminfo.c
# Include procfs build support

View File

@ -78,9 +78,7 @@
extern const struct procfs_operations proc_operations;
extern const struct procfs_operations cpuload_operations;
extern const struct procfs_operations kmm_operations;
extern const struct procfs_operations umm_operations;
extern const struct procfs_operations progmem_operations;
extern const struct procfs_operations meminfo_operations;
extern const struct procfs_operations module_operations;
extern const struct procfs_operations uptime_operations;
@ -126,8 +124,8 @@ static const struct procfs_entry_s g_procfs_entries[] =
{ "cpuload", &cpuload_operations, PROCFS_FILE_TYPE },
#endif
#if defined(CONFIG_MM_KERNEL_HEAP) && !defined(CONFIG_FS_PROCFS_EXCLUDE_KMM)
{ "kmm", &kmm_operations, PROCFS_FILE_TYPE },
#ifndef CONFIG_FS_PROCFS_EXCLUDE_MEMINFO
{ "meminfo", &meminfo_operations, PROCFS_FILE_TYPE },
#endif
#if defined(CONFIG_MODULE) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE)
@ -167,14 +165,6 @@ static const struct procfs_entry_s g_procfs_entries[] =
{ "partitions", &part_procfsoperations, PROCFS_FILE_TYPE },
#endif
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && !defined(CONFIG_FS_PROCFS_EXCLUDE_PROGMEM)
{ "progmem", &progmem_operations, PROCFS_FILE_TYPE },
#endif
#if !defined(CONFIG_FS_PROCFS_EXCLUDE_UMM) && !defined(CONFIG_BUILD_KERNEL)
{ "umm", &umm_operations, PROCFS_FILE_TYPE },
#endif
#if !defined(CONFIG_FS_PROCFS_EXCLUDE_UPTIME)
{ "uptime", &uptime_operations, PROCFS_FILE_TYPE },
#endif

View File

@ -1,324 +0,0 @@
/****************************************************************************
* fs/procfs/fs_procfskmm.c
*
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mm/mm.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#if defined(CONFIG_MM_KERNEL_HEAP) && defined(CONFIG_FS_PROCFS) && \
!defined(CONFIG_FS_PROCFS_EXCLUDE_KMM)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Determines the size of an intermediate buffer that must be large enough
* to handle the longest line generated by this logic.
*/
#define KMM_LINELEN 54
/****************************************************************************
* Private Types
****************************************************************************/
/* This structure describes one open "file" */
struct kmm_file_s
{
struct procfs_file_s base; /* Base open file structure */
unsigned int linesize; /* Number of valid characters in line[] */
char line[KMM_LINELEN]; /* Pre-allocated buffer for formatted lines */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* File system methods */
static int kmm_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode);
static int kmm_close(FAR struct file *filep);
static ssize_t kmm_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static int kmm_dup(FAR const struct file *oldp,
FAR struct file *newp);
static int kmm_stat(FAR const char *relpath, FAR struct stat *buf);
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/* See fs_mount.c -- this structure is explicitly externed there.
* We use the old-fashioned kind of initializers so that this will compile
* with any compiler.
*/
const struct procfs_operations kmm_operations =
{
kmm_open, /* open */
kmm_close, /* close */
kmm_read, /* read */
NULL, /* write */
kmm_dup, /* dup */
NULL, /* opendir */
NULL, /* closedir */
NULL, /* readdir */
NULL, /* rewinddir */
kmm_stat /* stat */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: kmm_open
****************************************************************************/
static int kmm_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode)
{
FAR struct kmm_file_s *procfile;
finfo("Open '%s'\n", relpath);
/* PROCFS is read-only. Any attempt to open with any kind of write
* access is not permitted.
*
* REVISIT: Write-able proc files could be quite useful.
*/
if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0)
{
ferr("ERROR: Only O_RDONLY supported\n");
return -EACCES;
}
/* "kmm" is the only acceptable value for the relpath */
if (strcmp(relpath, "kmm") != 0)
{
ferr("ERROR: relpath is '%s'\n", relpath);
return -ENOENT;
}
/* Allocate a container to hold the file attributes */
procfile = (FAR struct kmm_file_s *)kmm_zalloc(sizeof(struct kmm_file_s));
if (!procfile)
{
ferr("ERROR: Failed to allocate file attributes\n");
return -ENOMEM;
}
/* Save the attributes as the open-specific state in filep->f_priv */
filep->f_priv = (FAR void *)procfile;
return OK;
}
/****************************************************************************
* Name: kmm_close
****************************************************************************/
static int kmm_close(FAR struct file *filep)
{
FAR struct kmm_file_s *procfile;
/* Recover our private data from the struct file instance */
procfile = (FAR struct kmm_file_s *)filep->f_priv;
DEBUGASSERT(procfile);
/* Release the file attributes structure */
kmm_free(procfile);
filep->f_priv = NULL;
return OK;
}
/****************************************************************************
* Name: kmm_read
****************************************************************************/
static ssize_t kmm_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct kmm_file_s *procfile;
struct mallinfo mem;
size_t linesize;
size_t copysize;
size_t totalsize;
off_t offset;
finfo("buffer=%p buflen=%d\n", buffer, (int)buflen);
DEBUGASSERT(filep != NULL && buffer != NULL && buflen > 0);
offset = filep->f_pos;
/* Recover our private data from the struct file instance */
procfile = (FAR struct kmm_file_s *)filep->f_priv;
DEBUGASSERT(procfile);
/* The first line is the headers */
linesize = snprintf(procfile->line, KMM_LINELEN,
" total used free largest\n");
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize = copysize;
if (totalsize < buflen)
{
buffer += copysize;
buflen -= copysize;
/* The second line is the memory data */
#ifdef CONFIG_CAN_PASS_STRUCTS
mem = kmm_mallinfo();
#else
(void)kmm_mallinfo(&mem);
#endif
linesize = snprintf(procfile->line, KMM_LINELEN,
"Kmem: %11d%11d%11d%11d\n",
mem.arena, mem.uordblks, mem.fordblks,
mem.mxordblk);
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize += copysize;
}
/* Update the file offset */
filep->f_pos += totalsize;
return totalsize;
}
/****************************************************************************
* Name: kmm_dup
*
* Description:
* Duplicate open file data in the new file structure.
*
****************************************************************************/
static int kmm_dup(FAR const struct file *oldp, FAR struct file *newp)
{
FAR struct kmm_file_s *oldattr;
FAR struct kmm_file_s *newattr;
finfo("Dup %p->%p\n", oldp, newp);
/* Recover our private data from the old struct file instance */
oldattr = (FAR struct kmm_file_s *)oldp->f_priv;
DEBUGASSERT(oldattr);
/* Allocate a new container to hold the task and attribute selection */
newattr = (FAR struct kmm_file_s *)kmm_malloc(sizeof(struct kmm_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
return -ENOMEM;
}
/* The copy the file attributes from the old attributes to the new */
memcpy(newattr, oldattr, sizeof(struct kmm_file_s));
/* Save the new attributes in the new file structure */
newp->f_priv = (FAR void *)newattr;
return OK;
}
/****************************************************************************
* Name: kmm_stat
*
* Description: Return information about a file or directory
*
****************************************************************************/
static int kmm_stat(FAR const char *relpath, FAR struct stat *buf)
{
/* "kmm" is the only acceptable value for the relpath */
if (strcmp(relpath, "kmm") != 0)
{
ferr("ERROR: relpath is '%s'\n", relpath);
return -ENOENT;
}
/* "kmm" is the name for a read-only file */
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* CONFIG_MM_KERNEL_HEAP && CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_KMM */

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/procfs/fs_procfsprogmem.c
* fs/procfs/fs_procfsmeminfo.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -53,21 +53,20 @@
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/progmem.h>
#include <nuttx/mm/mm.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && !defined(CONFIG_FS_PROCFS_EXCLUDE_PROGMEM)
#ifndef CONFIG_FS_PROCFS_EXCLUDE_MEMINFO
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Determines the size of an intermediate buffer that must be large enough
* to handle the longest line generated by this logic.
*/
#define PROGMEM_LINELEN 54
#define MEMINFO_LINELEN 54
/****************************************************************************
* Private Types
@ -75,13 +74,14 @@
/* This structure describes one open "file" */
struct progmem_file_s
struct meminfo_file_s
{
struct procfs_file_s base; /* Base open file structure */
unsigned int linesize; /* Number of valid characters in line[] */
char line[PROGMEM_LINELEN]; /* Pre-allocated buffer for formatted lines */
char line[MEMINFO_LINELEN]; /* Pre-allocated buffer for formatted lines */
};
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && defined(CONFIG_FS_PROCFS_INCLUDE_PROGMEM)
struct progmem_info_s
{
int arena; /* Total size of available progmem. */
@ -90,27 +90,26 @@ struct progmem_info_s
int uordblks; /* Total size of memory for allocated chunks */
int fordblks; /* Total size of memory for free chunks.*/
};
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static void progmem_getinfo(FAR struct progmem_info_s *progmem);
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && defined(CONFIG_FS_PROCFS_INCLUDE_PROGMEM)
static void meminfo_progmem(FAR struct progmem_info_s *progmem);
#endif
/* File system methods */
static int progmem_open(FAR struct file *filep, FAR const char *relpath,
static int meminfo_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode);
static int progmem_close(FAR struct file *filep);
static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
static int meminfo_close(FAR struct file *filep);
static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static int progmem_dup(FAR const struct file *oldp,
static int meminfo_dup(FAR const struct file *oldp,
FAR struct file *newp);
static int progmem_stat(FAR const char *relpath, FAR struct stat *buf);
/****************************************************************************
* Private Data
****************************************************************************/
static int meminfo_stat(FAR const char *relpath, FAR struct stat *buf);
/****************************************************************************
* Public Data
@ -121,18 +120,18 @@ static int progmem_stat(FAR const char *relpath, FAR struct stat *buf);
* with any compiler.
*/
const struct procfs_operations progmem_operations =
const struct procfs_operations meminfo_operations =
{
progmem_open, /* open */
progmem_close, /* close */
progmem_read, /* read */
meminfo_open, /* open */
meminfo_close, /* close */
meminfo_read, /* read */
NULL, /* write */
progmem_dup, /* dup */
meminfo_dup, /* dup */
NULL, /* opendir */
NULL, /* closedir */
NULL, /* readdir */
NULL, /* rewinddir */
progmem_stat /* stat */
meminfo_stat /* stat */
};
/****************************************************************************
@ -140,7 +139,7 @@ const struct procfs_operations progmem_operations =
****************************************************************************/
/****************************************************************************
* Name: progmem_getinfo
* Name: meminfo_progmem
*
* Description:
* The moral equivalent of mallinfo() for prog mem
@ -149,7 +148,8 @@ const struct procfs_operations progmem_operations =
*
****************************************************************************/
static void progmem_getinfo(FAR struct progmem_info_s *progmem)
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && defined(CONFIG_FS_PROCFS_INCLUDE_PROGMEM)
static void meminfo_progmem(FAR struct progmem_info_s *progmem)
{
size_t page = 0;
size_t stpage = 0xffff;
@ -198,15 +198,16 @@ static void progmem_getinfo(FAR struct progmem_info_s *progmem)
progmem->mxordblk *= pagesize;
}
#endif
/****************************************************************************
* Name: progmem_open
* Name: meminfo_open
****************************************************************************/
static int progmem_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode)
static int meminfo_open(FAR struct file *filep, FAR const char *relpath,
int oflags, mode_t mode)
{
FAR struct progmem_file_s *procfile;
FAR struct meminfo_file_s *procfile;
finfo("Open '%s'\n", relpath);
@ -222,9 +223,9 @@ static int progmem_open(FAR struct file *filep, FAR const char *relpath,
return -EACCES;
}
/* "progmem" is the only acceptable value for the relpath */
/* "meminfo" is the only acceptable value for the relpath */
if (strcmp(relpath, "progmem") != 0)
if (strcmp(relpath, "meminfo") != 0)
{
ferr("ERROR: relpath is '%s'\n", relpath);
return -ENOENT;
@ -232,9 +233,9 @@ static int progmem_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
procfile = (FAR struct progmem_file_s *)
kmm_zalloc(sizeof(struct progmem_file_s));
if (procfile == NULL)
procfile = (FAR struct meminfo_file_s *)
kmm_zalloc(sizeof(struct meminfo_file_s));
if (!procfile)
{
ferr("ERROR: Failed to allocate file attributes\n");
return -ENOMEM;
@ -247,16 +248,16 @@ static int progmem_open(FAR struct file *filep, FAR const char *relpath,
}
/****************************************************************************
* Name: progmem_close
* Name: meminfo_close
****************************************************************************/
static int progmem_close(FAR struct file *filep)
static int meminfo_close(FAR struct file *filep)
{
FAR struct progmem_file_s *procfile;
FAR struct meminfo_file_s *procfile;
/* Recover our private data from the struct file instance */
procfile = (FAR struct progmem_file_s *)filep->f_priv;
procfile = (FAR struct meminfo_file_s *)filep->f_priv;
DEBUGASSERT(procfile);
/* Release the file attributes structure */
@ -267,14 +268,14 @@ static int progmem_close(FAR struct file *filep)
}
/****************************************************************************
* Name: progmem_read
* Name: meminfo_read
****************************************************************************/
static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct progmem_file_s *procfile;
struct progmem_info_s progmem;
FAR struct meminfo_file_s *procfile;
struct mallinfo mem;
size_t linesize;
size_t copysize;
size_t totalsize;
@ -287,17 +288,20 @@ static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
/* Recover our private data from the struct file instance */
procfile = (FAR struct progmem_file_s *)filep->f_priv;
procfile = (FAR struct meminfo_file_s *)filep->f_priv;
DEBUGASSERT(procfile);
/* The first line is the headers */
linesize = snprintf(procfile->line, PROGMEM_LINELEN,
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
" total used free largest\n");
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize = copysize;
/* Followed by information about the memory resources */
#ifdef CONFIG_MM_KERNEL_HEAP
if (totalsize < buflen)
{
buffer += copysize;
@ -305,7 +309,55 @@ static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
/* The second line is the memory data */
progmem_getinfo(&progmem);
#ifdef CONFIG_CAN_PASS_STRUCTS
mem = kmm_mallinfo();
#else
(void)kmm_mallinfo(&mem);
#endif
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
"Kmem: %11d%11d%11d%11d\n",
mem.arena, mem.uordblks, mem.fordblks,
mem.mxordblk);
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize += copysize;
}
#endif
#if !defined(CONFIG_BUILD_KERNEL)
if (totalsize < buflen)
{
buffer += copysize;
buflen -= copysize;
/* The second line is the memory data */
#ifdef CONFIG_CAN_PASS_STRUCTS
mem = kumm_mallinfo();
#else
(void)kumm_mallinfo(&mem);
#endif
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
"Umem: %11d%11d%11d%11d\n",
mem.arena, mem.uordblks, mem.fordblks,
mem.mxordblk);
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize += copysize;
}
#endif
#if defined(CONFIG_ARCH_HAVE_PROGMEM) && defined(CONFIG_FS_PROCFS_INCLUDE_PROGMEM)
if (totalsize < buflen)
{
buffer += copysize;
buflen -= copysize;
/* The second line is the memory data */
meminfo_progmem(&progmem);
linesize = snprintf(procfile->line, PROGMEM_LINELEN,
"Prog: %11d%11d%11d%11d\n",
@ -315,6 +367,7 @@ static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
&offset);
totalsize += copysize;
}
#endif
/* Update the file offset */
@ -323,29 +376,29 @@ static ssize_t progmem_read(FAR struct file *filep, FAR char *buffer,
}
/****************************************************************************
* Name: progmem_dup
* Name: meminfo_dup
*
* Description:
* Duplicate open file data in the new file structure.
*
****************************************************************************/
static int progmem_dup(FAR const struct file *oldp, FAR struct file *newp)
static int meminfo_dup(FAR const struct file *oldp, FAR struct file *newp)
{
FAR struct progmem_file_s *oldattr;
FAR struct progmem_file_s *newattr;
FAR struct meminfo_file_s *oldattr;
FAR struct meminfo_file_s *newattr;
finfo("Dup %p->%p\n", oldp, newp);
/* Recover our private data from the old struct file instance */
oldattr = (FAR struct progmem_file_s *)oldp->f_priv;
oldattr = (FAR struct meminfo_file_s *)oldp->f_priv;
DEBUGASSERT(oldattr);
/* Allocate a new container to hold the task and attribute selection */
newattr = (FAR struct progmem_file_s *)
kmm_malloc(sizeof(struct progmem_file_s));
newattr = (FAR struct meminfo_file_s *)
kmm_malloc(sizeof(struct meminfo_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
@ -354,7 +407,7 @@ static int progmem_dup(FAR const struct file *oldp, FAR struct file *newp)
/* The copy the file attributes from the old attributes to the new */
memcpy(newattr, oldattr, sizeof(struct progmem_file_s));
memcpy(newattr, oldattr, sizeof(struct meminfo_file_s));
/* Save the new attributes in the new file structure */
@ -363,23 +416,23 @@ static int progmem_dup(FAR const struct file *oldp, FAR struct file *newp)
}
/****************************************************************************
* Name: progmem_stat
* Name: meminfo_stat
*
* Description: Return information about a file or directory
*
****************************************************************************/
static int progmem_stat(FAR const char *relpath, FAR struct stat *buf)
static int meminfo_stat(FAR const char *relpath, FAR struct stat *buf)
{
/* "progmem" is the only acceptable value for the relpath */
/* "meminfo" is the only acceptable value for the relpath */
if (strcmp(relpath, "progmem") != 0)
if (strcmp(relpath, "meminfo") != 0)
{
ferr("ERROR: relpath is '%s'\n", relpath);
return -ENOENT;
}
/* "progmem" is the name for a read-only file */
/* "meminfo" is the name for a read-only file */
memset(buf, 0, sizeof(struct stat));
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
@ -390,4 +443,4 @@ static int progmem_stat(FAR const char *relpath, FAR struct stat *buf)
* Public Functions
****************************************************************************/
#endif /* CONFIG_ARCH_HAVE_PROGMEM && !CONFIG_FS_PROCFS_EXCLUDE_PROGMEM */
#endif /* !CONFIG_FS_PROCFS_EXCLUDE_MEMINFO */