Commit graph

2343 commits

Author SHA1 Message Date
zhangyuan29
dcea1b90e7 arch_atomic: only support atomic_xx and atomic64_xx function
Modify the kernel to use only atomic_xx and atomic64_xx interfaces,
avoiding the use of sizeof or typeof to determine the type of
atomic operations, thereby simplifying the kernel's atomic
interface operations.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-12-04 14:03:14 +01:00
hujun5
16f39fbb56 fs: use small lock to protect filelist
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-30 03:25:17 +08:00
wangmingrong1
4daafd0781 Fix path error
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-28 15:04:59 +08:00
YAMAMOTO Takashi
610c72ccd0 fs/littlefs: add LFS_MULTIVERSION support 2024-11-27 02:56:52 +08:00
YAMAMOTO Takashi
abd769dcb0 fs/littlefs: disable -Wshadow and explain why 2024-11-27 02:56:52 +08:00
YAMAMOTO Takashi
f7e2e23f12 fs/littlefs: stop applying local patches for unknown versions of littlefs
Because they are not expected to apply cleanly.
In that case, disable all features which require the local patches.

Note: lfs_util.patch is actually necessary regardless of
the littlefs version. It should be ok to drop it for the simplest
flat memory model configurations with a single heap though. I plan
to fix it once littlefs 2.9.4 is released.

Tested with esp32s3-devkitc:toywasm + CONFIG_FS_LITTLEFS_VERSION="v2.9.3".
2024-11-27 02:56:52 +08:00
YAMAMOTO Takashi
0157118ead fs/littlefs: don't use lfs_getsetattr.patch unless FS_LITTLEFS_ATTR_UPDATE 2024-11-27 02:56:52 +08:00
wangjianyu3
d83ab55e00 fs/partition/txtable: Fix panic when no txtable was found in last eraseblock
Panic occured if no txtable was found in last eraseblock of MTD device and `CONFIG_TXTABLE_DEFAULT_PARTITION` was disabled

Backtrace

  sched_dumpstack
  /workspace/nuttx/libs/libc/sched/sched_dumpstack.c:71
  dump_assert_info
  /workspace/nuttx/sched/misc/assert.c:718
  xtensa_user_panic
  /workspace/nuttx/arch/xtensa/src/common/xtensa_assert.c:188 (discriminator 1)
  xtensa_user
  ??:?
  _xtensa_user_handler
  /workspace/nuttx/arch/xtensa/src/common/xtensa_user_handler.S:194
  ??
  ??:0
  parse_txtable_partition
  /workspace/nuttx/fs/partition/fs_txtable.c:136
  parse_partition
  /workspace/nuttx/fs/partition/fs_partition.c:165
  parse_mtd_partition
  /workspace/nuttx/fs/partition/fs_partition.c:291

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-26 18:23:06 +08:00
YAMAMOTO Takashi
92b9a30878 fs/littlefs: make CONFIG_FS_LITTLEFS_VERSION include the "v" prefix
To allow other tags/branches like "devel" and even sha256 hash.
2024-11-25 20:15:53 -03:00
chao an
24add5eeaf spelling: fix spelling typo premp -> preemp
Signed-off-by: chao an <anchao@lixiang.com>
2024-11-25 22:05:05 +08:00
YAMAMOTO Takashi
72a8764ea8 fs/littlefs: Add a kconfig to override littlefs version
Hopefully, It's more user-friendly than the current method,
which is just an overridable make variable. It would also help
to make some features (and their associated local patches)
conditional on littlefs version in future.

Also, update CMakeLists.txt to use the same littlefs version as Makefile.
2024-11-22 21:02:54 +08:00
chenrun1
6a19264c97 littlefs_fstat:Ignore When the error is LFS_ERR_NOENT, we assume that the attr attribute is not set.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-19 11:08:07 -03:00
chenrun1
27eaa23219 lfs:Added LITTLEFS_USE_ATTR to control whether to save attributes when
create file

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-19 11:08:07 -03:00
YAMAMOTO Takashi
9a2b6be842 Update a few comments after the recent readv/writev changes
No functional changes are expected.
2024-11-18 19:10:24 +08:00
hujun5
19b4911d7f arch: remove up_current_regs in common code
reason:

When entering an exception or interrupt, there are two sets of registers:
one is the "running regs", which we need to save,
and the other is the "ready to running regs", which we may soon use.
For consistency in logic, we can always store the "running regs" in the regs field of g_running_tasks,
otherwise it may lead to errors in the storage location of the "running regs."

When we need to access the "running regs," we should uniformly retrieve them from the regs field of g_running_tasks.

As the next step, we will rename the set_current_regs/up_current_regs functions
for each architecture to more appropriate names, solely for the purpose of identifying interrupts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-15 18:25:35 +08:00
wangjianyu3
4266580319 fs/procfs: The procfsversion should be under control of FS_PROCFS_EXCLUDE_VERSION
Env

  sim:nsh
  - CONFIG_FS_PROCFS_EXCLUDE_PROCESS=y

