fs/mnemofs: Setup and VFS methods
The Setup and VFS methods for mnemofs, a NAND Flash File System. Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
This commit is contained in:
parent
de460b5a10
commit
23b7dc0651
@ -538,6 +538,7 @@ NuttX provides support for a variety of file systems out of the box.
|
||||
hostfs.rst
|
||||
littlefs.rst
|
||||
mmap.rst
|
||||
mnemofs.rst
|
||||
nfs.rst
|
||||
nxffs.rst
|
||||
partition.rst
|
||||
|
118
Documentation/components/filesystem/mnemofs.rst
Normal file
118
Documentation/components/filesystem/mnemofs.rst
Normal file
@ -0,0 +1,118 @@
|
||||
=======
|
||||
MNEMOFS
|
||||
=======
|
||||
|
||||
Mnemofs is a NAND Flash File System built for NuttX.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
If there's a NAND flash available at a location, for example, ``/dev/nand``,
|
||||
you can mount it with ``mnemofs`` to a location like ``/mydir`` using::
|
||||
|
||||
mount -t mnemofs /dev/nand /mydir
|
||||
|
||||
The above command will only work if the device was already formatted using
|
||||
mnemofs. For a brand new device, or if you want to switch from an existing
|
||||
file system, this won't work, and would need a format.
|
||||
|
||||
Instead try this::
|
||||
|
||||
mount -t mnemofs -o forceformat /dev/nand /mydir
|
||||
|
||||
Unsure of whether you need to do a format? This will help::
|
||||
|
||||
mount -t mnemofs -o autoformat /dev/nand /mydir
|
||||
|
||||
This will format the device only if it can not detect mnemofs being already
|
||||
formatted onto it. Do note this includes cases where mnemofs is formatted to
|
||||
the device, but it's been mutilated to the point of being unrecognizable.
|
||||
|
||||
After this, use it like a regular file system. That's the job of a file
|
||||
system after all...to hide the storage device's pecularities behind an
|
||||
abstraction. A file system is considered good if you don't have to think
|
||||
about its existence during regular usage.
|
||||
|
||||
Design
|
||||
======
|
||||
|
||||
mnemofs is designed to be a middle ground between flash storage consumption,
|
||||
memory consumption, wear and speed. It sacrifices a little bit of everything,
|
||||
and ends up being acceptably good in all of them, instead of sacrificing
|
||||
multiple aspects, and being good in one.
|
||||
|
||||
mnemofs consists of several components, however, a walkthrough of the process
|
||||
where a change requested by a user ends up being written to the NAND flash
|
||||
would serve well for an introduction. The details will be explained further
|
||||
below.
|
||||
|
||||
The user requests some changes, say, add ``x`` bytes to ``y`` offset in a file.
|
||||
This change is copied into the LRU cache of mnemofs. This LRU cache exists
|
||||
in-memory, and serves as a tool for wear reduction.
|
||||
|
||||
This LRU cache is a kernel list of nodes. Each node represents a file or a
|
||||
directory. When the LRU is full, the last node is popped from this list and
|
||||
the changes it contains, which is an accumulation of changes requested by
|
||||
the user for that particular file or directory since the node was added to
|
||||
the LRU cache, is written to the flash.
|
||||
|
||||
Each file or directory is represented by a `CTZ skip list <https://github.com/littlefs-project/littlefs/blob/master/DESIGN.md#ctz-skip-lists>`_,
|
||||
and the only attributes required to access the list is the index of the last
|
||||
CTZ skip list block, the page number of that CTZ skip list block, and the
|
||||
size of the file. In mnemofs, CTZ skip list blocks take up exactly one page
|
||||
on the flash.
|
||||
|
||||
Mnemofs works in a Copy-On-Write manner, similar to littlefs. When a CTZ
|
||||
skip list is updated, the new location is added to the Journal of mnemofs
|
||||
as a log. This log contains some information about the location of the new
|
||||
CTZ list, the path it belongs to, etc. and then the updated location is
|
||||
added as an update to its parent's CTZ skip list, and it undergoes the same
|
||||
process. This log is appended with a checksum of the entire log, which
|
||||
gives an assurance that the saved log was indeed saved completely before a
|
||||
power loos.
|
||||
|
||||
The journal is a modified singly linked list of blocks on the flash that
|
||||
contains logs of changes in the file system. The last two blocks of the
|
||||
journal is reserved for master blocks, hence the number of blocks in the
|
||||
journal will be referred to as ``n + 2`` blocks.
|
||||
|
||||
The area on storage other than the journal contains a certain "base" state of
|
||||
the file system. All changes to the base state since is written to the
|
||||
journal. The first block of the journal starts with an 8 byte magic sequence
|
||||
to identify the start of the journal (on mount), followed by the number of
|
||||
blocks in the journal and then finally an array of all the ``n + 2`` block
|
||||
numbers that are part of the journal. After this part, the entire area in the
|
||||
``n`` blocks contain logs and their checksums.
|
||||
|
||||
The last two blocks of a journal are called the master blocks, and they store
|
||||
multiple instances of the master node. They are duplicates of each other, and
|
||||
each instance of the master node takes one page each, and are written to
|
||||
these master blocks in a sequential manner. The master node points to the
|
||||
root.
|
||||
|
||||
When the first ``n`` blocks of the journal are full, then they are flushed
|
||||
and since the root updates here as well, a new master node is written. Once
|
||||
the new master node is written, the file system's base state is updated and
|
||||
thus the old obsolete pages can be erased (if possible). The first ``n``
|
||||
blocks of the journal move more than the master nodes.
|
||||
|
||||
The block allocator of mnemofs is havily inspired from littlefs. It starts
|
||||
from a random block, and starts allocating pages or blocks sequentially in a
|
||||
circular manner. It skips pages upon block requirement, but since block
|
||||
requirements are only required by internal structures, they are always
|
||||
requested in bulk, and minimize wastage. However, unlike in littlefs, mnemofs
|
||||
keeps a bitmap in memory about the pages that are currently being used, as
|
||||
well as the count of pages inside each block that want to be erased.
|
||||
|
||||
In mnemofs, the bind might take a lot of time in the worst possible
|
||||
theoretical case, as it's an ``O(n)`` mounting process, however, it's not the
|
||||
case in real life. Mnemofs only needs to scan the first page of every block
|
||||
in the device to look for the start of the journal. Leaving the actual
|
||||
location of the page aside, this will be pretty fast in real life as the
|
||||
larger the storage capacity is, the larger are the pages and the larger are
|
||||
the number of pages per block, and thus the number of blocks in the device
|
||||
do not increase at a rate similar to the increase in storage capacity of the
|
||||
device. Further, the journal has the journal array, which contains block
|
||||
numbers of each block in it, very close to the start of the array, and
|
||||
mnemofs can quickly jump from there to the latest master node, and scan
|
||||
the file system for used pages.
|
@ -134,3 +134,4 @@ source "fs/userfs/Kconfig"
|
||||
source "fs/hostfs/Kconfig"
|
||||
source "fs/rpmsgfs/Kconfig"
|
||||
source "fs/zipfs/Kconfig"
|
||||
source "fs/mnemofs/Kconfig"
|
@ -57,6 +57,7 @@ include hostfs/Make.defs
|
||||
include littlefs/Make.defs
|
||||
include rpmsgfs/Make.defs
|
||||
include zipfs/Make.defs
|
||||
include mnemofs/Make.defs
|
||||
|
||||
endif
|
||||
|
||||
|
53
fs/mnemofs/CMakeLists.txt
Normal file
53
fs/mnemofs/CMakeLists.txt
Normal file
@ -0,0 +1,53 @@
|
||||
# ##############################################################################
|
||||
# fs/mnemofs/CMakeLists.txt
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||
# license agreements. See the NOTICE file distributed with this work for
|
||||
# additional information regarding copyright ownership. The ASF licenses this
|
||||
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||
# use this file except in compliance with the License. You may obtain a copy of
|
||||
# the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of the
|
||||
# BSD-3-Clause license:
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
# Copyright (c) 2024 Saurav Pal
|
||||
#
|
||||
# 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 of the author nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
#
|
||||
# ##############################################################################
|
||||
|
||||
if(CONFIG_FS_MNEMOFS)
|
||||
target_sources(
|
||||
fs PRIVATE mnemofs_blkalloc.c mnemofs_fsobj.c mnemofs_journal.c
|
||||
mnemofs_lru.c mnemofs_rw.c mnemofs.c)
|
||||
endif()
|
45
fs/mnemofs/Kconfig
Normal file
45
fs/mnemofs/Kconfig
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config FS_MNEMOFS
|
||||
bool "MNEMOFS NAND Flash File System"
|
||||
default n
|
||||
depends on !DISABLE_MOUNTPOINT && MTD_NAND
|
||||
---help---
|
||||
Build the mnemofs NAND flash file system.
|
||||
|
||||
if FS_MNEMOFS
|
||||
config MNEMOFS_JOURNAL_NBLKS
|
||||
int "MNEMOFS Journal Block Count"
|
||||
default 20
|
||||
range 4 65536
|
||||
depends on FS_MNEMOFS
|
||||
---help---
|
||||
Number of blocks that mnemofs will use for the journal. Specifying
|
||||
this will only work on formatting a NAND flash using mnemofs. If the
|
||||
device is already formatted, the on-flash journal block count will
|
||||
be considered instead. Two additional blocks will be allocated for
|
||||
the master blocks.
|
||||
|
||||
config MNEMOFS_NLRU
|
||||
int "MNEMOFS LRU Node Count"
|
||||
default 20
|
||||
range 1 255
|
||||
depends on FS_MNEMOFS
|
||||
---help---
|
||||
Number of nodes used by mnemofs for LRU. The higher the value is,
|
||||
the lesser would be the wear on device with higher RAM
|
||||
consumption.
|
||||
|
||||
config MNEMOFS_NLRUDELTA
|
||||
int "MNEMOFS LRU Delta Count"
|
||||
default 20
|
||||
range 1 255
|
||||
depends on FS_MNEMOFS
|
||||
---help---
|
||||
Number of deltas used by mnemofs for LRU for every node. The higher
|
||||
the value is, the lesser would be the wear on device with higher RAM
|
||||
consumption.
|
||||
endif # FS_MNEMOFS
|
66
fs/mnemofs/Make.defs
Normal file
66
fs/mnemofs/Make.defs
Normal file
@ -0,0 +1,66 @@
|
||||
############################################################################
|
||||
# fs/mnemofs/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# the BSD-3-Clause license:
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
# Copyright (c) 2024 Saurav Pal
|
||||
#
|
||||
# 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 of the author nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_FS_MNEMOFS),y)
|
||||
|
||||
# Add the mnemofs C files to the build
|
||||
|
||||
CSRCS += mnemofs_blkalloc.c
|
||||
CSRCS += mnemofs_fsobj.c
|
||||
CSRCS += mnemofs_journal.c
|
||||
CSRCS += mnemofs_lru.c
|
||||
CSRCS += mnemofs_rw.c
|
||||
CSRCS += mnemofs.c
|
||||
|
||||
# Add the mnemofs directory to the build
|
||||
|
||||
DEPPATH += --dep-path mnemofs
|
||||
VPATH += :mnemofs
|
||||
endif
|
2148
fs/mnemofs/mnemofs.c
Normal file
2148
fs/mnemofs/mnemofs.c
Normal file
File diff suppressed because it is too large
Load Diff
1106
fs/mnemofs/mnemofs.h
Normal file
1106
fs/mnemofs/mnemofs.h
Normal file
File diff suppressed because it is too large
Load Diff
128
fs/mnemofs/mnemofs_blkalloc.c
Normal file
128
fs/mnemofs/mnemofs_blkalloc.c
Normal file
@ -0,0 +1,128 @@
|
||||
/****************************************************************************
|
||||
* fs/mnemofs/mnemofs_blkalloc.c
|
||||
* Block Allocator for mnemofs
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the BSD-3-Clause license:
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Saurav Pal
|
||||
*
|
||||
* 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 of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* mnemofs block allocator takes some inspiration from littlefs's block
|
||||
* allocator.
|
||||
*
|
||||
* It has two primary jobs...provide a block and ensure wear levelling. The
|
||||
* block allocator of mnemofs tries to provide a block that will more or less
|
||||
* ensure wear levelling. We'll call the block allocator as BA.
|
||||
*
|
||||
* The block allocator starts at a random block in the device and starts a
|
||||
* circular allocation from there, ie. it allocated sequentially till it
|
||||
* reaches the end, at which point it cycles back to the beginning and then
|
||||
* continues allocating sequentially. If a page is requested it will check if
|
||||
* the page has been written to (being used). If a page is being written to
|
||||
* but all the pages in a block are ready to be erased, then the block is
|
||||
* erased and page is allocated. If none of these two conditions match, it
|
||||
* moves on to check the next page and so on. If the block that contains the
|
||||
* page is a bad block, the BA skips all the pages in the entire block.
|
||||
*
|
||||
* The BA can also grant a request for an entire block. If the BA is
|
||||
* currently in the middle of a block, it will skip the remaining pages till
|
||||
* it reaches the start of the next block. These pages won't be reflected as
|
||||
* being used, and can be allocated the next time the BA cycles back to these
|
||||
* pages. Even though skipped pages will be eventually utilized later anyway,
|
||||
* block allocation requests are made by very few critical data structures
|
||||
* in mnemofs, and they all do it in bulk, and thus skipped pages are
|
||||
* minimal.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mnemofs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int mfs_ba_init(FAR struct mfs_sb_s * const sb)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void mfs_ba_free(FAR struct mfs_sb_s * const sb)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
250
fs/mnemofs/mnemofs_fsobj.c
Normal file
250
fs/mnemofs/mnemofs_fsobj.c
Normal file
@ -0,0 +1,250 @@
|
||||
/****************************************************************************
|
||||
* fs/mnemofs/mnemofs_fsobj.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the BSD-3-Clause license:
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Saurav Pal
|
||||
*
|
||||
* 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 of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* In mnemofs, all the FS object methods (ie. methods in this file),
|
||||
* interface directly with the LRU. To these methods, only the methods
|
||||
* exposed by the LRU are visible, nothing else. The LRU will give them the
|
||||
* most updated data, which includes data from the flash, the updates from
|
||||
* the journal and the LRU deltas as well.
|
||||
*
|
||||
* TODO: The above menetioned concept.
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "mnemofs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
FAR const char * mfs_path2childname(FAR const char *relpath)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mfs_t mfs_get_fsz(FAR struct mfs_sb_s * const sb,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mfs_get_patharr(FAR struct mfs_sb_s *const sb,
|
||||
FAR const char *relpath, FAR struct mfs_path_s **path,
|
||||
FAR mfs_t *depth)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void mfs_free_patharr(FAR struct mfs_path_s *path)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
bool mfs_obj_isempty(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_pitr_s * const pitr)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void mfs_pitr_init(FAR struct mfs_sb_s * const sb,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth, FAR struct mfs_pitr_s *pitr, bool child)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_free(FAR struct mfs_pitr_s * const pitr)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_adv(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_pitr_s * const pitr)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_adv_dirent(FAR struct mfs_pitr_s * const pitr,
|
||||
FAR const struct mfs_dirent_s * const dirent)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_adv_off(FAR struct mfs_pitr_s * const pitr,
|
||||
const mfs_t off)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_adv_tochild(FAR struct mfs_pitr_s * const pitr,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_reset(FAR struct mfs_pitr_s * const pitr)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_pitr_sync(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_pitr_s * const pitr,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
int mfs_pitr_readdirent(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_pitr_s * const pitr,
|
||||
FAR struct mfs_dirent_s **dirent)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void mfs_free_dirent(FAR struct mfs_dirent_s *dirent)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
bool mfs_searchfopen(FAR const struct mfs_sb_s * const sb,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int mfs_pitr_appendnew(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_path_s * const path,
|
||||
const mfs_t depth,
|
||||
FAR const struct mfs_pitr_s * const pitr,
|
||||
FAR const char * const child_name,
|
||||
const mode_t mode)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_pitr_appenddirent(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_path_s * const path,
|
||||
const mfs_t depth,
|
||||
FAR const struct mfs_pitr_s * const pitr,
|
||||
FAR const struct mfs_dirent_s * const dirent)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_pitr_rmdirent(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_path_s * const path,
|
||||
const mfs_t depth,
|
||||
FAR struct mfs_pitr_s * const pitr,
|
||||
FAR const struct mfs_dirent_s * const dirent)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_pitr_rm(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_path_s * const path,
|
||||
const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
131
fs/mnemofs/mnemofs_journal.c
Normal file
131
fs/mnemofs/mnemofs_journal.c
Normal file
@ -0,0 +1,131 @@
|
||||
/****************************************************************************
|
||||
* fs/mnemofs/mnemofs_journal.c
|
||||
* Journal of mnemofs.
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the BSD-3-Clause license:
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Saurav Pal
|
||||
*
|
||||
* 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 of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* In mnemofs, the journal stores the path, depth and the new location of the
|
||||
* CTZ file called logs, and also the location of the master block. The first
|
||||
* n blocks of the journal store the logs, while the last two blocks contain
|
||||
* master nodes, and the blocks are called as master blocks. The two master
|
||||
* blocks are identical copies for backup.
|
||||
*
|
||||
* Due to LRU, and the structure of mnemofs, the first n blocks of the
|
||||
* journal get filled up much faster than the master blocks, and move more.
|
||||
* There will be certain point where the entire journal (the n+2 blocks)
|
||||
* move, but mostly, its the first n blocks that move.
|
||||
*
|
||||
* The first block starts with an 8 byte magic sequence, a 2 bytes long
|
||||
* number denoting number of blocks in the journal, and then follows up
|
||||
* with an array containing the block numbers of all blocks in the journal
|
||||
* including the first block. Then the logs start.
|
||||
*
|
||||
* The logs take up size in multiples of pages. There might be unitilzed
|
||||
* space at the end of a log.
|
||||
*
|
||||
* All logs are followed by a byte-long hash of the log.
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <endian.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/list.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "mnemofs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int mfs_jrnl_init(FAR struct mfs_sb_s * const sb, mfs_t blk)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void mfs_jrnl_free(FAR struct mfs_sb_s * const sb)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
int mfs_jrnl_fmt(FAR struct mfs_sb_s * const sb, mfs_t blk1, mfs_t blk2)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
152
fs/mnemofs/mnemofs_lru.c
Normal file
152
fs/mnemofs/mnemofs_lru.c
Normal file
@ -0,0 +1,152 @@
|
||||
/****************************************************************************
|
||||
* fs/mnemofs/mnemofs_lru.c
|
||||
* LRU cache of mnemofs.
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the BSD-3-Clause license:
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Saurav Pal
|
||||
*
|
||||
* 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 of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* LRU (Least Recently Used) cache takes in all the changes the user wants
|
||||
* to do to the on-flash storage, and stores them in memory. When a
|
||||
* significant amount of changes are accumulated, the LRU writes the new
|
||||
* information to the flash.
|
||||
*
|
||||
* LRU is a kernel list of nodes. Each node represents a CTZ list. Each node
|
||||
* contains a kernel list of changes requested for the CTZ list, called as
|
||||
* deltas.
|
||||
*
|
||||
* When LRU is full the last node is flushed (it can be explicitly flushed as
|
||||
* well) and all the changes are written at once on the flash, and the new
|
||||
* location is noted down in the journal, and an entry for the location
|
||||
* update is added to the LRU for the parent.
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/list.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "mnemofs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int mfs_lru_ctzflush(FAR struct mfs_sb_s * const sb,
|
||||
FAR struct mfs_path_s * const path, const mfs_t depth,
|
||||
const mfs_t ctz_sz)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_lru_del(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
|
||||
mfs_t bytes, mfs_t ctz_sz,
|
||||
FAR struct mfs_path_s * const path, const mfs_t depth)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_lru_wr(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
|
||||
mfs_t bytes, mfs_t ctz_sz, FAR struct mfs_path_s * const path,
|
||||
const mfs_t depth, FAR const char *buf)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int mfs_lru_rdfromoff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
|
||||
FAR struct mfs_path_s * const path, const mfs_t depth,
|
||||
FAR char *buf, const mfs_t buflen)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void mfs_lru_init(FAR struct mfs_sb_s * const sb)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void mfs_lru_updatedsz(FAR struct mfs_sb_s * const sb,
|
||||
FAR const struct mfs_path_s * const path,
|
||||
const mfs_t depth, mfs_t *n_sz)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
91
fs/mnemofs/mnemofs_rw.c
Normal file
91
fs/mnemofs/mnemofs_rw.c
Normal file
@ -0,0 +1,91 @@
|
||||
/****************************************************************************
|
||||
* fs/mnemofs/mnemofs_rw.c
|
||||
* Read/Write utilities for mnemofs
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the BSD-3-Clause license:
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Saurav Pal
|
||||
*
|
||||
* 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 of the author nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 "mnemofs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t mfs_read_page(FAR const struct mfs_sb_s * const sb,
|
||||
FAR char *data, const mfs_t datalen, const off_t page,
|
||||
const mfs_t pgoff)
|
||||
{
|
||||
return OK;
|
||||
}
|
@ -57,8 +57,8 @@
|
||||
|
||||
/* These file systems require MTD drivers */
|
||||
|
||||
#if (defined(CONFIG_FS_SPIFFS) || defined(CONFIG_FS_LITTLEFS)) && \
|
||||
defined(CONFIG_MTD)
|
||||
#if (defined(CONFIG_FS_SPIFFS) || defined(CONFIG_FS_LITTLEFS) || \
|
||||
defined(CONFIG_FS_MNEMOFS)) && defined(CONFIG_MTD)
|
||||
# define MDFS_SUPPORT 1
|
||||
#endif
|
||||
|
||||
@ -132,6 +132,9 @@ extern const struct mountpt_operations g_spiffs_operations;
|
||||
#ifdef CONFIG_FS_LITTLEFS
|
||||
extern const struct mountpt_operations g_littlefs_operations;
|
||||
#endif
|
||||
#ifdef CONFIG_FS_MNEMOFS
|
||||
extern const struct mountpt_operations g_mnemofs_operations;
|
||||
#endif
|
||||
|
||||
static const struct fsmap_t g_mdfsmap[] =
|
||||
{
|
||||
@ -143,6 +146,9 @@ static const struct fsmap_t g_mdfsmap[] =
|
||||
#endif
|
||||
#ifdef CONFIG_FS_LITTLEFS
|
||||
{ "littlefs", &g_littlefs_operations },
|
||||
#endif
|
||||
#ifdef CONFIG_FS_MNEMOFS
|
||||
{ "mnemofs", &g_mnemofs_operations },
|
||||
#endif
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
@ -82,6 +82,7 @@
|
||||
#define _XIAFS_SUPER_MAGIC 0x012fd16d
|
||||
#define SPIFFS_SUPER_MAGIC 0x20090315
|
||||
#define LITTLEFS_SUPER_MAGIC 0x0a732923
|
||||
#define MNEMOFS_SUPER_MAGIC 0x704b8e4d
|
||||
|
||||
/* NuttX specific file-systems */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user