jlaitine commented on code in PR #8026: URL: https://github.com/apache/nuttx/pull/8026#discussion_r1065405960
########## fs/mmap/fs_rammap.c: ########## @@ -44,12 +41,83 @@ * Public Data ****************************************************************************/ -/* This is the list of all mapped files */ +/**************************************************************************** + * Private Functions + ****************************************************************************/ -struct fs_allmaps_s g_rammaps = +static int unmap_rammap(FAR struct task_group_s *group, + FAR struct mm_map_entry_s *entry, + FAR void *start, + size_t length) { - NXMUTEX_INITIALIZER -}; + FAR void *newaddr; + unsigned int offset; + bool kernel = entry->priv.i != 0 ? true : false; + int ret; + + /* Get the offset from the beginning of the region and the actual number + * of bytes to "unmap". All mappings must extend to the end of the region. + * There is no support for freeing a block of memory but leaving a block of + * memory at the end. This is a consequence of using kumm_realloc() to + * simulate the unmapping. + */ + + offset = start - entry->vaddr; + if (offset + length < entry->length) + { + ferr("ERROR: Cannot umap without unmapping to the end\n"); + return -ENOSYS; + } + + /* Okay.. the region is being unmapped to the end. Make sure the length + * indicates that. + */ + + length = entry->length - offset; + + /* Are we unmapping the entire region (offset == 0)? */ + + if (length >= entry->length) + { + /* Free the region */ + + if (kernel) + { + kmm_free(entry->vaddr); + } + else + { + kumm_free(entry->vaddr); + } + + /* Then remove the mapping from the list */ + + ret = mm_map_remove(group_get_mm(group), &entry); Review Comment: I don't care, if you insist we can do it. My thinking is that it can still fail. Not done yet. ########## fs/mmap/Kconfig: ########## @@ -25,3 +25,9 @@ config FS_RAMMAP if FS_RAMMAP Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org