Commit Graph

2319 Commits

Author SHA1 Message Date
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
zhouliang3 8f6ea8896f fs/littlefs: revert fstat and use lfs_file_attr function
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2024-10-11 15:46:02 +08:00
Jiuzhu Dong c5779297cf littlefs/stat: return OK when stat success
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2024-10-11 15:46:02 +08:00
zhouliang3 0ab637f57e fs/littlefs: Add attr to dirA
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2024-10-11 15:46:02 +08:00
zhouliang3 f70de1c65f fs/littlefs: Fix the bug of missing file types
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2024-10-11 15:46:02 +08:00
zhouliang3 44992c8821 fs/littlefs: Implement fchstat and chstat of littlefs
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2024-10-11 15:46:02 +08:00
guohao15 38f0056dcd romfs:extend romfs to enable write part4
add sem for write safe

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 322765b442 fs/romfs: Align up the file size to 16 bytes
and set volume size to 96 bytes in romfs_mkfs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 7814c40a99 fs/romfs: Replace strlcpy and strcmp with memcpy and memcmp
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 4d9512f0d4 fs/romfs: Add romfs_devstrcpy and romfs_devmemcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 808beabc83 fs/romfs: Compute rf_endsector correctly when the file end on the sector boundary
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao cca7b7cb37 fs/romfs: romfs_read return the partail read size instead error code
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 96900845a5 fs/romfs: Change the type of num from uint8_t to uint16_t
to support the directory with more than 255 files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 4ebcc130b9 fs/romfs: Remove the reference to OK and ERROR
and fix the minor style issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 23aef2d7b4 romfs:extend romfs to enable write part3
add romfs_mkfs to support autoformat && forceformat

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 7d8d766018 romfs:bugfix use origoffset instead of offset
origoffset represent the offset of current node
offset represent the offset of the file when
the current node is a soft or hard link

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 3e58620ccc romfs:bugfix romfs_statfs
fix for df cmd infomation of romfs

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 c61734a469 romfs:extend romfs to enable write part2
add sparelist api

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 f3840cf141 romfs:extend romfs to enable write part1
change romfs_cachenode to find all headers

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
yinshengkai e4e355d164 fs: Set the poll return value according to the man manual
The man manual describes that poll only has EFAULT, EINTR, EINVAL, and ENOMEM return values.
If a file returns an error, the POLLERR event should be set and OK should be returned
https://man7.org/linux/man-pages/man2/poll.2.html

When using libuv to poll the socket, the socket poll returned an EBUSY error, causing libuv to abort.

The expected logic should be to return OK, allowing libuv to notify the event listener that the POLLERR event occurred.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-11 03:08:05 +08:00
yinshengkai 36ddb46dba fs/poll: remove poll_teardown unused parameter
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-11 03:08:05 +08:00
zhengyu9 bc7114ab16 fs/vfs: result_independent_of_operands
timeout is a type of int
in MSEC2TICK, timeout may be multiplied by USEC_PER_MSEC
and the result may be out of range of int
Besides, this will induce following ERROR while running simulator:
vfs/fs_poll.c:498:38: runtime error: signed integer overflow:
19768268 * 1000 cannot be represented in type 'int'

Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-11 03:08:05 +08:00
Neo Xu d598da80e4 Rename group_argvstr to nxtask_argvstr
Now argument vector is stored to TLS, task_argvstr fits better.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-10 23:13:37 +08:00
dongjiuzhu1 5a29652d2a fs/inode: using read-lock to protect inode_find
inode_find don't need to modify inode tree

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-10 16:42:15 +08:00
yintao 37a30023f5 nuttx/drivers: add ept_release_cb for destroy server resource
use ept_release_cb to destory rpmsg services server dile resource
to avoid the used-after-free issue

Signed-off-by: yintao <yintao@xiaomi.com>
2024-10-10 08:44:29 +08:00