2007-11-20 20:32:33 +00:00
|
|
|
############################################################################
|
|
|
|
|
# fs/Makefile
|
2007-02-17 23:21:28 +00:00
|
|
|
#
|
2024-11-05 09:32:55 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
2021-02-03 14:47:23 +01:00
|
|
|
# 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
|
2007-02-17 23:21:28 +00:00
|
|
|
#
|
2021-02-03 14:47:23 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-17 23:21:28 +00:00
|
|
|
#
|
2021-02-03 14:47:23 +01:00
|
|
|
# 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.
|
2007-02-17 23:21:28 +00:00
|
|
|
#
|
2007-11-20 20:32:33 +00:00
|
|
|
############################################################################
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2020-05-19 03:42:11 +08:00
|
|
|
include $(TOPDIR)/Make.defs
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2024-06-14 11:56:13 +08:00
|
|
|
CSRCS = fs_initialize.c fs_heap.c
|
2011-06-02 15:05:48 +00:00
|
|
|
|
2024-09-09 20:28:16 +08:00
|
|
|
ifneq ($(CONFIG_FS_HEAPBUF_SECTION),"")
|
|
|
|
|
CFLAGS += ${DEFINE_PREFIX}FS_HEAPBUF_SECTION=CONFIG_FS_HEAPBUF_SECTION
|
|
|
|
|
endif
|
|
|
|
|
|
2014-09-28 10:53:40 -06:00
|
|
|
include inode/Make.defs
|
2014-09-28 11:46:11 -06:00
|
|
|
include vfs/Make.defs
|
2014-09-28 11:06:21 -06:00
|
|
|
include driver/Make.defs
|
2014-10-05 15:33:31 -06:00
|
|
|
include aio/Make.defs
|
2011-05-07 20:08:46 +00:00
|
|
|
include mmap/Make.defs
|
|
|
|
|
|
2014-09-28 14:35:17 -06:00
|
|
|
# OS resources
|
|
|
|
|
|
|
|
|
|
include semaphore/Make.defs
|
2014-09-29 07:00:11 -06:00
|
|
|
include mqueue/Make.defs
|
2014-09-29 16:46:31 -06:00
|
|
|
include shm/Make.defs
|
2021-02-23 18:04:13 +08:00
|
|
|
include socket/Make.defs
|
2024-08-22 21:00:47 +08:00
|
|
|
include event/Make.defs
|
2014-09-28 14:35:17 -06:00
|
|
|
|
2011-06-02 15:05:48 +00:00
|
|
|
# Additional files required is mount-able file systems are supported
|
|
|
|
|
|
2008-10-22 22:02:44 +00:00
|
|
|
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
2013-01-16 15:41:27 +00:00
|
|
|
|
2014-09-28 11:28:17 -06:00
|
|
|
include mount/Make.defs
|
2018-08-28 07:30:21 -06:00
|
|
|
include partition/Make.defs
|
2008-08-02 15:02:10 +00:00
|
|
|
include fat/Make.defs
|
2008-09-10 19:29:24 +00:00
|
|
|
include romfs/Make.defs
|
2018-03-19 07:08:40 -06:00
|
|
|
include cromfs/Make.defs
|
2015-10-09 11:02:59 -06:00
|
|
|
include tmpfs/Make.defs
|
2011-04-28 19:26:46 +00:00
|
|
|
include nxffs/Make.defs
|
2012-03-02 02:11:31 +00:00
|
|
|
include nfs/Make.defs
|
2013-04-30 20:13:30 -06:00
|
|
|
include smartfs/Make.defs
|
2013-01-16 15:41:27 +00:00
|
|
|
include binfs/Make.defs
|
2013-11-13 15:59:14 -06:00
|
|
|
include procfs/Make.defs
|
This commit brings in an inital port of the SPIFFS flash file system into NuttX. The file system is still untested at this point (and subject to some additional review). It is, however, marked EXPERIMENTAL should this should not cause a problem for anyone.
Squashed commit of the following:
fs/spiffs: Fix last compilation issue. Now compiles without error. It is still not quite ready for testing as there is additional code review that must be be performed. It is now marked as EXPERIMENTAL so that it can be brought onto the master branch with little risk.
fs/spiffs: Remove some dead code.
fs/spiffs: Weak start of analysis of spiffs_nucleus.c. Renamed to spiffs_core.c
fs/spiffs: Rename spiffs_nucleus.c to spiffs_core.c
fs/spiffs: Remove spiffs_config.h. All configuration settings are now available in the SPIFFS Kconfig options.
fs/spiffs: Finished review, update, and repartitioning of spiffs_check.c. Added spiffs_check.h.
fs/spiffs: Finished review, update, and repartitioning of spiffs_cache.c. Added spiffs_cache.h.
fs/spiffs: Clean up some defines used in debug output statements.
fs/spiffs: Finished review, update, and repartitioning of spiffs_gc.c. Added spiffs_gc.h.
fs/spiffs: Now that VFS interface is completed, I have begun the long march of repartitioning the remaining functionality, reviewing logic, identifying dead code, and cleaning up loose ends.
fs/spiffs: Initial integration of MTD interface, replacing the SPIFFS native flash interface. Lots of open issues such as the use of pages vs. blocks vs. erase blocks and units of addresses, offsets, and lengths that are passed in function calls. Remove SPIFFS_USE_MAGIC support. That option (which default to OFF anyway), wrote a magic value at the beginning of every sector and support verifiable identification of the file system. It was not being and used and removing it makes life simpler.
fs/spiffs: Remove semaphore lock on the file object structure. Ultimately, the file access must modify the volume and access the volume structue which also has a exclusivity lock. So use of the volume lock alone should be sufficient.
Integrated the SPIFFS rename logic into the NuttX VFS. Removed non-standard application calls or convert them to IOCTL commands. These were converted to IOCTL commands: (1) integrity check, (2) garbage collection, and (3) format flash. These were removed: (1) Integrity check callback. These provided a lot of good information about the state of the file system, but such callbacks are not compatible with a POSIX compliant file system. (2) Index maps. The index maps were a performance improvement feature. The user could provide the memory and request that a region of a a file use that memory for improved lookup performance when accessing parts of the file. The fallback is the less performance lookup by traversing the FLASH memory. (3) Removed the quick garbage collection interface (the code is still used internally). Only the full garbage collection is available to the user application via IOCTL.
configs/sim/spiffs: A simulator configuration to use for testing SPIFFS.
fs/spiffs: Integrate SPIFFS logic into NuttX VFS bind() and unbind() methods.
fs/mount/fs_mount.c: Add SPIFFS to the list of drivers that require MTD vs block drivers.
fs/spiffs: Trivial changes, mostly from analysis of how to integrate the rename() VFS method.
fs/spiffs: Connect NuttX VFS unlink method to the SPIFFS_remove() function. Lots of name-changing.
fs/spiffs: Remove non-standard errno support. Remove bogus SPIFFS_LOCK() and SPIFFS_UNLOCK() macros.
fs/spiffs: Add NuttX VFS implementation for statfs() method. Clean up some of the accumulating compilation problems.
fs/spiffs: Add stat(), truncate() methods. Dummy out unsupport mkdir() and rmdir() methods.
fs/spiffs: Replace some of the custom error numbers with standard error numbers.
fs/spiffs: Hooks read(), write(), fstat(), ioctl(), opendir(), closedir(), rewindif(), and readdir() into the NuttX VFS.
fs/spiffs: Beginning the organization to work with the NuttX VFS. Lots of things are get broken!
fs/spiffs: Add spiffs.c which will be the interface between SPIFFS and NuttX. No very close at present, however.
fs/spiffs: Clean up some compile problems introduced by coding standard changes.
fs/spiffs: A little closer to NuttX coding standard.
fs/spiffs: Ran tools/indent.sh against all files. Closer to NuttX coding standard, but needs a lot more effort to be fully compliant.
fs/spiffs: This commit brings in version 0.3.7 of Peter Anderson's SPIFFS. The initial commit includes the core FS files (with some definitions destributed to their correct header files) and hooks into the build system.
2018-09-24 18:05:09 -06:00
|
|
|
include spiffs/Make.defs
|
2015-06-05 13:18:06 -06:00
|
|
|
include unionfs/Make.defs
|
2017-10-30 18:04:28 -06:00
|
|
|
include userfs/Make.defs
|
2015-11-25 08:26:26 -06:00
|
|
|
include hostfs/Make.defs
|
2019-01-09 14:26:51 -06:00
|
|
|
include littlefs/Make.defs
|
2021-11-30 20:00:03 +08:00
|
|
|
include rpmsgfs/Make.defs
|
2023-09-25 16:25:34 +08:00
|
|
|
include zipfs/Make.defs
|
2024-07-09 18:57:16 +00:00
|
|
|
include mnemofs/Make.defs
|
fs/xipfs: Add a contiguous execute-in-place file system.
ROMFS is the usual way to carry executables on a NOMMU target with memory
mapped NOR flash: it can hand out a real flash pointer from mmap(), so the
NXFLAT loader maps a module's text in place instead of copying it into RAM.
But a ROMFS image is built on the host and is read only, so a module cannot
be downloaded onto the board at run time.
xipfs is a writable file system with the same in-place property. Each file
is stored as one physically contiguous, erase-block aligned extent, so an
mmap() of it resolves to flash_base + extent_offset and a loader can execute
the file where it already lies. This needs the underlying MTD driver to
answer BIOC_XIPBASE; on the RP2350 rp23xx_flash_mtd.c does.
Files are write once. A file is created, its size is declared, it is
written sequentially, closed, and is thereafter immutable until it is
deleted. That is the whole life cycle of a downloaded module, and it is
what licenses the design: the exact extent is reserved at create time, so
no file ever grows, moves, or fragments internally. Random writes, appends
and truncation of a written file are not supported and are refused.
The only source of fragmentation is therefore free space holes left by
deletes. Allocation fails with -ENOSPC when no single contiguous run is
large enough, and never defragments on its own; the caller decides whether
to compact and retry, through XIPFSIOC_DEFRAG. Defragmentation is manual,
best effort and interruptible: it is a loop of atomic single-extent
relocations, each one copy, commit, erase, so every stop point -- a time
budget, a pinned extent, an erase error -- leaves a consistent layout that
is simply less compact. It reports the largest contiguous run it achieved,
which is what tells the caller whether the retry will fit.
Metadata is committed power safely. Two metadata block sets are used in
ping-pong, each generation carrying a sequence number and a CRC, and every
state change is ordered as write the new data, flip the metadata reference,
then erase what the old one referenced. Mount scans both sets and selects
the last fully valid generation, so a torn write costs the interrupted
operation and nothing else.
A mapping takes a pin on the extent, and the pin lives on the extent rather
than on the file descriptor, so three running instances of one module hold
three pins and the extent becomes movable only when the last one goes.
Defragmentation skips pinned extents, which is what stops it relocating
code that is executing. The pin is released by munmap() or by the task
teardown walk, so a task that dies without unmapping does not leak it.
Directories are records in that same generation, carrying their own identity
and the identity of the directory holding them; the root is implicit and owns
identity zero. They are deliberately NOT objects in the data region, which
is what keeps the commit story in one piece: mkdir and rmdir add or remove a
record and commit one generation, exactly as create and unlink do, so there
is never a multi-object update to journal or an orphan to collect at mount.
An empty directory therefore exists, survives a remount, and costs one entry
out of the volume's fixed supply and no flash blocks at all.
A name is one path component; depth comes from the parent, so XIPFS_NAME_MAX
bounds a component, which is what statfs reports it as. Mount rebuilds the
tree and checks that it is one: identities unique, names unique within a
directory, every parent a live directory, and following parents reaching the
root -- a cycle on the medium would otherwise hang a path walk rather than
merely answering wrongly. '.' and '..' are refused as components, since an
entry stored under either could never be reached again.
The commands that act on the volume rather than on one file --
XIPFSIOC_DEFRAG and XIPFSIOC_LISTPINNED -- are reached through the ioctldir
method, on a descriptor for the mountpoint directory. They are accepted on
a descriptor for a file inside the volume too, but that route holds the file
open for the duration and an open extent cannot be relocated, so a pass
asked for that way is obstructed by the act of asking.
mmap() falls back to the generic RAM copy for ordinary readers when the
media cannot be addressed directly. A module loader must not silently get
a RAM copy, so MAP_XIP_STRICT is added: with it the mapping either resolves
in place or fails with -ENXIO, which the caller can turn into defragment
and retry.
Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-25 13:07:16 +02:00
|
|
|
include xipfs/Make.defs
|
2024-06-08 13:02:28 +08:00
|
|
|
include v9fs/Make.defs
|
2007-11-20 20:32:33 +00:00
|
|
|
endif
|
2007-06-09 19:11:00 +00:00
|
|
|
|
2022-11-01 21:47:53 +08:00
|
|
|
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)fs
|
|
|
|
|
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)sched
|
2020-05-19 17:43:29 +08:00
|
|
|
|
|
|
|
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
2014-02-19 10:01:26 -06:00
|
|
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-02-19 10:01:26 -06:00
|
|
|
SRCS = $(ASRCS) $(CSRCS)
|
|
|
|
|
OBJS = $(AOBJS) $(COBJS)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-02-19 10:01:26 -06:00
|
|
|
BIN = libfs$(LIBEXT)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-02-19 10:01:26 -06:00
|
|
|
all: $(BIN)
|
2016-05-10 15:44:06 -06:00
|
|
|
.PHONY: depend clean distclean
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2007-02-27 23:59:20 +00:00
|
|
|
$(AOBJS): %$(OBJEXT): %.S
|
2008-01-08 17:06:21 +00:00
|
|
|
$(call ASSEMBLE, $<, $@)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2007-02-28 13:42:19 +00:00
|
|
|
$(COBJS): %$(OBJEXT): %.c
|
2008-01-08 17:06:21 +00:00
|
|
|
$(call COMPILE, $<, $@)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2023-01-28 10:17:18 +08:00
|
|
|
$(BIN): $(OBJS)
|
2026-07-28 05:52:38 -03:00
|
|
|
$(call ARCHIVE_REBUILD, $@, $(OBJS))
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2020-04-21 15:22:31 +08:00
|
|
|
context::
|
2020-11-28 11:43:30 +08:00
|
|
|
|
2024-09-15 13:41:42 +09:00
|
|
|
makedepfile: $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds)
|
|
|
|
|
$(call CATFILE, Make.dep, $^)
|
|
|
|
|
$(call DELFILE, $^)
|
|
|
|
|
|
2020-07-22 16:54:29 +09:00
|
|
|
.depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config
|
2024-09-15 13:41:42 +09:00
|
|
|
$(Q) $(MAKE) makedepfile
|
2020-03-23 11:44:03 +09:00
|
|
|
$(Q) touch $@
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2020-03-23 11:44:03 +09:00
|
|
|
depend: .depend
|
2007-02-17 23:21:28 +00:00
|
|
|
|
|
|
|
|
clean:
|
2012-11-20 15:47:41 +00:00
|
|
|
$(call DELFILE, $(BIN))
|
2008-01-10 18:23:08 +00:00
|
|
|
$(call CLEAN)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2020-04-21 15:22:31 +08:00
|
|
|
distclean:: clean
|
2026-02-16 17:12:20 +09:00
|
|
|
$(call DELFILE, $(CSRCS:.c=.ddc) $(ASRCS:.S=.dds))
|
2012-11-20 15:47:41 +00:00
|
|
|
$(call DELFILE, Make.dep)
|
2020-03-23 11:44:03 +09:00
|
|
|
$(call DELFILE, .depend)
|
2007-02-17 23:21:28 +00:00
|
|
|
|
|
|
|
|
-include Make.dep
|