Commit Graph

2058 Commits

Author SHA1 Message Date
Xiang Xiao 2ab9a848a0 fs/romfs: Move rn_child/rn_count before rn_namesize
which could save 4 bytes for each node

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-01-20 09:27:50 -03:00
wangyongrong 7508a10e20 rptun: Strip rpmsg and rptun
nuttx/driver/rpmsg: new folder, extract common rpmsg api in rptun.c to rpmsg.c.
rpmsg provide rpmsg_ops to each backend for specific implementation.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-01-16 15:58:32 +01:00
Takeyoshi Kikuchi f01e395b1c fs: partition: fs_mbr: fix for MBR block count calculation.
When the MBR partition size exceeds 2 GiB, a 32-bit wrap-around occurs,
causing an error in the block count calculation.

* wrong
 brw-rw-rw- 5150605312 mmcblk0
 brw-rw-rw-  629145600 mmcblk0p1
 brw-rw-rw-  225443840 mmcblk0p2 <--

* fixed
 brw-rw-rw- 5150605312 mmcblk0
 brw-rw-rw-  629145600 mmcblk0p1
 brw-rw-rw- 4520411136 mmcblk0p2 <--

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
2024-01-14 01:29:24 -08:00
wangyongrong 540e7f475f rpmsgfs: synchronous message transfer format
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-01-09 05:49:03 -08:00
yinshengkai 9852428953 fs: procfs add poll support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 19:23:13 -08:00
Takumi Ando dde0872b63 fs: smartfs: Add necessary aligned access in smartfs_rename()
smartfs_rename() was stuck on the boards they need
CONFIG_SMARTFS_ALIGNED_ACCESS.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
2023-12-25 23:41:25 -08:00
Jukka Laitinen 26b7de0f34 fs/fat: Fix number of data clusters usable for fat driver
Fix the issue where fat driver is not using the last two clusters in
the file system.

The fat parameter fs->fs_nclusters is the maximum number of data clusters;
this doesn't include the two in the beginning. Many checks in the fat driver
treat the fs->fs_nclusters-1 as being the last accessible cluster, which is not
right, the last accessible one is actually this number + 2 when the cluster
count includes the two first ones.

Normally this is not an issue when writes are being done through the same
driver, the last two clusters are just never used. But if the filesystem is
modified by external driver, for example with a populated fat created with PC,
or modifying the FS via USB-MSC, this leads to the fat driver not being able to
read anything that uses the last two clusters.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-12-22 11:09:12 +01:00
anjiahao d932e0af2a sched/procfs:use instrument to statistics run time max stack
Usage:
1. CONFIG_FS_PROCFS_MAX_STACK_RECORD > 0, such as 32,
2. add '-finstrument-functions' to CFLAGS for What you want to check
   stack.
3. mount porcfs
4. cat /proc/<pid>/stack will print backtace & size

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
Xiang Xiao 19baa56fb5 procfs/cpuinfo: Zero copylen in cpuinfo_read
to avoid return the negative number

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-11 10:36:03 +01:00
anjiahao a4ad9b7579 fs_gettype:add zipfs magic
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-08 21:45:45 -03:00
Zhe Weng bffe858e47 fs/proc: Fix groupfd to get fd by group instead of current tcb
/proc/<pid>/group/fd should read the fds of <pid>, not current tcb.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-04 21:37:28 -08:00
Xiang Xiao 6783051aed Fix the wrong comment banner
"Private Type"->"Private Types"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-03 17:50:35 +01:00
chao an 7b1f22ca18 xmc4/spi: fix typo
Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-30 06:16:09 -08:00
Ville Juven 5f36a43609 sched/semaphore: Move named semaphores to user space 2023-11-27 04:52:54 -08:00
liaoao 27f672d55a rpmsgblk: bind block inode to ept when create ept
A segmentfault might happen when read/write/unlink ops called without an open
ops called because it bind ept's ops in rpmsgblk_open_handler.

proxy> rm /dev/ram1
segmentfault

