Commit Graph

2031 Commits

Author SHA1 Message Date
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
xuxin19
e5ee8f7470 Fix error: procfs/fs_procfscritmon.c:184:10: error: variable 'remaining' set but not used [-Werror,-Wunused-but-set-variable]
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-11 20:34:46 +08:00
dongjiuzhu1
6367f2469c fs/vfs: fix dup issue for eventfd/signalfd/timerfd
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-11 19:57:34 +08:00
xuxin19
b1cc5b50b1 cmake:complete missing changes during cmake reforming for fs
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-08 21:20:16 +03:00
dongjiuzhu1
e43194f5ea Revert "rpmsgfs: cache statfs result in case of deadlock"
This reverts commit 572d865034.
2023-09-08 00:58:48 +03:00
chao an
664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
chao an
b60f01a55b inode/i_private: remove all unnecessary cast for i_private
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 08:58:07 +02:00
chao an
7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
wanggang26
3dbface167 Revert commit 35602cc2ef
Reason for revert: when block device enable bch proxy, fsync calling would be failed

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-08-25 20:37:38 +03:00
Ville Juven
a37d094f31 fs/shmfs: Fix illegal usage of void* arithmetics
Fixes build error with -Werror:

shm/shmfs.c: In function 'shmfs_read':
shm/shmfs.c:122:33: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
  122 |       memcpy(buffer, sho->paddr + startpos, nread);
      |                                 ^
shm/shmfs.c: In function 'shmfs_write':
shm/shmfs.c:166:25: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
  166 |       memcpy(sho->paddr + startpos, buffer, nwritten);
      |                         ^
cc1: all warnings being treated as errors
2023-08-22 23:33:20 +08:00
yinshengkai
8fa4f2d61d add the startup process tracepoint
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-19 21:50:08 +08:00
chenrun1
709301cbfd hostfs:support SEEK_CUR
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-19 01:48:48 +08:00
wanggang26
d8f316b998 fs/ioctl: add BIOC_BLKGETSIZE cmd to get block sector numbers
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-08-19 01:43:59 +08:00
chenrun1
35602cc2ef fs_fsync.c:Fix unknown command message in non-block device situations
This command is called only if the device is a block device or mtd
device.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-18 14:47:27 +08:00
fangxinyong
903e87a7bd builtin: support uid/gid config for binfs app
Implement I_SUID/I_SGID feature for binfs in the POSIX compliant way.
If set-user-ID bit is set in the file permissions, then the effective
user ID of process shall be set to UID of the new process image file.

test case:
hello example emulates to set uid and file set-user-ID bit, and call
geteuid and getegid API.
UID  = 2000
GID  = 3000
MODE = 06555

nsh> ls -l /bin/hello
 -r-sr-sr-x    2000    3000       0 hello
nsh> hello
geteuid:2000
getegid:3000

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-14 01:37:00 +08:00
Petro Karashchenko
4bebf64d6b fs/inode: add missing FAR
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Petro Karashchenko
1b0baa8337 nuttx: use lib_free for memory de-allocation after strdup or asprintf
The memory allocated with strdup and asprintf is done via lib_malloc
so we need to use lib_free to deallocate memory otherwise the assertion
"Free memory from the wrong heap" is hit with flat mode and user separated
heap enabled mode.

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Petro Karashchenko
b3d620152e Revert "Don't call lib_free in the kernel code"
This reverts commit 7884c18620.
2023-08-08 11:58:29 -03:00
xucheng5
f1287a9996 fs_open: add ioctl checkflag
fixed open error when driver not implement write

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2023-08-07 01:09:52 -07:00
Xiang Xiao
7884c18620 Don't call lib_free in the kernel code
since kernel just allocate memory from kmm_malloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-06 06:51:24 -03:00
Brennan Ashton
46b0f6d6ee fdt: Add initial FDT support and procfs for userspace export
VELAPLATFO-12536

This provides the initial hooks for Flattened Device Tree support
with QEMU RV. It also provides a new procfs file that exposes the
fdt to userspace much like the /sys/firmware/fdt endpoint in Linux.
See https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw

Nodes in the fdt are not yet usable by the OS.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-08-05 12:41:06 -07:00
yinshengkai
a6fcb0a5a9 fs: add pipe type support to inode
Both the device and the pipe used the FSNODEFLAG_TYPE_DRIVER type before,
and now add an independent pipe type

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-05 06:32:50 -07:00
cuiziwei
a0206adcfa nuttx/fs:remove (flags & MAP_PRIVATE) == 0.
NuttX not support MAP_PRIVATE currently.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-04 04:20:06 -07:00
ligd
ea03d06ab3 tmpfs: fix tmpfs_read overwrite after seek over tfo_size
reproduce:
fs = open("tmpfs", xx);
lseek(fd, 256, SEEK_END);  // filep->f_pos = size + 256
read(fd, buf, len);        // overwrite

resolve:
directly return 0 when seek over tfo_size

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 10:40:28 -07:00
chenrun1
eb0a43f4cf fs_procfsproc:Fix the wrong position of information display, integrate the fd information of socket and file
By left-aligned display, the effect is as follows (0, 1, 2 is fd information, 3 is sd information)

    FD  OFLAGS  TYPE POS       PATH
    0   3       1    0         /dev/console
    1   3       1    0         /dev/console
    2   3       1    0         /dev/console
    3   65      2

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-03 10:33:53 -07:00
chenrun1
9381e929dd procfsproc:Optimize fd information output format
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-03 10:33:53 -07:00
yinshengkai
e3c637baf4 fs: procfs add show file typee
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-03 10:33:53 -07:00
yangjiao
a543950951 fs/mqueue/mq_open.c: Add the judgment for mq_attr is NULL.
Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00