Error

  LD:  nuttx
  /usr/bin/ld: nuttx.rel:(.rodata.g_procfs_entries+0xc8): undefined reference to `g_version_operations'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:429: nuttx] Error 1
  make: *** [tools/Unix.mk:551: nuttx] Error 2

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-13 12:31:46 -03:00
chenrun1
8068ba75ec fs_automount:fix ci break
====================================================================================
Configuration/Tool: spresense/example_camera,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2024-11-12 12:24:37
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
mount/fs_automount.c: In function 'automount_initialize':
Error: mount/fs_automount.c:816:7: error: 'return' with no value, in function returning non-void [-Werror=return-type]
  816 |       return;
      |       ^~~~~~
In file included from mount/fs_automount.c:43:
/github/workspace/sources/nuttx/include/nuttx/fs/automount.h:176:11: note: declared here
  176 | FAR void *automount_initialize(FAR const struct automount_lower_s *lower);
      |           ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-13 13:16:51 +08:00
chenrun1
2cf26036a5 Use lib_get_pathbuffer instead of stack variables
Summary:
  Modified the usage logic, mainly introduced lib_get_pathbuffer and lib_put_pathbuffer

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-12 17:21:42 +08:00
chenrun1
0c9203b48e v9fs/CMakeLists.txt:Fix the problem that virtio-9p is not compiled properly in cmake
Summary:
  change CONFIG_DRIVERS_VIRTIO_9P -> CONFIG_V9FS_VIRTIO_9P

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-11-12 16:13:27 +08:00
wangjianyu3
0702dc5361 fs/vfs: Fix initialization of g_pseudofile_ops
Config: sim:nsh

Log

  CC:  driver/fs_registerblockdriver.c vfs/fs_pseudofile.c:99:3: warning: initialization of ‘ssize_t (*)(struct file *, const struct uio *)’ {aka ‘long int (*)(struct file *, const struct uio *)’} from incompatible pointer type ‘int (*)(struct inode *)’ [-Wincompatible-pointer-types]
      99 |   pseudofile_unlink,   /* unlink */
         |   ^~~~~~~~~~~~~~~~~
  vfs/fs_pseudofile.c:99:3: note: (near initialization for ‘g_pseudofile_ops.readv’)

Related: https://github.com/apache/nuttx/pull/13498

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-10 00:53:40 +08:00
wanggang26
929bbf0be8 fs: add merge partitions support
Usage example for merging the factory partition and reserve
partition into the merge partition:
register_merge_blockdriver("/dev/merge", "/dev/factory", "/dev/reserve",
NULL)

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-11-07 14:59:23 +08:00
Alin Jerpelea
6833b8787e fs: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-11-06 01:58:54 +08:00
YAMAMOTO Takashi
8241a10ebc file_readv_compat/file_writev_compat: Fix partial success handling
The problem has been inherited from the original libc readv/writev
implementation. However, now it's exposed in more situations because
this implemenation is used to back read/write as well.

I expect this fixes the regressions observed on the Espressif CI.
https://github.com/apache/nuttx/pull/13498#issuecomment-2448031197

Note that, even with this fix, these "compat" readv/writev
implementations are still inheritedly broken. (E.g. consider that
a data boundary happens to match one of iovec boundaries) However,
this fix is enough for read/write, where iovcnt is always 1.
2024-11-05 16:57:05 +08:00
Saurav Pal
4e53ee4486 fs/mnemofs: Fix open and rmdir return value and seek out of bounds.
- Update open return value to ENOTDIR when ancestor is a file.
- Update rmdir return value to ENOTDIR when path is not a directory.
- Better logs for file and dir operations.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-11-03 16:01:58 +08:00
ouyangxiangzhen
17c51c0667 userspace: Exclude nuttx/arch.h
This patch fixed userspace headers conflict. Architecture-related definition and API should not be exposed to users.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-11-01 16:59:37 +08:00
dongjiuzhu1
47478e543d fs/shm: support shm_open with flags O_TRUNC
testcase:
https://fossies.org/linux/posixtestsuite/conformance/interfaces/shm_open/25-1.c

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-31 18:47:51 -03:00
xuxin19
36b891c1e1 cmake(bugfix):fix fs cmake typo
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-30 22:14:40 +08:00
YAMAMOTO Takashi
761ee81956 move readv/writev to the kernel
currently, nuttx implements readv/writev on the top of read/write.
while it might work for the simplest cases, it's broken by design.
for example, it's impossible to make it work correctly for files
which need to preserve data boundaries without allocating a single
contiguous buffer. (udp socket, some character devices, etc)

this change is a start of the migration to a better design.
that is, implement read/write on the top of readv/writev.

to avoid a single huge change, following things will NOT be done in
this commit:

* fix actual bugs caused by the original readv-based-on-read design.
  (cf. https://github.com/apache/nuttx/pull/12674)

* adapt filesystems/drivers to actually benefit from the new interface.
  (except a few trivial examples)

* eventually retire the old interface.

* retire read/write syscalls. implement them in libc instead.

* pread/pwrite/preadv/pwritev (except the introduction of struct uio,
  which is a preparation to back these variations with the new
  interface.)
2024-10-30 17:07:54 +08:00
zhangshoukui
198dd93713 shmfs: return EINVAL if group null
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-10-29 18:11:33 +08:00
zhangshoukui
646bf48ed2 shmfs: Assign a variable when object is not null
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-10-29 18:11:33 +08:00
Saurav Pal
17bca89f07 fs/mnemofs: Fix mkdir for depth > 3 bug, better logs
- Fix bug which prevents mkdir for depth > 3.
- Better logs for mnemofs

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-10-29 02:23:58 +08:00
Alejandro Aguirre
0095009076 fs/nfs: fix offset in append mode and attributes after create
- When opening a NFS file in append mode, its file pointer was at offset
  0 instead of the end of file.

- When creating a NFS file, the response read pointer wasn't advanced
  after reading the attributes_follows bool, which caused the attributes
  to be off by 4 bytes. For example, the file size read the GID.

Signed-off-by: Alejandro Aguirre <alejandro.aguirre@midokura.com>
2024-10-28 19:40:30 +08:00
Neo Xu
8a70377fc4 fs/shm: align memory size to cache line size
Make sure the share memory takes the full cache line.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-27 10:38:58 +08:00
xuxingliang
9af5fc5d09 fs/shm: alloc aligned memory if CPU has cache
For kernel builds, shared memory is automatically aligned to page size.
For flat and protected builds, we align the memory size to the CPU cache
line size.

Failure to align memory properly could result in partial data read/write
by the CPU and peripherals, potentially causing data corruption during
cache flushes or invalidations.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-27 10:38:58 +08:00
xuxingliang
22bcb88687 fs_heap: add memalign interface
So the share memory can use it to malloc aligned memory.
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-27 10:38:58 +08:00
ligd
662bbeb33e container_of: fix compile failed cause of list.h not support container_of
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-23 20:10:43 +08:00
Saurav Pal
974da12448 fs/mnemofs: Fix extra log unused value error.
Fix the unused value error for when extra logs are OFF.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-10-22 15:42:40 -03:00
yinshengkai
c3f3b338c9 fs: add fs_heap_strndup, replace strndup with fs_heap_strndup
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-23 00:27:12 +08:00
Saurav Pal
b4a6d456c9 fs/mnemofs: Add logs to bind and unbind.
Add logs and extra logs to mnemofs VFS methods for bind and unbind.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-10-22 16:37:25 +08:00
Leo Chung
c8d683ce7a fs/nxffs: Fix syslog formats compile error
If CONFIG_FS_LARGEFILE is enabled, the off_t is 64bit.
So use PRIiOFF instead of PRIi32.

Signed-off-by: Leo Chung <gewalalb@gmail.com>
2024-10-21 19:33:33 +08:00
wangchen
addfe127a9 socketpair.c:Replace kmm with fs heap
due to https://github.com/apache/nuttx/pull/13722/commits, In the socketpair.c,fs_heap interface replaces kmm interface

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-10-16 20:56:39 +08:00
dongjiuzhu1
8e2f8be671 fs/rpmsgfs: return real err value when open failed
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-16 18:12:21 +08:00
hujun5
a567148888 sched: add up_this_task and up_change_task macro stub
reason:
We can utilize percpu storage to hold information about the
current running task. If we intend to implement this feature, we would
need to define two macros that help us manage this percpu information
effectively.

up_this_task: This macro is designed to read the contents of the percpu
              register to retrieve information about the current
              running task.This allows us to quickly access
              task-specific data without having to disable interrupts,
              access global variables and obtain the current cpu index.

up_update_task: This macro is responsible for updating the contents of
                the percpu register.It is typically called during
                initialization or when a context switch occurs to ensure
                that the percpu register reflects the information of the
                newly running task.

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-15 15:25:55 +08:00
dongjiuzhu1
5a38c8bfe3 fs/readlink: fix minor issue
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-14 18:08:14 -03:00
chenrun1
b613863bad fs:replase all asprintf / strdup in fs with fs_heap_xxx
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-15 01:16:48 +08:00
yintao
e435fca0e2 fs_file.c: modify files_countlist comments
Signed-off-by: yintao <yintao@xiaomi.com>
2024-10-13 02:27:02 +08:00
xuxin19
351781d601 cmake:refine nuttx cmake build system fix CMake build missing part
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-13 02:25:06 +08:00
yinshengkai
c23878e442 sched: modify CONFIG_DUMP_ON_EXIT to CONFIG_SCHED_DUMP_ON_EXIT
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-13 02:06:38 +08:00
guohao15
69f3774f30 littlefs:remove the '/' in the end of relpath in mkdir
mkdir /data/log   success
mkdir /data/log/  failed  in littlefs (but fatfs/yaffs/tmpfs success)

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 15:46:02 +08:00
ligd
da5839c6f2 littlefs: fix warnings
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-11 15:46:02 +08:00