proxy> ls /dev/ram1
segmentfault

Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-11-22 08:08:12 -08:00
chao an 59cf308eff sched/taskspawn: fix spawn fail if enable FDCHECK
protect file descriptor before compare

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-22 16:05:36 +01:00
chao an 6bbb7c0046 fs/spiffs: correct mutex lock cycle of spiffs
This PR will fix the below issues:
1. double lock() on dup
2. use after free on unbind

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-22 01:57:44 -08:00
hujun5 b2e6d7b9d7 fs/tmpfs: fix an integer overflow
newsize = newsize + CONFIG_FS_TMPFS_FILE_ALLOCGUARD;

When newsize is a large value,
adding a relatively small value can cause the result to become very small,
resulting in program logic errors.
For example:
0xffffffff + 0x2 = 1

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-11-21 20:02:00 -08:00
Xiang Xiao eddd90de78 poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
chao an 42427e9e29 sched/taskfiles: skip unnecessary file open/close operations to improve performance
The task files should consult the "spawn action" and "O_CLOEXEC flags"
to determine further whether the file should be duplicated.

This PR will further optimize file list duplicating to avoid the performance
regression caused by additional file operations.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-16 07:30:36 -08:00
Ville Juven 0dedbcd4ae task/pthread_cancelpt: Move cancel point handling to libc, data to TLS
This moves task / thread cancel point logic from the NuttX kernel into
libc, while the data needed by the cancel point logic is moved to TLS.

The change is an enabler to move user-space APIs to libc as well, for
a coherent user/kernel separation.
2023-11-15 08:52:04 -08:00
chao an 6104f32afc fs/fat: fix ubsan warning of shift-out-of-bounds
ubsan_prologue: ================================================================================
ubsan_prologue: UBSAN: shift-out-of-bounds in fat/fs_fat32util.c:989:40
__ubsan_handle_shift_out_of_bounds: left shift of 268435455 by 4 places cannot be represented in type 'int'
ubsan_epilogue: ================================================================================

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-15 07:14:41 -08:00
chao an d63034994e fs/inode: check file list before memcpy
The file list is NULL if task group initialized, check the validity
of the file list before memcpy.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-14 19:11:32 -03:00
chao an 3b2c585ab7 fs/inode: add common function to get file count from list
common function to get file count from file list

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-12 17:01:13 -08:00
chao an 0a567bbae4 fs/inode: improve the performance of get file pointer
Remove file locks and enter critical sections to protect file lists

Signed-off-by: chao an <anchao@xiaomi.com>
2023-11-12 17:01:13 -08:00
yinshengkai bb5b5420ae mm: record the maximum system memory usage
Add the usmblks field to mallinfo to record the maximum space allocated historically in the system

https://man7.org/linux/man-pages/man3/mallinfo.3.html#:~:text=mmap(2).-,usmblks,-This%20field%20is

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-11-09 09:08:49 +08:00
zhanghongyu 3610b25c91 cmake: add include path for special source
fix the cmake build error.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-07 17:39:03 +01:00
raiden00pl 607792d452 fs_files.c: make sure that fs_getfilep is not interrupted when holding mutex
this fixes the issue https://github.com/apache/nuttx/issues/6012
2023-11-07 01:07:57 +08:00
Bowen Wang 2f9c082f8f fs_epoll: serveral epoll issues fix
1. fs_epoll: try again when epoll_teardown() return 0
when poll_notify() called larger than twice when epoll_wait() blocked
in the eph->sem, the semcount will be larger than 1 when epoll_wait()
unblocked and will return 0 directly at the next epoll_wait.
So retry to wait the eph->sem again when epoll_teardown return 0.

