Commit Graph

1854 Commits

Author SHA1 Message Date
zhangyuan21
8c52633bd0 fs: unlock tmpfs before free the file object
tcb will hold an invalid semaphore when CONFIG_PRIORITY_INHERITANCE is enabled

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-01-28 19:35:45 +08:00
Petro Karashchenko
2c972bd402 fs/shm: update pointer arithmetic logic
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-01-26 10:26:09 +08:00
Petro Karashchenko
d35d8b4a12 fs/shm: use ERROR instead of -1
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-01-26 10:26:09 +08:00
Alan Carvalho de Assis
c3a34a5956 fs: Avoid accessing filep fields if it is NULL & add DEBUGASSERTs 2023-01-20 22:31:00 +08:00
Xiang Xiao
f8d33e40ac Fix mmap/fs_mmap.c:259:13: warning: 'mapped' may be used uninitialized in this function [-Wmaybe-uninitialized]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-18 08:40:33 +01:00
Jukka Laitinen
a0ebddaac1 fs/shm: Add initial implementation for posix shared memory
This implements the file system logic for posix shared memory:
shm_open, shm_unlink, mmap, munmap and close

For flat and protected builds the memory simply allocated from (user) heap

For kernel build the memory is allocated from page pool and mapped with MMU

This doesn't yet support protection flags or re-sizing already truncated shared
memory area.

Co-authored-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-18 11:01:20 +08:00
chao an
3d7629a02c fs/mmap: fix compile warning if set the optimize level to O3
| $ gcc -c "-O3" -Wall -isystem include -D__NuttX__ -D__KERNEL__ -I fs -I sched fs/mmap/fs_mmap.c -o fs_mmap.o
| include/sys/mman.h: In function ‘mmap’:
| fs/mmap/fs_mmap.c:259:13: warning: ‘mapped’ may be used uninitialized in this function [-Wmaybe-uninitialized]
|   259 |   FAR void *mapped;
|       |             ^~~~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-17 21:56:37 +08:00
Xiang Xiao
0a95c7721b vfs/poll: Remove POLLFILE and POLLSOCK NuttX specific extension
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-17 14:02:59 +08:00
Xiang Xiao
b1899ffbfd fs: Support O_NOFOLLOW flag
https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/functions/open.html:
O_NOFOLLOW
If path names a symbolic link, fail and set errno to [ELOOP].

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-17 12:02:48 +08:00
Xuxingliang
9166eeddf6 fs/mmap: update mapped var before exit
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-01-17 11:12:26 +08:00
Xuxingliang
dce315005a fs/mmap: rammap should return buffer start address
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-01-17 11:12:26 +08:00
crafcat7
047f7f8d3a vfs/fs_truncate.c:Add socket judgment to return correct errno. 2023-01-17 10:29:41 +08:00
Jukka Laitinen
6db295481b fs/mmap/fs_rammap.c: Remove void * arithmetic
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-13 23:08:58 +08:00
Jukka Laitinen
3577d2f055 fs/mmap/fs_anonmap.c: Remove void * arithmetic
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-13 23:08:58 +08:00
Petro Karashchenko
6c5cb98e7d fs/mount: fix logging macro in FS automount
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-01-13 12:18:36 +08:00
Xiang Xiao
fd0195b0d8 fs/mmap: Suppor the partial unmap for anonymous mapping
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Xiang Xiao
fcd4a421e3 fs/mmap: Support the no backing file for anonymous mapping
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Xiang Xiao
ab67d6a75b fs/mmap: Remove the duplication rammap handling
and minor ifx for style and format

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Ville Juven
416e83d57e fs/poll: add missing FAR qualifier to poll()
Follow-up to #8072
2023-01-11 21:12:17 +08:00
Ville Juven
f730cf8ad8 fs/poll: Fix poll_notify for CONFIG_BUILD_KERNEL
With flat addressing the user pollfd list is given directly to the
drivers that perform the notification. This is fine when the addressing
is flat, as there is no ambiguity on who gets notified and the fds memory
is always mapped.

For kernel mode with MMU this does not work. The notification must be done
via a temporary buffer allocated from kernel memory.

