Commit Graph

45 Commits

Author SHA1 Message Date
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
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
chao an 49dec5b48c cmake/build: fix build break on cmake
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-25 15:00:10 +02:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Xiang Xiao 987b01221c fs/rpmsgfs: Zero dirs after realloc to avoid stale data
since many places assume the null pointer as an unused entry

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-28 10:29:21 -03:00
wangbowen6 940bbfc720 rpmsg: support the fdsan feature for rpmsg dev/mtd/blk
Directly return -ENOTTY in rpmsgxxx_ioctl() when the command is
not supported to avoid fdsan command FIOC_SETTAG and FIOC_GETTAG
pass to the rpmsg dev/mtd/blk server with CONFIG_FDSAN enabled.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-06-17 19:34:39 +08:00
zhanghongyu b723e90356 fs: move memset to upper lever for statfs
if struct statfs add new members, such as f_fsid, no additional code
changes are required.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-06-16 11:10:25 +08:00
Xiang Xiao 1955992ae5 fs: Replace strncat with strlcat
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
Xiang Xiao fa8719bb5a Replace all strcat with strlcat
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
Xiang Xiao dd631265c4 fs: Add g_ prefix for all global mountpt_operations instances
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-04-24 16:13:29 +02:00
lilei19 38f64f559d change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
Jiuzhu Dong 9340d6e0d7 fs/rpmsgfs: return ENOTTY to vfs to do cmd operate
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2023-02-23 21:42:45 +02:00
chao an 3a0fdb019d nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08: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
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
anjiahao 5724c6b2e4 sem:remove sem default protocl
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
wangbowen6 301cd53f14 rpmsgfs/Make.defs: rpmsgfs_server.c given more than once
Makefile:81: target 'rpmsgfs_server.o' given more than once in the same rule

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-09-01 11:41:23 +08:00
Jiuzhu Dong a7e7487053 fs/rpmsgfs: fix double free
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-17 01:57:26 +08:00
wangbowen6 0b95148e5a rpmsgfs: fix ioctl operation can not work bug
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-08-17 01:57:15 +08:00
Xiang Xiao 5f93ae9dd2 fs/rpmsg: Move the server initialization to fs_initialize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-11 02:08:42 +03:00
Jiuzhu Dong fe17f747a7 fs/directory: move private directory information to filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Jiuzhu Dong 90db4daca9 fs/directory: update readdir interface for all filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Xiang Xiao 2b0e28e492 vfs: Remove the unnessary check when CONFIG_DEBUG_MM enable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-28 16:52:06 +03:00
ligd 8a3683fb9f rptun: add ns_match callback to resolve rptun deadlock
thread A: accept -> net_lock -> socket_rpmsg_accept
          -> rpmsg_register_callabck -> rptun_lock
thread B: ns_bind -> rpmsg_socket_ns_bind -> get_tx_payload_buffer
          -> rptun_wait_tx -> usrsock_rpmsg_ept_cb -> usrsockdev_write
          -> net_lock -> deadlock

fix:
add ns_match callback

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
ligd 1e5568b030 rpmsgfs: fix nx_style
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 17:10:19 +03:00
ligd 572d865034 rpmsgfs: cache statfs result in case of deadlock
rptun: msg from other cpu
[ap] [ 5] [<0x2c353768>] arm_switchcontext+0xc/0x10
[ap] [ 5] [<0x2c322266>] sem_wait+0x5a/0xbc
[ap] [ 5] [<0x2c7400a8>] inode_semtake+0x24/0x5c
[ap] [ 5] [<0x2c74087a>] inode_release+0x6/0x60
[ap] [ 5] [<0x2c741284>] file_close+0x18/0x44
[ap] [ 5] [<0x2c74fb06>] rpmsgfs_close_handler+0x86/0xe4
[ap] [ 5] [<0x2c75b8de>] rpmsg_virtio_rx_callback+0xba/0x1b4
[ap] [ 5] [<0x2c75af70>] rproc_virtio_notified+0x44/0x5c
[ap] [ 5] [<0x2c75a93c>] remoteproc_get_notification+0x1c/0x2c
[ap] [ 5] [<0x2c335a08>] rptun_thread+0x74/0x208
[ap] [ 5] [<0x2c323e72>] nxtask_start+0x3a/0x60