2. fs_epoll: poll_setup the fd again even this fd got non-expected event
Some poll implementations need call poll_setup again when their internal
states changed (e.g., local socket), so should add the fd to the epoll
teardown list and poll_setup again at the next epoll_wait even this fd
got the user non-expected event.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-11-02 00:44:52 +08:00
yinshengkai d0a5489ac5 sched: explicitly select the cpuload clock source configuration
Different configurations require different dependencies.
Explicitly select dependencies to avoid automatically selecting inappropriate configurations.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-11-01 09:27:56 +08:00
Xiang Xiao 949d01be51 fs/inode: Change inode_unlink to static function
since it's only be called by inode_remove now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-30 10:57:14 +02:00
raiden00pl 5b87fdfb9d Documentation: remove all migrated READMEs 2023-10-29 21:03:54 -03:00
raiden00pl b565e28da3 Kconfigs: rename {Rpmsg|rpmsg} to RPMGS 2023-10-28 13:58:56 +08:00
dongjiuzhu1 18819b6b24 sched/task: close file descriptor with O_CLOEXEC before active task or exec
VELAPLATFO-18473

refs:
https://man7.org/linux/man-pages/man2/fcntl.2.html
If the FD_CLOEXEC bit is set, the file descriptor will automatically
be closed during a successful execve(2).
(If the execve(2) fails, the file descriptor is left open.)

modify:
1. Ensure that the child task copies all fds of the parent task,
   including those with O_CLOEXE.
2. Make sure spawn_file_action is executed under fd with O_CLOEXEC,
   otherwise it will fail.
3. When a new task is activated or exec is called, close all fds
   with O_CLOEXEC flags.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-27 21:15:07 +08:00
dongjiuzhu1 73dc8f84cc fs/dup3: impletement dup3/nx_dup3_from_tcb function
refs: https://man7.org/linux/man-pages/man2/dup.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-27 21:15:07 +08:00
dongjiuzhu1 dc2dac2377 fs/dup/dup2: don't add O_CLOEXEC for new file descriptor
refs: https://man7.org/linux/man-pages/man2/dup.2.html

The two file descriptors do not share file descriptor flags (the
close-on-exec flag).  The close-on-exec flag (FD_CLOEXEC; see
fcntl(2)) for the duplicate descriptor is off.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-27 21:15:07 +08:00
dongjiuzhu1 dcc006035d fs/rename: fix use after free issue about rename
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:04:23 +08:00
chao an 3cadf6642a kernel: replace all usleep to nxsig_usleep in kernel space
syscall cannot be called from kernel space

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-25 15:46:03 +08:00
Xiang Xiao d84aba8a42 fs: Change inode_checkflags to static function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-22 21:23:08 +03:00
Xiang Xiao b1c8c84e81 stdio: Merge fs_fdopen into fdopen to simplify the code logi
since fs_fdopen could avoid call the kernel specific function now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
Xiang Xiao 62c2b1abba stdio: Initialize stdin, stdout and stderr directly
and then remove group_setupstreams

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
ThomasNS 696717b28b add munmap logic to pseudofs 2023-10-13 03:17:27 +08:00
yinshengkai ddb87d3b86 clock: replace all up_perf_xx with perf_xx
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-02 16:11:43 +02:00
anjiahao a2c5cb729a fs:support zipfs,can mount zipfile
we can mount a zipfile in nuttx use mount command like this:

mount -t zipfs -o /data/test.zip /zip

The zipfs is a read only file system,The advantage is that it
does not occupy additional space when reading the decompressed file.

When used, reading and decompression operations are simultaneous.
The known disadvantage is that when using seek to read forward,
it will reopen and cause slow speed problems.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-09-27 01:06:04 +08:00
guohao15 2bce0f404c fs:add syncfs api for sync whole fs data
Signed-off-by: guohao15 <guohao15@xiaomi.com>
2023-09-23 15:58:00 +08:00
wanggang26 40a2adf720 procfs: fix a typo
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-21 15:02:27 +03:00
zhengshaobo1 be767dde01 vela fs procfs add clock procfs entry
procfs enrty add clock feature procfs operations

Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-19 10:34:48 +08:00
chao an 5026a96cfa nxstyle: cleanup UTF-8 Unicode to ASCII
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-18 11:54:17 -04:00
Petro Karashchenko e77ec6c8c6 fs/mqueue: add missing FAR specifier
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Petro Karashchenko 0e42808923 fs/vfs: remove redundant return in nx_vopen
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00