Thus, create a copy of the user fds and pass the copy to the drivers.
Afterwards copy the output events back to the user.
2023-01-11 01:53:13 +08:00
Jukka Laitinen
b8f23fc3f7 Move rammaps to use mm_map list
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
Jukka Laitinen
a5ed8014e8 Move anonymous mapping emulation into own module under fs/mmap
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
Jukka Laitinen
dd97900221 fs/mmap: Add mappings to mm_map list if CONFIG_MM_MAP is defined
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
wangbowen6
a491d07061 sem_unlink: return ENOENT when the named semaphore does not exist.
Follow posix, return ENOENT when the named semaphore does not
exist to fix the ltp open posix sem_unlink 4-1.c test problem.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-01-09 22:46:30 +08:00
Xiang Xiao
9aa835815f fs/timerfd: Reverse truncate and mmap field
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-07 14:27:42 +02:00
qinwei1
c137aeec32 fs/vfs: add missed truncate/mmap callback at timerfd file_operation
Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2023-01-06 13:31:38 +08:00
Xiang Xiao
1a59f4ed00 mm/map: Remove the unnessary map.h inclusion in various drivers
and Fix include/nuttx/mm/map.h:55:28: error: 'struct task_group_s' declared inside parameter list will not be visible outside of this definition or declaration

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-05 16:06:53 +02:00
Xiang Xiao
7179d57026 fs: Check offset and length more carefully in mmap callback
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 17:43:59 +02:00
Xiang Xiao
b0a0ba3ad7 fs: Move mmap callback before truncate in [file|mountpt]_operations
since mmap may exist in block_operations, but truncate may not,
moving mmap beforee truncate could make three struct more compatible

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 17:43:59 +02:00
Xiang Xiao
779a610ca3 Remove the unnecessary NULL fields in global instance definition of file_operations
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 00:32:13 +02:00
Jukka Laitinen
f33dc4df3f Change FIOC_MMAP into file operation call
- Add mmap into file_operations and remove it from ioctl definitions.
- Add mm_map structure definitions to support future unmapping
- Modify all drivers to initialize the operations struct accordingly

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-02 11:23:20 -03:00
Jukka Laitinen
41e9df2f3e Add ftruncate into file operation calls
- Add truncate into file_operations
- Move truncate to be common for mountpt_operations and file_operations
- Modify all drivers to initialize the operations struct accordingly

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-02 11:23:20 -03:00
Jukka Laitinen
36528eed64 Revert "fs/vfs/fs_truncate.c: Use ioctl to truncate on non-mountpoint inode"
This reverts commit dbc163f1b0.
2023-01-02 11:23:20 -03:00
dongjiuzhu1
f85d9a9332 fs/signalfd: using file descriptor to accept signal
Reference here:
https://man7.org/linux/man-pages/man2/signalfd.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-28 23:05:58 +08:00
dongjiuzhu1
d36b7fea45 timerfd: remove timeout work and do notify in isr
1.Optimize notification speed
2.using enter/leave critical to replace spin_lock to avoid race condition

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-28 22:45:25 +08:00
dongjiuzhu1
c7eca3d176 timerfd/eventfd: using file_allocate to replace register_driver
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-28 22:45:25 +08:00
Xiang Xiao
72e76600c3 fs/procfs: Avoid the cast in uptime_read
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-24 11:26:48 -03:00
Ville Juven
2ed51d026c fs/streams: Move the file streams from the group structure into TLS
This is preparation for flushing streams from user space, like it should
be done.

- Move tg_streamlist (group, kernel space) ->
       ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
2022-12-22 20:16:11 +08:00
Xiang Xiao
fd0d6a9bf5 compiler.h: Add _ between format|printf|syslog|scanf|strftime and like
align with other macro naming style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-21 01:05:19 +02:00
anjiahao
70791af8e2 procmeminfo:support memdump can show specific task
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-12-19 20:43:33 +08:00
zhangyuan21
3462061624 task: show thread main entry when display thread name
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2022-12-17 14:53:59 +08:00
qinwei1
a4f06660d2 fs_epoll: fix some potential issue for list operation
VELAPLATFO-4690

Summary
1. delete item before free it

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
Change-Id: Ie101a0cdba97caa8c3bbf0830dc0a35750688a41
2022-12-13 21:00:11 +02:00
chao an
b5507ea9a2 compile/attribute: minor fix for packed struct mismatch
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-06 03:50:20 +08:00
crafcat7
8b95b7ca5b littlefs: Get and return the current error status before RMDIR execution type
In some cases, deleting a folder will return unexpected results. For example, ENOENT should be returned when deleting a non-existent folder, but the result will return ENOTDIR.
2022-12-03 02:44:49 +08:00
YAMAMOTO Takashi
8ee2ed0b91 littlefs: add a few Kconfig options 2022-12-01 23:34:31 +08:00
dongjiuzhu1
b1b2a7cc0b timerfd_create: initial reference count to zero
nx_open in timerfd_create will increase reference count,
Therefore, the reference count starts with a value of 0.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-12-01 15:07:09 +08:00
Gao Feng
08f5a5a3be meminfo: buflen identify the left of buffer
It is enought to only checking the buflen's avaiable or not.
(total size means total copied size)

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-11-29 01:29:55 +08:00
ligd
11fa70d53a romfs: change lock to recursion lock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 18:04:38 +08:00
wangbowen6
a0ded9d0d4 fs_epoll: [bug fix] epoll node use-after-free in epoll extend list
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-11-26 11:56:58 +08:00
wangbowen6
2f2176151e fs_epoll: [bug fix] EPOLL_CTL_ADD/MOD consider the teardown list too
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-11-25 21:34:09 +08:00