nsh: send msg to other cpu with inode lock
[ap] [10] [<0x2c353768>] arm_switchcontext+0xc/0x10
[ap] [10] [<0x2c3221b2>] nxsem_wait_uninterruptible+0x6e/0xc8
[ap] [10] [<0x2c74e498>] rpmsgfs_send_recv.constprop.0+0x78/0xc0
[ap] [10] [<0x2c74ebc0>] rpmsgfs_client_statfs+0x50/0x80
[ap] [10] [<0x2c3221ca>] nxsem_wait_uninterruptible+0x86/0xc8
[ap] [10] [<0x2c74da78>] rpmsgfs_statfs+0x28/0x50
[ap] [10] [<0x2c74534e>] mountpoint_filter+0x66/0x90
[ap] [10] [<0x2c740016>] foreach_inodelevel+0x66/0x88
[ap] [10] [<0x2c73fffa>] foreach_inodelevel+0x4a/0x88
[ap] [10] [<0x2c740062>] foreach_inode+0x2a/0x48
[ap] [10] [<0x2c745388>] foreach_mountpoint+0x10/0x20
[ap] [10] [<0x2c745606>] mount_read+0x36/0x70
[ap] [10] [<0x2c742a34>] read+0x30/0x5c
[ap] [10] [<0x2c371096>] nsh_catfile+0x36/0x140
[ap] [10] [<0x2c36d01a>] nsh_parse_command+0x7fe/0xc54
[ap] [10] [<0x2c370f92>] nsh_session+0x66/0x134
[ap] [10] [<0x2c3721a4>] nsh_consolemain+0x2c/0x44
[ap] [10] [<0x2c374fde>] nsh_main+0x2a/0x4c
[ap] [10] [<0x2c33f7f8>] lib_cxx_initialize+0x24/0x48
[ap] [10] [<0x2c34274a>] nxtask_startup+0x12/0x24
[ap] [10] [<0x2c323e7e>] nxtask_start+0x46/0x60

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 17:10:19 +03:00
ligd 5f60b7dc12 rpmsgfs: hande count <=0 when rpmsgfs_read&write
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 17:10:19 +03:00
ligd 837c15dcb6 rpmsgfs: improve file read & write performance
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 17:10:19 +03:00
Xiang Xiao 9785d6606c openamp: Change the dependence from OPENAMP to RPTUN
since all rpmsg driver need the extension api exposed by rptun driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-05 10:05:41 +03:00
Petro Karashchenko d08fbca679 nuttx: unify FAR attribute usage across the code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-04 21:32:58 +08:00
Jiuzhu Dong 0a111b7c96 fs/rpmsgfs: fix bug about using uninit variable "times"
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 21:02:08 +08:00
ligd 6f210655fa rpmsgfs: do NOT access the pointer when do remote ioctl
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-04-01 17:39:38 +08:00
ligd 40d9e10f37 rpmsgfs: use rptun_wait/post to resolve deadlock with usrsock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-04-01 08:33:57 +03:00
ligd 96ed33f1d8 rpmsgfs: add timeout when mount in rpmsgfs
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-04-01 08:33:57 +03:00
ligd 023c54d0a4 rpmsgfs: add wait ready to rpmsgfs
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-04-01 08:33:57 +03:00
Jiuzhu Dong 42664f4505 rpmsgfs/rename: fix bug about pathname align with 8bytes
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-27 05:16:13 +03:00
Xiang Xiao 4d8c92603b Fix rpmsgfs/rpmsgfs_client.c:774:3: warning: 'strcpy' writing 1 or more bytes into a region of size 0 overflows the destination
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-23 10:52:46 +02:00
chao.an 8308f32863 fs/rpmsgfs: minor refine the return value
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 10:28:41 +02:00
Petro Karashchenko 8d3bf05fd2 include: fix double include pre-processor guards
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-16 11:11:14 -03:00
zhouliang3 1f53a058fa nuttx:Change fs strncpy to strlcpy to avoid losing'\0'
Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2021-12-30 18:06:00 +08:00
ligd 5b369c5cec libs/lbc: remove CHAR_BIT = 16 support
For CEVA platform CHAR_BIT is 16, and will do lots of extra work
when use IPC.
We will not support this platform anymore, so remove all the b2c operations.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 11:08:28 -06:00
ligd 985cc4fc6d hosfs_rpmsg: merge hostfs_rpmsg to rpmsgfs
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-04 01:04:18 -06:00