fs/xxfs:Replace kmm with fs heap

Summary:
  1.Add configuration to allocate memory from the specified section
  2.Replace all memory operations (kmm_) in the vfs with
    fs_heap_. When FS_HEAPSIZE > 0, memory is requested for the file system by specifying a configured heap location. By default (i.e. FS_HEAPSIZE=0) fs_heap_ is equivalent to kmm_

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1
2024-09-09 20:28:16 +08:00
committed by archer
parent e0df067d3c
commit 96206cbf9d
82 changed files with 568 additions and 449 deletions
+6
View File
@@ -17,6 +17,12 @@
# the License.
#
# ##############################################################################
if(NOT "${CONFIG_FS_HEAPBUF_SECTION}" STREQUAL "")
target_compile_definitions(
fs PRIVATE FS_HEAPBUF_SECTION=${CONFIG_FS_HEAPBUF_SECTION})
endif()
nuttx_add_kernel_library(fs fs_initialize.c fs_heap.c)
nuttx_add_subdirectory()
target_include_directories(fs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+9 -1
View File
@@ -112,13 +112,21 @@ config SENDFILE_BUFSIZE
Size of the I/O buffer to allocate in sendfile(). Default: 512b
config FS_HEAPSIZE
int "Independent heap bytes used by shm/tmpfs/pseudofile"
int "Independent heap bytes"
default 0
depends on FS_SHMFS || FS_TMPFS || PSEUDOFS_FILE
---help---
Support for shm/tmpfs/fs_pseudofile.c ram based fs memory.
default 0 to use kmm directly. independent heap disabled
config FS_HEAPBUF_SECTION
string "FS heap use Userheap section"
depends on FS_HEAPSIZE > 0
default ""
---help---
Allocated fs heap from the specified section. If not
specified, it will alloc from kernel heap.
config FS_REFCOUNT
bool "File reference count"
default !DEFAULT_SMALL
+4
View File
@@ -22,6 +22,10 @@ include $(TOPDIR)/Make.defs
CSRCS = fs_initialize.c fs_heap.c
ifneq ($(CONFIG_FS_HEAPBUF_SECTION),"")
CFLAGS += ${DEFINE_PREFIX}FS_HEAPBUF_SECTION=CONFIG_FS_HEAPBUF_SECTION
endif
include inode/Make.defs
include vfs/Make.defs
include driver/Make.defs
+3 -2
View File
@@ -41,6 +41,7 @@
#include <nuttx/lib/builtin.h>
#include "inode/inode.h"
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_BINFS)
@@ -305,7 +306,7 @@ static int binfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
return -ENOENT;
}
bdir = kmm_zalloc(sizeof(*bdir));
bdir = fs_heap_zalloc(sizeof(*bdir));
if (bdir == NULL)
{
return -ENOMEM;
@@ -330,7 +331,7 @@ static int binfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir);
kmm_free(dir);
fs_heap_free(dir);
return 0;
}
+11 -10
View File
@@ -43,6 +43,7 @@
#include <nuttx/fs/ioctl.h>
#include "cromfs.h"
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_CROMFS)
@@ -785,7 +786,7 @@ static int cromfs_open(FAR struct file *filep, FAR const char *relpath,
* file.
*/
ff = kmm_zalloc(sizeof(struct cromfs_file_s));
ff = fs_heap_zalloc(sizeof(struct cromfs_file_s));
if (ff == NULL)
{
return -ENOMEM;
@@ -793,10 +794,10 @@ static int cromfs_open(FAR struct file *filep, FAR const char *relpath,
/* Create a file buffer to support partial sector accesses */
ff->ff_buffer = kmm_malloc(fs->cv_bsize);
ff->ff_buffer = fs_heap_malloc(fs->cv_bsize);
if (!ff->ff_buffer)
{
kmm_free(ff);
fs_heap_free(ff);
return -ENOMEM;
}
@@ -829,8 +830,8 @@ static int cromfs_close(FAR struct file *filep)
/* Free all resources consumed by the opened file */
kmm_free(ff->ff_buffer);
kmm_free(ff);
fs_heap_free(ff->ff_buffer);
fs_heap_free(ff);
return OK;
}
@@ -1118,7 +1119,7 @@ static int cromfs_dup(FAR const struct file *oldp, FAR struct file *newp)
* same node.
*/
newff = kmm_zalloc(sizeof(struct cromfs_file_s));
newff = fs_heap_zalloc(sizeof(struct cromfs_file_s));
if (newff == NULL)
{
return -ENOMEM;
@@ -1126,10 +1127,10 @@ static int cromfs_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Create a file buffer to support partial sector accesses */
newff->ff_buffer = kmm_malloc(fs->cv_bsize);
newff->ff_buffer = fs_heap_malloc(fs->cv_bsize);
if (newff->ff_buffer == NULL)
{
kmm_free(newff);
fs_heap_free(newff);
return -ENOMEM;
}
@@ -1236,7 +1237,7 @@ static int cromfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
return -ENOTDIR;
}
cdir = kmm_zalloc(sizeof(*cdir));
cdir = fs_heap_zalloc(sizeof(*cdir));
if (cdir == NULL)
{
return -ENOMEM;
@@ -1261,7 +1262,7 @@ static int cromfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(mountpt != NULL);
kmm_free(dir);
fs_heap_free(dir);
return 0;
}
+4 -3
View File
@@ -35,6 +35,7 @@
#include "driver/driver.h"
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Private Types
@@ -284,7 +285,7 @@ static int part_unlink(FAR struct inode *inode)
FAR struct inode *parent = dev->parent;
inode_release(parent);
kmm_free(dev);
fs_heap_free(dev);
return OK;
}
@@ -332,7 +333,7 @@ int register_partition_with_inode(FAR const char *partition,
/* Allocate a partition device structure */
dev = kmm_zalloc(sizeof(*dev));
dev = fs_heap_zalloc(sizeof(*dev));
if (dev == NULL)
{
return -ENOMEM;
@@ -365,7 +366,7 @@ int register_partition_with_inode(FAR const char *partition,
errout_free:
inode_release(parent);
kmm_free(dev);
fs_heap_free(dev);
return ret;
}
+14 -14
View File
@@ -318,7 +318,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
* file.
*/
ff = kmm_zalloc(sizeof(struct fat_file_s));
ff = fs_heap_zalloc(sizeof(struct fat_file_s));
if (!ff)
{
ret = -ENOMEM;
@@ -379,7 +379,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
off_t offset = fat_seek(filep, ff->ff_size, SEEK_SET);
if (offset < 0)
{
kmm_free(ff);
fs_heap_free(ff);
return (int)offset;
}
}
@@ -391,7 +391,7 @@ static int fat_open(FAR struct file *filep, FAR const char *relpath,
*/
errout_with_struct:
kmm_free(ff);
fs_heap_free(ff);
errout_with_lock:
nxmutex_unlock(&fs->fs_lock);
@@ -469,7 +469,7 @@ static int fat_close(FAR struct file *filep)
/* Then free the file structure itself. */
kmm_free(ff);
fs_heap_free(ff);
filep->f_priv = NULL;
return ret;
}
@@ -504,7 +504,7 @@ static int fat_zero_cluster(FAR struct fat_mountpt_s *fs, int cluster,
off_t end_sec = sector + DIV_ROUND_UP(end, fs->fs_hwsectorsize);
int ret;
buf = kmm_malloc(fs->fs_hwsectorsize);
buf = fs_heap_malloc(fs->fs_hwsectorsize);
if (!buf)
{
return -ENOMEM;
@@ -543,7 +543,7 @@ static int fat_zero_cluster(FAR struct fat_mountpt_s *fs, int cluster,
ret = OK;
out:
kmm_free(buf);
fs_heap_free(buf);
return ret;
}
@@ -1549,7 +1549,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp)
* dup'ed file.
*/
newff = kmm_malloc(sizeof(struct fat_file_s));
newff = fs_heap_malloc(sizeof(struct fat_file_s));
if (!newff)
{
ret = -ENOMEM;
@@ -1616,7 +1616,7 @@ static int fat_dup(FAR const struct file *oldp, FAR struct file *newp)
*/
errout_with_struct:
kmm_free(newff);
fs_heap_free(newff);
errout_with_lock:
nxmutex_unlock(&fs->fs_lock);
@@ -1647,7 +1647,7 @@ static int fat_opendir(FAR struct inode *mountpt, FAR const char *relpath,
fs = mountpt->i_private;
fdir = kmm_zalloc(sizeof(struct fat_dirent_s));
fdir = fs_heap_zalloc(sizeof(struct fat_dirent_s));
if (fdir == NULL)
{
return -ENOMEM;
@@ -1725,7 +1725,7 @@ errout_with_lock:
nxmutex_unlock(&fs->fs_lock);
errout_with_fdir:
kmm_free(fdir);
fs_heap_free(fdir);
return ret;
}
@@ -1740,7 +1740,7 @@ static int fat_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir);
kmm_free(dir);
fs_heap_free(dir);
return 0;
}
@@ -2230,7 +2230,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Create an instance of the mountpt state structure */
fs = kmm_zalloc(sizeof(struct fat_mountpt_s));
fs = fs_heap_zalloc(sizeof(struct fat_mountpt_s));
if (!fs)
{
return -ENOMEM;
@@ -2252,7 +2252,7 @@ static int fat_bind(FAR struct inode *blkdriver, FAR const void *data,
if (ret != 0)
{
nxmutex_destroy(&fs->fs_lock);
kmm_free(fs);
fs_heap_free(fs);
return ret;
}
@@ -2354,7 +2354,7 @@ static int fat_unbind(FAR void *handle, FAR struct inode **blkdriver,
}
nxmutex_destroy(&fs->fs_lock);
kmm_free(fs);
fs_heap_free(fs);
return OK;
}
+4 -2
View File
@@ -35,6 +35,8 @@
#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -845,8 +847,8 @@
# define fat_io_alloc(s) fat_dma_alloc(s)
# define fat_io_free(m,s) fat_dma_free(m,s)
#else
# define fat_io_alloc(s) kmm_malloc(s)
# define fat_io_free(m,s) kmm_free(m)
# define fat_io_alloc(s) fs_heap_malloc(s)
# define fat_io_free(m,s) fs_heap_free(m)
#endif
/****************************************************************************
+10
View File
@@ -38,7 +38,12 @@ static FAR struct mm_heap_s *g_fs_heap;
void fs_heap_initialize(void)
{
#ifdef FS_HEAPBUF_SECTION
static uint8_t buf[CONFIG_FS_HEAPSIZE] locate_data(FS_HEAPBUF_SECTION);
#else
FAR void *buf = kmm_malloc(CONFIG_FS_HEAPSIZE);
#endif
DEBUGASSERT(buf != NULL);
g_fs_heap = mm_initialize("heapfs", buf, CONFIG_FS_HEAPSIZE);
}
@@ -48,6 +53,11 @@ FAR void *fs_heap_zalloc(size_t size)
return mm_zalloc(g_fs_heap, size);
}
FAR void *fs_heap_malloc(size_t size)
{
return mm_malloc(g_fs_heap, size);
}
size_t fs_heap_malloc_size(FAR void *mem)
{
return mm_malloc_size(g_fs_heap, mem);
+2
View File
@@ -36,12 +36,14 @@
#if defined(CONFIG_FS_HEAPSIZE) && CONFIG_FS_HEAPSIZE > 0
void fs_heap_initialize(void);
FAR void *fs_heap_zalloc(size_t size);
FAR void *fs_heap_malloc(size_t size);
size_t fs_heap_malloc_size(FAR void *mem);
FAR void *fs_heap_realloc(FAR void *oldmem, size_t size);
void fs_heap_free(FAR void *mem);
#else
# define fs_heap_initialize()
# define fs_heap_zalloc kmm_zalloc
# define fs_heap_malloc kmm_malloc
# define fs_heap_malloc_size kmm_malloc_size
# define fs_heap_realloc kmm_realloc
# define fs_heap_free kmm_free
+11 -10
View File
@@ -45,6 +45,7 @@
#include "inode/inode.h"
#include "hostfs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -273,7 +274,7 @@ static int hostfs_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate memory for the open file */
len = strlen(relpath);
hf = kmm_malloc(sizeof(*hf) + len);
hf = fs_heap_malloc(sizeof(*hf) + len);
if (hf == NULL)
{
ret = -ENOMEM;
@@ -332,7 +333,7 @@ static int hostfs_open(FAR struct file *filep, FAR const char *relpath,
goto errout_with_lock;
errout_with_buffer:
kmm_free(hf);
fs_heap_free(hf);
errout_with_lock:
nxmutex_unlock(&g_lock);
@@ -426,7 +427,7 @@ static int hostfs_close(FAR struct file *filep)
/* Now free the pointer */
filep->f_priv = NULL;
kmm_free(hf);
fs_heap_free(hf);
okout:
nxmutex_unlock(&g_lock);
@@ -857,7 +858,7 @@ static int hostfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
/* Recover our private data from the inode instance */
fs = mountpt->i_private;
hdir = kmm_zalloc(sizeof(struct hostfs_dir_s));
hdir = fs_heap_zalloc(sizeof(struct hostfs_dir_s));
if (hdir == NULL)
{
return -ENOMEM;
@@ -892,7 +893,7 @@ errout_with_lock:
nxmutex_unlock(&g_lock);
errout_with_hdir:
kmm_free(hdir);
fs_heap_free(hdir);
return ret;
}
@@ -930,7 +931,7 @@ static int hostfs_closedir(FAR struct inode *mountpt,
host_closedir(hdir->dir);
nxmutex_unlock(&g_lock);
kmm_free(hdir);
fs_heap_free(hdir);
return OK;
}
@@ -1040,7 +1041,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Create an instance of the mountpt state structure */
fs = (FAR struct hostfs_mountpt_s *)
kmm_zalloc(sizeof(struct hostfs_mountpt_s));
fs_heap_zalloc(sizeof(struct hostfs_mountpt_s));
if (fs == NULL)
{
@@ -1054,7 +1055,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
options = strdup(data);
if (!options)
{
kmm_free(fs);
fs_heap_free(fs);
return -ENOMEM;
}
@@ -1076,7 +1077,7 @@ static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data,
ret = nxmutex_lock(&g_lock);
if (ret < 0)
{
kmm_free(fs);
fs_heap_free(fs);
return ret;
}
@@ -1150,7 +1151,7 @@ static int hostfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
}
nxmutex_unlock(&g_lock);
kmm_free(fs);
fs_heap_free(fs);
return ret;
}
+10 -9
View File
@@ -53,6 +53,7 @@
#include "sched/sched.h"
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Private Functions
@@ -136,7 +137,7 @@ static int files_extend(FAR struct filelist *list, size_t row)
return -EMFILE;
}
files = kmm_malloc(sizeof(FAR struct file *) * row);
files = fs_heap_malloc(sizeof(FAR struct file *) * row);
DEBUGASSERT(files);
if (files == NULL)
{
@@ -146,16 +147,16 @@ static int files_extend(FAR struct filelist *list, size_t row)
i = orig_rows;
do
{
files[i] = kmm_zalloc(sizeof(struct file) *
files[i] = fs_heap_zalloc(sizeof(struct file) *
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK);
if (files[i] == NULL)
{
while (--i >= orig_rows)
{
kmm_free(files[i]);
fs_heap_free(files[i]);
}
kmm_free(files);
fs_heap_free(files);
return -ENFILE;
}
}
@@ -174,10 +175,10 @@ static int files_extend(FAR struct filelist *list, size_t row)
for (j = orig_rows; j < i; j++)
{
kmm_free(files[j]);
fs_heap_free(files[j]);
}
kmm_free(files);
fs_heap_free(files);
return OK;
}
@@ -196,7 +197,7 @@ static int files_extend(FAR struct filelist *list, size_t row)
if (tmp != NULL && tmp != &list->fl_prefile)
{
kmm_free(tmp);
fs_heap_free(tmp);
}
return OK;
@@ -485,13 +486,13 @@ void files_putlist(FAR struct filelist *list)
if (i != 0)
{
kmm_free(list->fl_files[i]);
fs_heap_free(list->fl_files[i]);
}
}
if (list->fl_files != &list->fl_prefile)
{
kmm_free(list->fl_files);
fs_heap_free(list->fl_files);
}
}
+3 -2
View File
@@ -33,6 +33,7 @@
#include <nuttx/fs/fs.h>
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -170,7 +171,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
/* Allocate the mountpoint info structure */
info = kmm_malloc(sizeof(struct inode_path_s));
info = fs_heap_malloc(sizeof(struct inode_path_s));
if (!info)
{
return -ENOMEM;
@@ -193,7 +194,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
/* Free the info structure and return the result */
kmm_free(info);
fs_heap_free(info);
return ret;
#else
+3 -2
View File
@@ -31,6 +31,7 @@
#include <nuttx/fs/fs.h>
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Public Functions
@@ -69,10 +70,10 @@ void inode_free(FAR struct inode *node)
if (INODE_IS_SOFTLINK(node) && node->u.i_link != NULL)
{
kmm_free(node->u.i_link);
fs_heap_free(node->u.i_link);
}
#endif
kmm_free(node);
fs_heap_free(node);
}
}
+2 -1
View File
@@ -31,6 +31,7 @@
#include <nuttx/fs/fs.h>
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Private Data
@@ -81,7 +82,7 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode)
int namelen;
namelen = inode_namelen(name);
node = kmm_zalloc(FSNODE_SIZE(namelen));
node = fs_heap_zalloc(FSNODE_SIZE(namelen));
if (node)
{
node->i_ino = g_ino++;
+4 -3
View File
@@ -1,10 +1,11 @@
--- ./littlefs/littlefs/lfs_util.h 2022-11-11 03:32:30.000000000 +1100
+++ ./littlefs/littlefs/lfs_util.h 2023-04-21 12:25:27.987084276 +1000
@@ -28,6 +28,7 @@
@@ -28,6 +28,8 @@
#ifndef LFS_NO_MALLOC
#include <stdlib.h>
+#include <nuttx/mm/mm.h>
+#include "fs_heap.h"
#endif
#ifndef LFS_NO_ASSERT
#include <assert.h>
@@ -13,7 +14,7 @@
static inline void *lfs_malloc(size_t size) {
#ifndef LFS_NO_MALLOC
- return malloc(size);
+ return kmm_malloc(size);
+ return fs_heap_malloc(size);
#else
(void)size;
return NULL;
@@ -22,7 +23,7 @@
static inline void lfs_free(void *p) {
#ifndef LFS_NO_MALLOC
- free(p);
+ kmm_free(p);
+ fs_heap_free(p);
#else
(void)p;
#endif
+10 -9
View File
@@ -40,6 +40,7 @@
#include "inode/inode.h"
#include "littlefs/lfs.h"
#include "littlefs/lfs_util.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -298,7 +299,7 @@ static int littlefs_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate memory for the open file */
priv = kmm_malloc(sizeof(*priv));
priv = fs_heap_malloc(sizeof(*priv));
if (priv == NULL)
{
return -ENOMEM;
@@ -361,7 +362,7 @@ errout_with_file:
errout:
nxmutex_unlock(&fs->lock);
errlock:
kmm_free(priv);
fs_heap_free(priv);
return ret;
}
@@ -398,7 +399,7 @@ static int littlefs_close(FAR struct file *filep)
nxmutex_unlock(&fs->lock);
if (priv->refs <= 0)
{
kmm_free(priv);
fs_heap_free(priv);
}
return ret;
@@ -780,7 +781,7 @@ static int littlefs_opendir(FAR struct inode *mountpt,
/* Allocate memory for the open directory */
ldir = kmm_malloc(sizeof(*ldir));
ldir = fs_heap_malloc(sizeof(*ldir));
if (ldir == NULL)
{
return -ENOMEM;
@@ -809,7 +810,7 @@ static int littlefs_opendir(FAR struct inode *mountpt,
errout:
nxmutex_unlock(&fs->lock);
errlock:
kmm_free(ldir);
fs_heap_free(ldir);
return ret;
}
@@ -843,7 +844,7 @@ static int littlefs_closedir(FAR struct inode *mountpt,
lfs_dir_close(&fs->lfs, &ldir->dir);
nxmutex_unlock(&fs->lock);
kmm_free(ldir);
fs_heap_free(ldir);
return OK;
}
@@ -1070,7 +1071,7 @@ static int littlefs_bind(FAR struct inode *driver, FAR const void *data,
/* Create an instance of the mountpt state structure */
fs = kmm_zalloc(sizeof(*fs));
fs = fs_heap_zalloc(sizeof(*fs));
if (!fs)
{
ret = -ENOMEM;
@@ -1200,7 +1201,7 @@ static int littlefs_bind(FAR struct inode *driver, FAR const void *data,
errout_with_fs:
nxmutex_destroy(&fs->lock);
kmm_free(fs);
fs_heap_free(fs);
errout_with_block:
if (INODE_IS_BLOCK(driver) && driver->u.i_bops->close)
{
@@ -1259,7 +1260,7 @@ static int littlefs_unbind(FAR void *handle, FAR struct inode **driver,
/* Release the mountpoint private data */
nxmutex_destroy(&fs->lock);
kmm_free(fs);
fs_heap_free(fs);
}
return ret;
+5 -4
View File
@@ -30,6 +30,7 @@
#include "fs_anonmap.h"
#include "sched/sched.h"
#include "fs_heap.h"
/****************************************************************************
* Private Functions
@@ -77,7 +78,7 @@ static int unmap_anonymous(FAR struct task_group_s *group,
if (kernel)
{
kmm_free(entry->vaddr);
fs_heap_free(entry->vaddr);
}
else
{
@@ -97,7 +98,7 @@ static int unmap_anonymous(FAR struct task_group_s *group,
{
if (kernel)
{
newaddr = kmm_realloc(entry->vaddr, length);
newaddr = fs_heap_realloc(entry->vaddr, length);
}
else
{
@@ -127,7 +128,7 @@ int map_anonymous(FAR struct mm_map_entry_s *entry, bool kernel)
*/
entry->vaddr = kernel ?
kmm_zalloc(entry->length) : kumm_zalloc(entry->length);
fs_heap_zalloc(entry->length) : kumm_zalloc(entry->length);
if (entry->vaddr == NULL)
{
ferr("ERROR: kumm_alloc() failed, enable DEBUG_MM for info!\n");
@@ -142,7 +143,7 @@ int map_anonymous(FAR struct mm_map_entry_s *entry, bool kernel)
{
if (kernel)
{
kmm_free(entry->vaddr);
fs_heap_free(entry->vaddr);
}
else
{
+1 -1
View File
@@ -42,7 +42,7 @@
*
* Input Parameters:
* map Input struct containing user request
* kernel kmm_zalloc or kumm_zalloc
* kernel fs_heap_zalloc or kumm_zalloc
*
* Returned Value:
* On success returns 0. Otherwise negated errno is returned appropriately.
+7 -5
View File
@@ -39,6 +39,7 @@
#include "fs_rammap.h"
#include "sched/sched.h"
#include "fs_heap.h"
/****************************************************************************
* Public Data
@@ -165,7 +166,7 @@ static int unmap_rammap(FAR struct task_group_s *group,
if (type == MAP_KERNEL)
{
kmm_free(entry->vaddr);
fs_heap_free(entry->vaddr);
}
else if (type == MAP_USER)
{
@@ -187,7 +188,7 @@ static int unmap_rammap(FAR struct task_group_s *group,
{
if (type == MAP_KERNEL)
{
newaddr = kmm_realloc(entry->vaddr, length);
newaddr = fs_heap_realloc(entry->vaddr, length);
}
else if (type == MAP_USER)
{
@@ -216,7 +217,7 @@ static int unmap_rammap(FAR struct task_group_s *group,
* filep file descriptor of the backing file -- required.
* entry mmap entry information.
* field offset and length must be initialized correctly.
* type kmm_zalloc or kumm_zalloc or xip_base
* type fs_heap_zalloc or kumm_zalloc or xip_base
*
* Returned Value:
* On success, rammap returns 0 and entry->vaddr points to memory mapped.
@@ -262,7 +263,8 @@ int rammap(FAR struct file *filep, FAR struct mm_map_entry_s *entry,
/* Allocate a region of memory of the specified size */
rdbuffer = type == MAP_KERNEL ? kmm_malloc(length) : kumm_malloc(length);
rdbuffer = type == MAP_KERNEL ? fs_heap_malloc(length)
: kumm_malloc(length);
if (!rdbuffer)
{
ferr("ERROR: Region allocation failed, length: %zu\n", length);
@@ -344,7 +346,7 @@ out:
errout_with_region:
if (type == MAP_KERNEL)
{
kmm_free(entry->vaddr);
fs_heap_free(entry->vaddr);
}
else if (type == MAP_USER)
{
+1 -1
View File
@@ -81,7 +81,7 @@ enum mm_map_type_e
* length The length of the mapping. For exception #1 above, this length
* ignored: The entire underlying media is always accessible.
* offset The offset into the file to map
* type kmm_zalloc or kumm_zalloc or xip_base
* type fs_heap_zalloc or kumm_zalloc or xip_base
*
* Returned Value:
* On success rammmap returns 0. Otherwise errno is returned appropriately.
+22 -21
View File
@@ -97,6 +97,7 @@
#include <sys/statfs.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -272,14 +273,14 @@ static int mnemofs_open(FAR struct file *filep, FAR const char *relpath,
finfo("Lock Acquired.");
f = kmm_zalloc(sizeof(*f));
f = fs_heap_zalloc(sizeof(*f));
if (predict_false(f == NULL))
{
ret = -ENOMEM;
goto errout_with_lock;
}
fcom = kmm_zalloc(sizeof(*fcom));
fcom = fs_heap_zalloc(sizeof(*fcom));
if (predict_false(fcom == NULL))
{
ret = -ENOMEM;
@@ -405,10 +406,10 @@ errout_with_dirent:
}
errout_with_fcom:
kmm_free(fcom);
fs_heap_free(fcom);
errout_with_f:
kmm_free(f);
fs_heap_free(f);
errout_with_lock:
nxmutex_unlock(&MFS_LOCK(sb));
@@ -478,8 +479,8 @@ static int mnemofs_close(FAR struct file *filep)
goto errout_with_lock;
}
kmm_free(f->com->path);
kmm_free(f->com);
fs_heap_free(f->com->path);
fs_heap_free(f->com);
finfo("Open file structure freed.");
@@ -492,7 +493,7 @@ static int mnemofs_close(FAR struct file *filep)
errout_with_fcom:
list_delete(&f->list);
kmm_free(f);
fs_heap_free(f);
filep->f_priv = NULL;
finfo("File entry removed from the open files list.");
@@ -1005,7 +1006,7 @@ static int mnemofs_dup(FAR const struct file *oldp, FAR struct file *newp)
of = oldp->f_priv;
DEBUGASSERT(of != NULL);
nf = kmm_zalloc(sizeof(*nf));
nf = fs_heap_zalloc(sizeof(*nf));
if (predict_false(nf == NULL))
{
finfo("No memory left.");
@@ -1037,7 +1038,7 @@ static int mnemofs_dup(FAR const struct file *oldp, FAR struct file *newp)
return ret;
errout_with_nf:
kmm_free(nf);
fs_heap_free(nf);
errout_with_lock:
nxmutex_unlock(&MFS_LOCK(sb));
@@ -1192,14 +1193,14 @@ static int mnemofs_opendir(FAR struct inode *mountpt,
goto errout_with_path;
}
pitr = kmm_zalloc(sizeof(*pitr));
pitr = fs_heap_zalloc(sizeof(*pitr));
if (predict_false(pitr == NULL))
{
ret = -ENOMEM;
goto errout_with_path;
}
fsdirent = kmm_zalloc(sizeof(*fsdirent));
fsdirent = fs_heap_zalloc(sizeof(*fsdirent));
if (predict_false(fsdirent == NULL))
{
ret = -ENOMEM;
@@ -1228,10 +1229,10 @@ static int mnemofs_opendir(FAR struct inode *mountpt,
return ret;
errout_with_fsdirent:
kmm_free(fsdirent);
fs_heap_free(fsdirent);
errout_with_pitr:
kmm_free(pitr);
fs_heap_free(pitr);
errout_with_path:
mfs_free_patharr(path);
@@ -1270,8 +1271,8 @@ static int mnemofs_closedir(FAR struct inode *mountpt,
mfs_free_patharr(fsdirent->path);
mfs_pitr_free(fsdirent->pitr);
kmm_free(fsdirent->pitr);
kmm_free(fsdirent);
fs_heap_free(fsdirent->pitr);
fs_heap_free(fsdirent);
return OK;
}
@@ -1492,7 +1493,7 @@ static int mnemofs_bind(FAR struct inode *driver, FAR const void *data,
memset(buf, 0, 8);
sb = kmm_zalloc(sizeof(*sb));
sb = fs_heap_zalloc(sizeof(*sb));
if (!sb)
{
ret = -ENOMEM;
@@ -1552,7 +1553,7 @@ static int mnemofs_bind(FAR struct inode *driver, FAR const void *data,
list_initialize(&MFS_OFILES(sb));
sb->rw_buf = kmm_zalloc(MFS_PGSZ(sb));
sb->rw_buf = fs_heap_zalloc(MFS_PGSZ(sb));
if (predict_false(sb->rw_buf == NULL))
{
goto errout_with_lock;
@@ -1653,14 +1654,14 @@ static int mnemofs_bind(FAR struct inode *driver, FAR const void *data,
return ret;
errout_with_rwbuf:
kmm_free(sb->rw_buf);
fs_heap_free(sb->rw_buf);
errout_with_lock:
nxmutex_unlock(&MFS_LOCK(sb));
finfo("Lock released.");
errout_with_sb:
kmm_free(sb);
fs_heap_free(sb);
errout:
finfo("Mnemofs bind exited with %d.", ret);
@@ -1700,8 +1701,8 @@ static int mnemofs_unbind(FAR void *handle, FAR struct inode **driver,
mfs_jrnl_free(sb);
mfs_ba_free(sb);
kmm_free(sb->rw_buf);
kmm_free(sb);
fs_heap_free(sb->rw_buf);
fs_heap_free(sb);
finfo("Successfully unmounted mnemofs!");
return OK;
+6 -5
View File
@@ -86,6 +86,7 @@
#include <stdlib.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -307,7 +308,7 @@ int mfs_ba_fmt(FAR struct mfs_sb_s * const sb)
/* MFS_BA(sb).k_del_elemsz = ((log + 7) & (-8)) / 8; */
MFS_BA(sb).k_del = kmm_zalloc(sizeof(size_t) * MFS_NBLKS(sb));
MFS_BA(sb).k_del = fs_heap_zalloc(sizeof(size_t) * MFS_NBLKS(sb));
if (predict_false(MFS_BA(sb).k_del == NULL))
{
ret = -ENOMEM;
@@ -316,7 +317,7 @@ int mfs_ba_fmt(FAR struct mfs_sb_s * const sb)
MFS_BA(sb).n_bmap_upgs = MFS_UPPER8(MFS_NPGS(sb));
MFS_BA(sb).bmap_upgs = kmm_zalloc(MFS_BA(sb).n_bmap_upgs);
MFS_BA(sb).bmap_upgs = fs_heap_zalloc(MFS_BA(sb).n_bmap_upgs);
if (predict_false(MFS_BA(sb).bmap_upgs == NULL))
{
ret = -ENOMEM;
@@ -330,7 +331,7 @@ int mfs_ba_fmt(FAR struct mfs_sb_s * const sb)
return ret;
errout_with_k_del:
kmm_free(MFS_BA(sb).k_del);
fs_heap_free(MFS_BA(sb).k_del);
errout:
return ret;
@@ -367,8 +368,8 @@ errout:
void mfs_ba_free(FAR struct mfs_sb_s * const sb)
{
kmm_free(MFS_BA(sb).k_del);
kmm_free(MFS_BA(sb).bmap_upgs);
fs_heap_free(MFS_BA(sb).k_del);
fs_heap_free(MFS_BA(sb).bmap_upgs);
finfo("Block Allocator Freed.");
}
+3 -2
View File
@@ -102,6 +102,7 @@
#include <sys/stat.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -452,7 +453,7 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
/* So, till cur_idx - 1, the CTZ blocks are common. */
buf = kmm_zalloc(MFS_PGSZ(sb));
buf = fs_heap_zalloc(MFS_PGSZ(sb));
if (predict_false(buf == NULL))
{
ret = -ENOMEM;
@@ -595,7 +596,7 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
}
errout_with_buf:
kmm_free(buf);
fs_heap_free(buf);
errout:
return ret;
+11 -10
View File
@@ -67,6 +67,7 @@
#include <sys/stat.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -324,7 +325,7 @@ int pitr_traverse(FAR struct mfs_sb_s *sb, FAR struct mfs_path_s *path,
{
*cap = (*cap * 3) / 2; /* Don't want to double it for memory. */
path = kmm_realloc(path, (*cap) * sizeof(struct mfs_path_s));
path = fs_heap_realloc(path, (*cap) * sizeof(struct mfs_path_s));
if (predict_false(path == NULL))
{
ret = -ENOMEM;
@@ -421,7 +422,7 @@ bool mfs_obj_isempty(FAR struct mfs_sb_s * const sb,
void mfs_free_dirent(FAR struct mfs_dirent_s *dirent)
{
kmm_free(dirent);
fs_heap_free(dirent);
finfo("Dirent freed.");
}
@@ -601,7 +602,7 @@ int mfs_pitr_readdirent(FAR const struct mfs_sb_s * const sb,
*dirent = NULL;
memset(rd, 0, len);
d = kmm_zalloc(len);
d = fs_heap_zalloc(len);
if (predict_false(d == NULL))
{
ret = -ENOMEM;
@@ -637,7 +638,7 @@ int mfs_pitr_readdirent(FAR const struct mfs_sb_s * const sb,
}
sz = MFS_DIRENTSZ(d);
tmp = kmm_realloc(d, sz);
tmp = fs_heap_realloc(d, sz);
if (predict_true(tmp != NULL))
{
d = tmp;
@@ -653,7 +654,7 @@ int mfs_pitr_readdirent(FAR const struct mfs_sb_s * const sb,
return ret;
errout_with_d:
kmm_free(d);
fs_heap_free(d);
if (ret < 0)
{
@@ -713,7 +714,7 @@ static int search_ctz_by_name(FAR const struct mfs_sb_s * const sb,
{
DEBUGASSERT(namelen == 0);
nd = kmm_zalloc(sizeof(struct mfs_dirent_s));
nd = fs_heap_zalloc(sizeof(struct mfs_dirent_s));
if (predict_false(nd == NULL))
{
ret = -ENOMEM;
@@ -810,7 +811,7 @@ int mfs_get_patharr(FAR const struct mfs_sb_s * const sb,
*path = NULL;
n_objs = nobjs_in_path(relpath);
np = kmm_zalloc(n_objs * sizeof(struct mfs_path_s));
np = fs_heap_zalloc(n_objs * sizeof(struct mfs_path_s));
if (predict_false(np == NULL))
{
ret = -ENOMEM;
@@ -921,7 +922,7 @@ errout:
void mfs_free_patharr(FAR struct mfs_path_s *path)
{
kmm_free(path);
fs_heap_free(path);
}
void mfs_pitr_reset(FAR struct mfs_pitr_s * const pitr)
@@ -988,7 +989,7 @@ int mfs_pitr_appendnew(FAR struct mfs_sb_s * const sb,
DEBUGASSERT(depth > 0);
d = kmm_zalloc(sizeof(struct mfs_dirent_s) + len);
d = fs_heap_zalloc(sizeof(struct mfs_dirent_s) + len);
if (predict_false(d == NULL))
{
ret = -ENOMEM;
@@ -1043,7 +1044,7 @@ int mfs_pitr_traversefs(FAR struct mfs_sb_s * sb, const struct mfs_ctz_s ctz,
FAR struct mfs_path_s *path = NULL;
capacity = MFS_TRAVERSE_INITSZ;
path = kmm_zalloc(capacity * sizeof(struct mfs_path_s));
path = fs_heap_zalloc(capacity * sizeof(struct mfs_path_s));
if (predict_false(path == NULL))
{
ret = -ENOMEM;
+10 -9
View File
@@ -82,6 +82,7 @@
#include <sys/param.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -185,7 +186,7 @@ int mfs_jrnl_rdlog(FAR const struct mfs_sb_s *const sb,
goto errout;
}
buf = kmm_zalloc(log_sz);
buf = fs_heap_zalloc(log_sz);
if (predict_false(buf == NULL))
{
ret = -ENOMEM;
@@ -215,7 +216,7 @@ int mfs_jrnl_rdlog(FAR const struct mfs_sb_s *const sb,
}
errout_with_buf:
kmm_free(buf);
fs_heap_free(buf);
errout:
return ret;
@@ -297,7 +298,7 @@ FAR static const char *deser_log(FAR const char * const in,
/* Allocates path. Deallocate using mfs_jrnl_log_free. */
x->path = kmm_zalloc(sizeof(struct mfs_jrnl_log_s) * x->depth);
x->path = fs_heap_zalloc(sizeof(struct mfs_jrnl_log_s) * x->depth);
if (predict_false(x->path == NULL))
{
return NULL;
@@ -328,7 +329,7 @@ FAR static const char *deser_log(FAR const char * const in,
void mfs_jrnl_log_free(FAR const struct mfs_jrnl_log_s * const log)
{
free(log->path);
fs_heap_free(log->path);
}
/****************************************************************************
@@ -430,7 +431,7 @@ int mfs_jrnl_fmt(FAR struct mfs_sb_s * const sb, FAR mfs_t *blk1,
sz = MFS_JRNL_SUFFIXSZ + ((CONFIG_MNEMOFS_JOURNAL_NBLKS + 2) * 4);
buf = kmm_zalloc(sz);
buf = fs_heap_zalloc(sz);
if (predict_false(buf == NULL))
{
ret = -ENOMEM;
@@ -508,7 +509,7 @@ int mfs_jrnl_fmt(FAR struct mfs_sb_s * const sb, FAR mfs_t *blk1,
MFS_JRNL(sb).mblk2 = *blk2;
errout_with_buf:
kmm_free(buf);
fs_heap_free(buf);
errout:
return ret;
@@ -631,7 +632,7 @@ int mfs_jrnl_wrlog(FAR struct mfs_sb_s * const sb,
const mfs_t log_sz = sizeof(mfs_t) + MFS_LOGSZ(node->depth);
struct mfs_jrnl_log_s log;
buf = kmm_zalloc(log_sz); /* For size before log. */
buf = fs_heap_zalloc(log_sz); /* For size before log. */
if (predict_false(buf == NULL))
{
ret = -ENOMEM;
@@ -677,7 +678,7 @@ int mfs_jrnl_wrlog(FAR struct mfs_sb_s * const sb,
MFS_JRNL(sb).n_logs++;
errout_with_buf:
kmm_free(buf);
fs_heap_free(buf);
errout:
return ret;
@@ -753,7 +754,7 @@ int mfs_jrnl_flush(FAR struct mfs_sb_s * const sb)
tmp_blkidx = blkidx;
tmp_pg_in_blk = pg_in_blk;
path = kmm_zalloc(log.depth * sizeof(struct mfs_path_s));
path = fs_heap_zalloc(log.depth * sizeof(struct mfs_path_s));
if (predict_false(path == NULL))
{
goto errout;
+12 -11
View File
@@ -74,6 +74,7 @@
#include <sys/param.h>
#include "mnemofs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -265,8 +266,8 @@ static bool lru_isnodefull(FAR struct mfs_sb_s * const sb,
static void lru_free_delta(FAR struct mfs_delta_s *delta)
{
kmm_free(delta->upd);
kmm_free(delta);
fs_heap_free(delta->upd);
fs_heap_free(delta);
}
/****************************************************************************
@@ -391,7 +392,7 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
if (node == NULL)
{
node = kmm_zalloc(sizeof(*node));
node = fs_heap_zalloc(sizeof(*node));
if (predict_false(node == NULL))
{
found = false;
@@ -399,7 +400,7 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
goto errout;
}
node->path = kmm_zalloc(depth * sizeof(struct mfs_path_s));
node->path = fs_heap_zalloc(depth * sizeof(struct mfs_path_s));
if (predict_false(node->path == NULL))
{
found = false;
@@ -455,7 +456,7 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
/* Add delta to node. */
finfo("Adding delta to the node.");
delta = kmm_zalloc(sizeof(*delta));
delta = fs_heap_zalloc(sizeof(*delta));
if (predict_false(delta == NULL))
{
ret = -ENOMEM;
@@ -466,7 +467,7 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
if (op == MFS_LRU_UPD)
{
delta->upd = kmm_zalloc(bytes);
delta->upd = fs_heap_zalloc(bytes);
if (predict_false(delta->upd == NULL))
{
ret = -ENOMEM;
@@ -511,13 +512,13 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
errout_with_delta:
list_delete(&delta->list);
kmm_free(delta);
fs_heap_free(delta);
errout_with_node:
if (!found && node != NULL)
{
list_delete(&node->list);
kmm_free(node);
fs_heap_free(node);
}
errout:
@@ -622,7 +623,7 @@ errout:
static void lru_node_free(FAR struct mfs_node_s *node)
{
mfs_free_patharr(node->path);
kmm_free(node);
fs_heap_free(node);
}
static bool lru_sort_cmp(FAR struct mfs_node_s * const node,
@@ -761,7 +762,7 @@ int mfs_lru_flush(FAR struct mfs_sb_s * const sb)
{
finfo("Adding parent to LRU");
tmp = kmm_zalloc(sizeof(struct mfs_node_s));
tmp = fs_heap_zalloc(sizeof(struct mfs_node_s));
if (predict_false(tmp == NULL))
{
ret = -ENOMEM;
@@ -774,7 +775,7 @@ int mfs_lru_flush(FAR struct mfs_sb_s * const sb)
/* TODO: Time fields. in tmp. */
tmp->depth = node->depth - 1;
tmp->path = kmm_zalloc((node->depth - 1)
tmp->path = fs_heap_zalloc((node->depth - 1)
* sizeof(struct mfs_path_s));
if (predict_false(tmp->path == NULL))
{
+5 -4
View File
@@ -49,6 +49,7 @@
#endif /* CONFIG_FS_AUTOMOUNTER_DRIVER */
#include "inode/inode.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -213,7 +214,7 @@ static int automount_open(FAR struct file *filep)
/* Allocate a new open structure */
opriv = kmm_zalloc(sizeof(struct automounter_open_s));
opriv = fs_heap_zalloc(sizeof(struct automounter_open_s));
if (opriv == NULL)
{
ferr("ERROR: Failed to allocate open structure\n");
@@ -295,7 +296,7 @@ static int automount_close(FAR struct file *filep)
/* And free the open structure */
kmm_free(opriv);
fs_heap_free(opriv);
ret = OK;
@@ -818,7 +819,7 @@ FAR void *automount_initialize(FAR const struct automount_lower_s *lower)
/* Allocate an auto-mounter state structure */
priv = kmm_zalloc(sizeof(struct automounter_state_s));
priv = fs_heap_zalloc(sizeof(struct automounter_state_s));
if (priv == NULL)
{
ferr("ERROR: Failed to allocate state structure\n");
@@ -931,5 +932,5 @@ void automount_uninitialize(FAR void *handle)
/* And free the state structure */
kmm_free(priv);
fs_heap_free(priv);
}
+4 -3
View File
@@ -46,6 +46,7 @@
#include <nuttx/fs/procfs.h>
#include "mount/mount.h"
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
#if !defined(CONFIG_FS_PROCFS_EXCLUDE_MOUNT) || \
@@ -409,7 +410,7 @@ static int mount_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the task and node selection */
procfile = (FAR struct mount_file_s *)
kmm_zalloc(sizeof(struct mount_file_s));
fs_heap_zalloc(sizeof(struct mount_file_s));
if (!procfile)
{
ferr("ERROR: Failed to allocate file container\n");
@@ -441,7 +442,7 @@ static int mount_close(FAR struct file *filep)
/* Release the file container structure */
kmm_free(procfile);
fs_heap_free(procfile);
filep->f_priv = NULL;
return OK;
}
@@ -539,7 +540,7 @@ static int mount_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and node selection */
newfile = (FAR struct mount_file_s *)
kmm_malloc(sizeof(struct mount_file_s));
fs_heap_malloc(sizeof(struct mount_file_s));
if (!newfile)
{
ferr("ERROR: Failed to allocate file container\n");
+15 -13
View File
@@ -73,6 +73,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include "fs_heap.h"
#include "nfs.h"
#include "rpc.h"
#include "nfs_proto.h"
@@ -663,7 +665,7 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath,
/* Pre-allocate the file private data to describe the opened file. */
np = kmm_zalloc(sizeof(struct nfsnode));
np = fs_heap_zalloc(sizeof(struct nfsnode));
if (!np)
{
ferr("ERROR: Failed to allocate private data\n");
@@ -673,7 +675,7 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath,
ret = nxmutex_lock(&nmp->nm_lock);
if (ret < 0)
{
kmm_free(np);
fs_heap_free(np);
return ret;
}
@@ -744,7 +746,7 @@ static int nfs_open(FAR struct file *filep, FAR const char *relpath,
errout_with_lock:
if (np)
{
kmm_free(np);
fs_heap_free(np);
}
nxmutex_unlock(&nmp->nm_lock);
@@ -837,7 +839,7 @@ static int nfs_close(FAR struct file *filep)
/* Then deallocate the file structure and return success */
kmm_free(np);
fs_heap_free(np);
ret = OK;
break;
}
@@ -1497,7 +1499,7 @@ static int nfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
/* Recover our private data from the inode instance */
nmp = mountpt->i_private;
ndir = kmm_zalloc(sizeof(*ndir));
ndir = fs_heap_zalloc(sizeof(*ndir));
if (ndir == NULL)
{
return -ENOMEM;
@@ -1543,7 +1545,7 @@ static int nfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
errout_with_lock:
nxmutex_unlock(&nmp->nm_lock);
errout_with_ndir:
kmm_free(ndir);
fs_heap_free(ndir);
return ret;
}
@@ -1562,7 +1564,7 @@ static int nfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir);
kmm_free(dir);
fs_heap_free(dir);
return 0;
}
@@ -2077,7 +2079,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Create an instance of the mountpt state structure */
nmp = kmm_zalloc(SIZEOF_nfsmount(buflen));
nmp = fs_heap_zalloc(SIZEOF_nfsmount(buflen));
if (!nmp)
{
ferr("ERROR: Failed to allocate mountpoint structure\n");
@@ -2117,7 +2119,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data,
/* Create an instance of the rpc state structure */
rpc = kmm_zalloc(sizeof(struct rpcclnt));
rpc = fs_heap_zalloc(sizeof(struct rpcclnt));
if (!rpc)
{
ferr("ERROR: Failed to allocate rpc structure\n");
@@ -2169,13 +2171,13 @@ bad:
if (nmp->nm_rpcclnt)
{
rpcclnt_disconnect(nmp->nm_rpcclnt);
kmm_free(nmp->nm_rpcclnt);
fs_heap_free(nmp->nm_rpcclnt);
}
/* Free connection-related resources */
nxmutex_destroy(&nmp->nm_lock);
kmm_free(nmp);
fs_heap_free(nmp);
return ret;
}
@@ -2233,8 +2235,8 @@ static int nfs_unbind(FAR void *handle, FAR struct inode **blkdriver,
/* And free any allocated resources */
nxmutex_destroy(&nmp->nm_lock);
kmm_free(nmp->nm_rpcclnt);
kmm_free(nmp);
fs_heap_free(nmp->nm_rpcclnt);
fs_heap_free(nmp);
return OK;
+13 -12
View File
@@ -41,6 +41,7 @@
#include "inode/inode.h"
#include "sched/sched.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -210,7 +211,7 @@ inotify_alloc_event(int wd, uint32_t mask, uint32_t cookie,
len = ROUND_UP(strlen(name) + 1, sizeof(struct inotify_event));
}
event = kmm_malloc(sizeof(struct inotify_event_s) + len);
event = fs_heap_malloc(sizeof(struct inotify_event_s) + len);
if (event == NULL)
{
return NULL;
@@ -308,7 +309,7 @@ inotify_remove_watch_no_event(FAR struct inotify_watch_s *watch)
list_delete(&watch->d_node);
list_delete(&watch->l_node);
inotify_sub_count(watch->mask);
kmm_free(watch);
fs_heap_free(watch);
if (list_is_empty(&list->watches))
{
@@ -347,7 +348,7 @@ static void inotify_remove_event(FAR struct inotify_device_s *dev,
list_delete(&event->node);
dev->event_size -= sizeof(struct inotify_event) + event->event.len;
dev->event_count--;
kmm_free(event);
fs_heap_free(event);
}
/****************************************************************************
@@ -362,7 +363,7 @@ static FAR struct inotify_device_s *inotify_alloc_device(void)
{
FAR struct inotify_device_s *dev;
dev = kmm_zalloc(sizeof(struct inotify_device_s));
dev = fs_heap_zalloc(sizeof(struct inotify_device_s));
if (dev == NULL)
{
return dev;
@@ -584,7 +585,7 @@ static int inotify_close(FAR struct file *filep)
nxmutex_unlock(&g_inotify.lock);
nxmutex_destroy(&dev->lock);
nxsem_destroy(&dev->sem);
kmm_free(dev);
fs_heap_free(dev);
return OK;
}
@@ -653,7 +654,7 @@ inotify_alloc_watch(FAR struct inotify_device_s *dev,
{
FAR struct inotify_watch_s *watch;
watch = kmm_zalloc(sizeof(struct inotify_watch_s));
watch = fs_heap_zalloc(sizeof(struct inotify_watch_s));
if (watch == NULL)
{
return NULL;
@@ -738,7 +739,7 @@ inotify_alloc_watch_list(FAR const char *path)
FAR ENTRY *result;
ENTRY item;
list = kmm_zalloc(sizeof(struct inotify_watch_list_s));
list = fs_heap_zalloc(sizeof(struct inotify_watch_list_s));
if (list == NULL)
{
return NULL;
@@ -748,7 +749,7 @@ inotify_alloc_watch_list(FAR const char *path)
list->path = strdup(path);
if (list->path == NULL)
{
kmm_free(list);
fs_heap_free(list);
return NULL;
}
@@ -757,7 +758,7 @@ inotify_alloc_watch_list(FAR const char *path)
if (hsearch_r(item, ENTER, &result, &g_inotify.hash) == 0)
{
lib_free(list->path);
kmm_free(list);
fs_heap_free(list);
return NULL;
}
@@ -1019,10 +1020,10 @@ static inline void notify_queue_filep_event(FAR struct file *filep,
static void notify_free_entry(FAR ENTRY *entry)
{
/* Key is alloced by lib_malloc, value is alloced by kmm_malloc */
/* Key is alloced by lib_malloc, value is alloced by fs_heap_malloc */
lib_free(entry->key);
kmm_free(entry->data);
fs_heap_free(entry->data);
}
/****************************************************************************
@@ -1262,7 +1263,7 @@ int inotify_init1(int flags)
exit_with_dev:
nxmutex_destroy(&dev->lock);
nxsem_destroy(&dev->sem);
kmm_free(dev);
fs_heap_free(dev);
exit_set_errno:
set_errno(-ret);
return ERROR;
+2 -2
View File
@@ -555,8 +555,8 @@ int nxffs_getc(FAR struct nxffs_volume_s *volume, uint16_t reserve);
* to dispose of that memory when the inode entry is no longer needed.
*
* Note that the nxffs_entry_s containing structure is not freed. The
* caller may call kmm_free upon return of this function if necessary to
* free the entry container.
* caller may call fs_heap_free upon return of this function if necessary
* to free the entry container.
*
* Input Parameters:
* entry - The entry to be freed.
+4 -3
View File
@@ -35,6 +35,7 @@
#include <nuttx/kmalloc.h>
#include "nxffs.h"
#include "fs_heap.h"
/****************************************************************************
* Private Types
@@ -74,7 +75,7 @@ int nxffs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
/* Recover the file system state from the NuttX inode instance */
volume = mountpt->i_private;
ndir = kmm_zalloc(sizeof(*ndir));
ndir = fs_heap_zalloc(sizeof(*ndir));
if (ndir == NULL)
{
return -ENOMEM;
@@ -105,7 +106,7 @@ errout_with_lock:
nxmutex_unlock(&volume->lock);
errout_with_ndir:
kmm_free(ndir);
fs_heap_free(ndir);
return ret;
}
@@ -121,7 +122,7 @@ int nxffs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir);
kmm_free(dir);
fs_heap_free(dir);
return 0;
}
+4 -3
View File
@@ -34,6 +34,7 @@
#include <nuttx/mtd/mtd.h>
#include "nxffs.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -443,7 +444,7 @@ int nxffs_dump(FAR struct mtd_dev_s *mtd, bool verbose)
/* Allocate a buffer to hold one block */
blkinfo.buffer = kmm_malloc(blkinfo.geo.blocksize);
blkinfo.buffer = fs_heap_malloc(blkinfo.geo.blocksize);
if (!blkinfo.buffer)
{
ferr("ERROR: Failed to allocate block cache\n");
@@ -470,7 +471,7 @@ int nxffs_dump(FAR struct mtd_dev_s *mtd, bool verbose)
/* Read errors are fatal */
ferr("ERROR: Failed to read block %d\n", blkinfo.block);
kmm_free(blkinfo.buffer);
fs_heap_free(blkinfo.buffer);
return ret;
#else
/* A read error is probably fatal on all media but NAND.
@@ -493,7 +494,7 @@ int nxffs_dump(FAR struct mtd_dev_s *mtd, bool verbose)
syslog(LOG_NOTICE, "%" PRIi32 " blocks analyzed\n", blkinfo.nblocks);
kmm_free(blkinfo.buffer);
fs_heap_free(blkinfo.buffer);
return OK;
#else
+7 -6
View File
@@ -36,6 +36,7 @@
#include <nuttx/fs/ioctl.h>
#include "nxffs.h"
#include "fs_heap.h"
/****************************************************************************
* Private Data
@@ -162,7 +163,7 @@ int nxffs_initialize(FAR struct mtd_dev_s *mtd)
/* Allocate a NXFFS volume structure */
volume = kmm_zalloc(sizeof(struct nxffs_volume_s));
volume = fs_heap_zalloc(sizeof(struct nxffs_volume_s));
if (!volume)
{
return -ENOMEM;
@@ -191,7 +192,7 @@ int nxffs_initialize(FAR struct mtd_dev_s *mtd)
/* Allocate one I/O block buffer to general files system access */
volume->cache = kmm_malloc(volume->geo.blocksize);
volume->cache = fs_heap_malloc(volume->geo.blocksize);
if (!volume->cache)
{
ferr("ERROR: Failed to allocate an erase block buffer\n");
@@ -204,7 +205,7 @@ int nxffs_initialize(FAR struct mtd_dev_s *mtd)
* is not needed often, but is best to have pre-allocated and in-place.
*/
volume->pack = kmm_malloc(volume->geo.erasesize);
volume->pack = fs_heap_malloc(volume->geo.erasesize);
if (!volume->pack)
{
ferr("ERROR: Failed to allocate an I/O block buffer\n");
@@ -302,14 +303,14 @@ int nxffs_initialize(FAR struct mtd_dev_s *mtd)
ferr("ERROR: Failed to calculate file system limits: %d\n", -ret);
errout_with_buffer:
kmm_free(volume->pack);
fs_heap_free(volume->pack);
errout_with_cache:
kmm_free(volume->cache);
fs_heap_free(volume->cache);
errout_with_volume:
nxmutex_destroy(&volume->lock);
nxsem_destroy(&volume->wrsem);
#ifndef CONFIG_NXFFS_PREALLOCATED
kmm_free(volume);
fs_heap_free(volume);
#endif
return ret;
}
+4 -3
View File
@@ -35,6 +35,7 @@
#include <nuttx/mtd/mtd.h>
#include "nxffs.h"
#include "fs_heap.h"
/****************************************************************************
* Private Functions
@@ -108,7 +109,7 @@ static int nxffs_rdentry(FAR struct nxffs_volume_s *volume, off_t offset,
/* Allocate memory to hold the variable-length file name */
namlen = inode.namlen;
entry->name = kmm_malloc(namlen + 1);
entry->name = fs_heap_malloc(namlen + 1);
if (!entry->name)
{
ferr("ERROR: Failed to allocate name, namlen: %d\n", namlen);
@@ -197,8 +198,8 @@ errout:
* to dispose of that memory when the inode entry is no longer needed.
*
* Note that the nxffs_entry_s containing structure is not freed. The
* caller may call kmm_free upon return of this function if necessary to
* free the entry container.
* caller may call fs_heap_free upon return of this function if necessary
* to free the entry container.
*
* Input Parameters:
* entry - The entry to be freed.
+6 -5
View File
@@ -38,6 +38,7 @@
#include <nuttx/mtd/mtd.h>
#include "nxffs.h"
#include "fs_heap.h"
/****************************************************************************
* Private Data
@@ -490,7 +491,7 @@ static inline int nxffs_wropen(FAR struct nxffs_volume_s *volume,
memset(wrfile, 0, sizeof(struct nxffs_wrfile_s));
#else
wrfile = (FAR struct nxffs_wrfile_s *)
kmm_zalloc(sizeof(struct nxffs_wrfile_s));
fs_heap_zalloc(sizeof(struct nxffs_wrfile_s));
if (!wrfile)
{
ret = -ENOMEM;
@@ -657,7 +658,7 @@ errout_with_name:
lib_free(wrfile->ofile.entry.name);
errout_with_ofile:
#ifndef CONFIG_NXFFS_PREALLOCATED
kmm_free(wrfile);
fs_heap_free(wrfile);
#endif
errout_with_lock:
@@ -726,7 +727,7 @@ static inline int nxffs_rdopen(FAR struct nxffs_volume_s *volume,
/* Not already open.. create a new open structure */
ofile = (FAR struct nxffs_ofile_s *)
kmm_zalloc(sizeof(struct nxffs_ofile_s));
fs_heap_zalloc(sizeof(struct nxffs_ofile_s));
if (!ofile)
{
ferr("ERROR: ofile allocation failed\n");
@@ -761,7 +762,7 @@ static inline int nxffs_rdopen(FAR struct nxffs_volume_s *volume,
return OK;
errout_with_ofile:
kmm_free(ofile);
fs_heap_free(ofile);
errout_with_lock:
nxmutex_unlock(&volume->lock);
errout:
@@ -832,7 +833,7 @@ static inline void nxffs_freeofile(FAR struct nxffs_volume_s *volume,
if ((FAR struct nxffs_wrfile_s *)ofile != &g_wrfile)
#endif
{
kmm_free(ofile);
fs_heap_free(ofile);
}
}
+7 -6
View File
@@ -32,6 +32,7 @@
#include <nuttx/kmalloc.h>
#include "partition.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -205,7 +206,7 @@ gpt_alloc_verify_entries(FAR struct partition_state_s *state,
}
blk = (size + (state->blocksize - 1)) / state->blocksize;
pte = kmm_zalloc(blk * state->blocksize);
pte = fs_heap_zalloc(blk * state->blocksize);
if (!pte)
{
return NULL;
@@ -216,7 +217,7 @@ gpt_alloc_verify_entries(FAR struct partition_state_s *state,
ret = read_partition_block(state, pte, from, blk);
if (ret < 0)
{
kmm_free(pte);
fs_heap_free(pte);
ferr("Read ptr from block failed:%d.\n", ret);
return NULL;
}
@@ -227,7 +228,7 @@ gpt_alloc_verify_entries(FAR struct partition_state_s *state,
if (crc != le32toh(gpt->partition_entry_array_crc32))
{
ferr("GUID Partitition Entry Array CRC check failed.\n");
kmm_free(pte);
fs_heap_free(pte);
return NULL;
}
@@ -399,7 +400,7 @@ int parse_gpt_partition(FAR struct partition_state_s *state,
count = (sizeof(struct gpt_ptable_s) + (state->blocksize - 1)) /
state->blocksize;
ptbl = kmm_malloc(count * state->blocksize);
ptbl = fs_heap_malloc(count * state->blocksize);
if (!ptbl)
{
return -ENOMEM;
@@ -485,8 +486,8 @@ int parse_gpt_partition(FAR struct partition_state_s *state,
handler(&pentry, arg);
}
kmm_free(ptes);
fs_heap_free(ptes);
err:
kmm_free(ptbl);
fs_heap_free(ptbl);
return ret;
}
+5 -4
View File
@@ -30,6 +30,7 @@
#include <nuttx/kmalloc.h>
#include "partition.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -109,7 +110,7 @@ int parse_mbr_partition(FAR struct partition_state_s *state,
int i;
num = (MBR_SIZE + state->blocksize - 1) / state->blocksize;
buffer = kmm_malloc(num * state->blocksize);
buffer = fs_heap_malloc(num * state->blocksize);
if (!buffer)
{
return -ENOMEM;
@@ -118,13 +119,13 @@ int parse_mbr_partition(FAR struct partition_state_s *state,
ret = read_partition_block(state, buffer, 0, num);
if (ret < 0)
{
kmm_free(buffer);
fs_heap_free(buffer);
return ret;
}
if (buffer[0x1fe] != 0x55 || buffer[0x1ff] != 0xaa)
{
kmm_free(buffer);
fs_heap_free(buffer);
return -EINVAL;
}
@@ -211,6 +212,6 @@ int parse_mbr_partition(FAR struct partition_state_s *state,
}
out:
kmm_free(buffer);
fs_heap_free(buffer);
return ret;
}
+3 -2
View File
@@ -27,6 +27,7 @@
#include <nuttx/kmalloc.h>
#include "partition.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -91,7 +92,7 @@ int parse_ptable_partition(FAR struct partition_state_s *state,
/* Allocate one erase block memory */
ptable = kmm_malloc(state->erasesize);
ptable = fs_heap_malloc(state->erasesize);
if (ptable == NULL)
{
return -ENOMEM;
@@ -149,6 +150,6 @@ int parse_ptable_partition(FAR struct partition_state_s *state,
}
out:
kmm_free(ptable);
fs_heap_free(ptable);
return ret;
}
+3 -2
View File
@@ -30,6 +30,7 @@
#include <nuttx/kmalloc.h>
#include "partition.h"
#include "fs_heap.h"
/****************************************************************************
* Pre-processor Definitions
@@ -77,7 +78,7 @@ int parse_txtable_partition(FAR struct partition_state_s *state,
/* Allocate memory for table of parsed and raw */
part = kmm_malloc(CONFIG_TXTABLE_PARTITION_MAX_NUM *
part = fs_heap_malloc(CONFIG_TXTABLE_PARTITION_MAX_NUM *
sizeof(struct partition_s) +
TXTABLE_LENGTH);
if (part == NULL)
@@ -217,6 +218,6 @@ int parse_txtable_partition(FAR struct partition_state_s *state,
handler(&part[j], arg);
out:
kmm_free(part);
fs_heap_free(part);
return ret;
}
+7 -6
View File
@@ -48,6 +48,7 @@
#include "mount/mount.h"
#include "sched/sched.h"
#include "fs_heap.h"
/****************************************************************************
* External Definitions
@@ -468,7 +469,7 @@ static int procfs_close(FAR struct file *filep)
}
else
{
kmm_free(attr);
fs_heap_free(attr);
}
filep->f_priv = NULL;
@@ -656,7 +657,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
#endif
level0 = (FAR struct procfs_level0_s *)
kmm_zalloc(sizeof(struct procfs_level0_s) + sizeof(pid_t) * num) ;
fs_heap_zalloc(sizeof(struct procfs_level0_s) + sizeof(pid_t) * num);
if (!level0)
{
ferr("ERROR: Failed to allocate the level0 directory structure\n");
@@ -742,7 +743,7 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
*/
level1 = (FAR struct procfs_level1_s *)
kmm_zalloc(sizeof(struct procfs_level1_s));
fs_heap_zalloc(sizeof(struct procfs_level1_s));
if (!level1)
{
ferr("ERROR: Failed to allocate the level0 directory "
@@ -783,7 +784,7 @@ static int procfs_closedir(FAR struct inode *mountpt,
FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(mountpt && dir);
kmm_free(dir);
fs_heap_free(dir);
return OK;
}
@@ -1180,7 +1181,7 @@ int procfs_initialize(void)
/* No.. allocate a modifiable list of entries */
g_procfs_entries = (FAR struct procfs_entry_s *)
kmm_malloc(sizeof(g_base_entries));
fs_heap_malloc(sizeof(g_base_entries));
if (g_procfs_entries == NULL)
{
return -ENOMEM;
@@ -1246,7 +1247,7 @@ int procfs_register(FAR const struct procfs_entry_s *entry)
newsize = newcount * sizeof(struct procfs_entry_s);
newtable = (FAR struct procfs_entry_s *)
kmm_realloc(g_procfs_entries, newsize);
fs_heap_realloc(g_procfs_entries, newsize);
if (newtable != NULL)
{
/* Copy the new entry at the end of the reallocated table */
+5 -3
View File
@@ -36,6 +36,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#if defined(CONFIG_ARCH_HAVE_CPUINFO) && !defined(CONFIG_FS_PROCFS_EXCLUDE_CPUINFO)
/****************************************************************************
@@ -105,7 +107,7 @@ static int cpuinfo_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
procfile = kmm_zalloc(sizeof(struct cpuinfo_file_s));
procfile = fs_heap_zalloc(sizeof(struct cpuinfo_file_s));
if (procfile == NULL)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -133,7 +135,7 @@ static int cpuinfo_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(procfile);
fs_heap_free(procfile);
filep->f_priv = NULL;
return OK;
}
@@ -188,7 +190,7 @@ static int cpuinfo_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = kmm_malloc(sizeof(struct cpuinfo_file_s));
newattr = fs_heap_malloc(sizeof(struct cpuinfo_file_s));
if (newattr == NULL)
{
ferr("ERROR: Failed to allocate file attributes\n");
+5 -3
View File
@@ -44,6 +44,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS)
#if !defined(CONFIG_SCHED_CPULOAD_NONE) && \
!defined(CONFIG_FS_PROCFS_EXCLUDE_CPULOAD)
@@ -142,7 +144,7 @@ static int cpuload_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
attr = kmm_zalloc(sizeof(struct cpuload_file_s));
attr = fs_heap_zalloc(sizeof(struct cpuload_file_s));
if (!attr)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -170,7 +172,7 @@ static int cpuload_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(attr);
fs_heap_free(attr);
filep->f_priv = NULL;
return OK;
}
@@ -300,7 +302,7 @@ static int cpuload_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = kmm_malloc(sizeof(struct cpuload_file_s));
newattr = fs_heap_malloc(sizeof(struct cpuload_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
+5 -3
View File
@@ -43,6 +43,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
defined(CONFIG_SCHED_CRITMONITOR)
@@ -140,7 +142,7 @@ static int critmon_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
attr = kmm_zalloc(sizeof(struct critmon_file_s));
attr = fs_heap_zalloc(sizeof(struct critmon_file_s));
if (!attr)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -168,7 +170,7 @@ static int critmon_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(attr);
fs_heap_free(attr);
filep->f_priv = NULL;
return OK;
}
@@ -348,7 +350,7 @@ static int critmon_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = kmm_malloc(sizeof(struct critmon_file_s));
newattr = fs_heap_malloc(sizeof(struct critmon_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
+5 -3
View File
@@ -42,6 +42,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#if defined(CONFIG_DEVICE_TREE) && !defined(CONFIG_FS_PROCFS_EXCLUDE_FDT)
/****************************************************************************
@@ -123,7 +125,7 @@ static int fdt_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
attr = kmm_zalloc(sizeof(struct fdt_file_s));
attr = fs_heap_zalloc(sizeof(struct fdt_file_s));
if (attr == NULL)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -151,7 +153,7 @@ static int fdt_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(attr);
fs_heap_free(attr);
filep->f_priv = NULL;
return OK;
}
@@ -219,7 +221,7 @@ static int fdt_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = kmm_malloc(sizeof(struct fdt_file_s));
newattr = fs_heap_malloc(sizeof(struct fdt_file_s));
if (newattr == NULL)
{
ferr("ERROR: Failed to allocate file attributes\n");
+5 -3
View File
@@ -42,6 +42,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
defined(CONFIG_MM_IOB) && !defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO)
@@ -137,7 +139,7 @@ static int iobinfo_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
procfile = (FAR struct iobinfo_file_s *)
kmm_zalloc(sizeof(struct iobinfo_file_s));
fs_heap_zalloc(sizeof(struct iobinfo_file_s));
if (!procfile)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -165,7 +167,7 @@ static int iobinfo_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(procfile);
fs_heap_free(procfile);
filep->f_priv = NULL;
return OK;
}
@@ -248,7 +250,7 @@ static int iobinfo_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = (FAR struct iobinfo_file_s *)
kmm_malloc(sizeof(struct iobinfo_file_s));
fs_heap_malloc(sizeof(struct iobinfo_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
+5 -3
View File
@@ -46,6 +46,8 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include "fs_heap.h"
#ifndef CONFIG_FS_PROCFS_EXCLUDE_MEMINFO
/****************************************************************************
@@ -234,7 +236,7 @@ static int meminfo_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the file attributes */
procfile = kmm_zalloc(sizeof(struct meminfo_file_s));
procfile = fs_heap_zalloc(sizeof(struct meminfo_file_s));
if (!procfile)
{
ferr("ERROR: Failed to allocate file attributes\n");
@@ -262,7 +264,7 @@ static int meminfo_close(FAR struct file *filep)
/* Release the file attributes structure */
kmm_free(procfile);
fs_heap_free(procfile);
filep->f_priv = NULL;
return OK;
}
@@ -617,7 +619,7 @@ static int meminfo_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and attribute selection */
newattr = (FAR struct meminfo_file_s *)
kmm_malloc(sizeof(struct meminfo_file_s));
fs_heap_malloc(sizeof(struct meminfo_file_s));
if (!newattr)
{
ferr("ERROR: Failed to allocate file attributes\n");
+7 -5
View File
@@ -36,6 +36,8 @@
#include <nuttx/queue.h>
#include <nuttx/spinlock.h>
#include "fs_heap.h"
/****************************************************************************
* Private Types
****************************************************************************/
@@ -121,7 +123,7 @@ static int pressure_open(FAR struct file *filep, FAR const char *relpath,
return -ENOENT;
}
priv = kmm_zalloc(sizeof(struct pressure_file_s));
priv = fs_heap_zalloc(sizeof(struct pressure_file_s));
if (!priv)
{
return -ENOMEM;
@@ -147,7 +149,7 @@ static int pressure_close(FAR struct file *filep)
flags = spin_lock_irqsave(&g_pressure_lock);
dq_rem(&priv->entry, &g_pressure_memory_queue);
spin_unlock_irqrestore(&g_pressure_lock, flags);
free(priv);
fs_heap_free(priv);
return OK;
}
@@ -292,7 +294,7 @@ static int pressure_dup(FAR const struct file *oldp, FAR struct file *newp)
FAR struct pressure_file_s *newpriv;
uint32_t flags;
newpriv = kmm_zalloc(sizeof(struct pressure_file_s));
newpriv = fs_heap_zalloc(sizeof(struct pressure_file_s));
if (newpriv == NULL)
{
return -ENOMEM;
@@ -319,7 +321,7 @@ static int pressure_opendir(FAR const char *relpath,
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
DEBUGASSERT(relpath);
level = kmm_zalloc(sizeof(struct procfs_dir_priv_s));
level = fs_heap_zalloc(sizeof(struct procfs_dir_priv_s));
if (level == NULL)
{
return -ENOMEM;
@@ -339,7 +341,7 @@ static int pressure_opendir(FAR const char *relpath,
static int pressure_closedir(FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir);
kmm_free(dir);
fs_heap_free(dir);
return OK;
}
+12 -10
View File
@@ -57,6 +57,8 @@
#include <nuttx/mm/mm.h>
#include <nuttx/queue.h>
#include "fs_heap.h"
#if !defined(CONFIG_SCHED_CPULOAD_NONE) || defined(CONFIG_SCHED_CRITMONITOR)
# include <nuttx/clock.h>
#endif
@@ -904,7 +906,7 @@ static ssize_t proc_heap(FAR struct proc_file_s *procfile,
#ifdef CONFIG_MM_KERNEL_HEAP
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
{
info = kmm_mallinfo_task(&task);
info = fs_heap_mallinfo_task(&task);
}
else
#endif
@@ -1530,7 +1532,7 @@ static int proc_open(FAR struct file *filep, FAR const char *relpath,
/* Allocate a container to hold the task and node selection */
procfile = (FAR struct proc_file_s *)
kmm_zalloc(sizeof(struct proc_file_s));
fs_heap_zalloc(sizeof(struct proc_file_s));
if (procfile == NULL)
{
ferr("ERROR: Failed to allocate file container\n");
@@ -1563,7 +1565,7 @@ static int proc_close(FAR struct file *filep)
/* Release the file container structure */
kmm_free(procfile);
fs_heap_free(procfile);
filep->f_priv = NULL;
return OK;
}
@@ -1726,7 +1728,7 @@ static int proc_dup(FAR const struct file *oldp, FAR struct file *newp)
/* Allocate a new container to hold the task and node selection */
newfile = kmm_malloc(sizeof(struct proc_file_s));
newfile = fs_heap_malloc(sizeof(struct proc_file_s));
if (newfile == NULL)
{
ferr("ERROR: Failed to allocate file container\n");
@@ -1815,11 +1817,11 @@ static int proc_opendir(FAR const char *relpath,
}
/* Allocate the directory structure. Note that the index and procentry
* pointer are implicitly nullified by kmm_zalloc(). Only the remaining,
* non-zero entries will need be initialized.
* pointer are implicitly nullified by fs_heap_zalloc().
* Only the remaining, non-zero entries will need be initialized.
*/
procdir = kmm_zalloc(sizeof(struct proc_dir_s));
procdir = fs_heap_zalloc(sizeof(struct proc_dir_s));
if (procdir == NULL)
{
ferr("ERROR: Failed to allocate the directory structure\n");
@@ -1839,7 +1841,7 @@ static int proc_opendir(FAR const char *relpath,
if (node == NULL)
{
ferr("ERROR: Invalid path \"%s\"\n", relpath);
kmm_free(procdir);
fs_heap_free(procdir);
return -ENOENT;
}
@@ -1848,7 +1850,7 @@ static int proc_opendir(FAR const char *relpath,
if (!DIRENT_ISDIRECTORY(node->dtype))
{
ferr("ERROR: Path \"%s\" is not a directory\n", relpath);
kmm_free(procdir);
fs_heap_free(procdir);
return -ENOTDIR;
}
@@ -1882,7 +1884,7 @@ static int proc_opendir(FAR const char *relpath,
static int proc_closedir(FAR struct fs_dirent_s *dir)
{
DEBUGASSERT(dir != NULL);
kmm_free(dir);
fs_heap_free(dir);
return OK;
}

Some files were not shown because too many files have changed in this diff Show More