Commit Graph

1683 Commits

Author SHA1 Message Date
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
田昕
463a437733 fs and unistd: increase OPEN_MAX by claiming a Kconfig.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-04-01 12:17:47 +03:00
Jiuzhu Dong
8a80a853b7 fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 12:16:14 +03:00
Jiuzhu Dong
b5fb93aefb fs/procfstcbinfo: minor bug about print address
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 12:14:52 +03:00
Jiuzhu Dong
a91d143944 fs/unionfs: add sanity check for parameter
if relpath is NULL, it will cause system crash:
unionfs_opendir with relpath NULL
    ->	unionfs_tryopendir
	    ->	unionfs_offsetpath
		->  strncmp(prefix, relpath, pfxlen

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 16:35:43 +08:00
Jiuzhu Dong
e4c9a491c8 fs/unionfs: check return value to avoid unused value
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 16:35:43 +08:00
Jiuzhu Dong
4631face24 fs/unionfs: fix bug about use after free about ui
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 16:35:43 +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
ca8ce37433 fs/romfs: fix bug about compare path with same prefix
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-30 09:04:57 +03:00
ligd
b0e0f9db68 opendir: use inode_find() instead when opendir()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-30 03:33:39 +08:00
tianxin7
b53bbb15c5 fs:add _POSIX_OPEN_MAX limit to files_extend
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-03-29 17:51:20 +08:00
Xiang Xiao
37d7298f34 fs/littlefs: Convert the lfs_file_size error code to POSIX's
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-29 10:11:13 +08:00
Jiuzhu Dong
1146ff2f61 littlefs: unify lfs error code to nuttx
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-29 10:11:13 +08:00
Jiuzhu Dong
66d854371b fs/files_allocate: assert when fd overflow
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-29 00:19:13 +08:00
Jiuzhu Dong
b03f2e34b8 lseek: use type:off_t for return value
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-28 22:49:37 +08:00
Petro Karashchenko
98ba65c422 c89: get rid of designated initializers in common code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 13:39:27 +08:00
Petro Karashchenko
989e8ac48f fs/romfs: fix size of pointer during memory allocation
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 10:47:50 +08:00
Jiuzhu Dong
a721bc8830 fs/romfs: fix bug about test:examples/romfs
Mounting ROMFS filesystem at target=/usr/local/share with source=/dev/ram1
Traversing directory: /usr/local/share
  DIRECTORY: /usr/local/share/adir/
Traversing directory: /usr/local/share/adir
  FILE: /usr/local/share/adir/anotherfile.txt/
  DIRECTORY: /usr/local/share/adir/subdir/
Traversing directory: /usr/local/share/adir/subdir
  FILE: /usr/local/share/adir/subdir/subdirfile.txt/
Continuing directory: /usr/local/share/adir
  FILE: /usr/local/share/adir/yafile.txt/
Continuing directory: /usr/local/share
  FILE: /usr/local/share/afile.txt/
  FILE: /usr/local/share/hfile/
ERROR: ldir never found
Finished with  1 errors

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-27 14:24:19 +03:00
ligd
0d365f6fb9 epoll: fix epoll close error, report by kasan
-#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-#18 0x5684427a in nxtask_start () at task/task_start.c:133
-#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-27 08:51:21 +03:00
Jiuzhu Dong
709207b8d3 mm/memdump: dynamic turn on backtrace in heap when enable DEBUG_MM
default turn off.
turn on: echo on > /proc/memdump
turn off: echo off > proc/memdump

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-27 13:21:48 +08: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
Petro Karashchenko
68902d8732 pid_t: unify usage of special task IDs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Xiang Xiao
0f2f48f8ba sys/type.h: Change pid_t from int16_t to int
to fix the following warning:
include/unistd.h:302:9: error: incompatible redeclaration of library function 'vfork' [-Werror,-Wincompatible-library-redeclaration]
pid_t   vfork(void);
        ^
include/unistd.h:302:9: note: 'vfork' is a builtin with type 'int (void)'

and change 32768 to INT_MAX to match the type change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-21 15:48:33 +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
chao.an
9de2818c18 fs/nfs: fix compile warning
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 02:20:20 +08:00
Xiang Xiao
c2a1d0f5ae procfs: Remove mallinfo from struct procfs_meminfo_entry_s
let's call mm_mallinfo directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-17 13:59:03 -03:00
Xiang Xiao
dfb9a763a7 fs: Initialize g_inode_sem at the definition place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 15:06:39 -03:00
Xiang Xiao
f1339ba479 fs/fat: Change the default value of FAT_MAXFNAME to NAME_MAX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-10 19:46:01 +02:00
Xiang Xiao
b3b48a658f fs/aio: Don't include include/nuttx/net/net.h
since it isn't really used

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
Xiang Xiao
b2c86f808d net: Remove psock_fcntl related code
since the nonblocking mode set through psock_ioctl now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
Xiang Xiao
19e796305a vfs: Forward fcntl(F_SETFD...) to ioctl(FIOCLEX|FIONCLEX...)
this is follow change to:
commit 37730a1fce
Author: fangzhenwei <fangzhenwei@xiaomi.com>
Date:   Thu Nov 25 13:43:10 2021 +0800

    nuttx/fcntl:pass O_NONBLOCK flag to ioctl

    1. fix pty fcntl F_SETFL(O_NONBLOCK) fail issue

    Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
Jiuzhu Dong
2197fb2b51 fs/romfs: fix read file mismatch when the length of file name is 16
romfs: file name must end with '\0'

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 11:44:27 -03:00
Xiang Xiao
ddde41018a Revert "sched: Don't duplicate caller file handler when creating kernel thread"
since the temporary kernel spawn proxy need duplicate file handler
from caller, please reference the follow source code for more info:
sched/task/task_posixspawn.c
sched/task/task_spawn.c

This reverts commit 5c5f1dec08.
2022-03-01 12:26:49 +01:00
Jiuzhu Dong
f677a0d316 romfs: cache romfs entry to improve access file speed
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong
bc43206920 fs/romfs: always save linkoffset in romfs_nodeinfo_s
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong
07bfa32e87 fs/romfs: get file path by ioctl with FION_FILEPATH
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong
4f79a1e22c procfs/group/fd: add path for every file descriptor
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong
120fa93d7f fs: add "/" suffix for mountpoint node when using inode_getpath
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Xiang Xiao
da954956e7 Simplify DEFAULT_SMALL usage in Kconfig
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-01 03:15:01 +08:00
Jiuzhu Dong
7ae3c572dc procfs: add heap info for every task
cat /proc/2/heap
AllocSize:  512
AllocBlks:  10

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-26 14:32:42 +08:00
Jiuzhu Dong
2dcc4a359d mm/dump: add pid and backtrace for every memory node
usage:
echo <pid/used/free> trace > /proc/memdump
echo used > /proc/memdump //output all used memory info with backtrace
echo free > /proc/memdump //output all free memory info
echo 22 > /proc/memdump //output used memory info for task pid is 22 with backtrace

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-26 14:32:42 +08:00
Jiuzhu Dong
c5ba9261bc procfs: add memdump interface to dump used/free memory info
usage:echo <used/free> > /proc/memdump
echo used > /proc/memdump // output all used memory node info(address + size)
echo free > /proc/memdump // output all free memory node info(address + size)

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-26 14:32:42 +08:00
Xiang Xiao
43f57240e0 Replece clock_gettime(CLOCK_MONOTONIC) with clock_systime_timespec
it's better to call the kernrel api insteaad user space api in kernel

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-24 01:06:36 +08:00
Xiang Xiao
f1ed349dd9 sched/clock: Remove CLOCK_MONOTONIC option from Kconfig
here is the reason:
1.clock_systime_timespec(core function) always exist regardless the setting
2.CLOCK_MONOTONIC is a foundamental clock type required by many places

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-23 01:21:26 +08:00
fangzhenwei
37730a1fce nuttx/fcntl:pass O_NONBLOCK flag to ioctl
1. fix pty fcntl F_SETFL(O_NONBLOCK) fail issue

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2022-02-22 13:42:44 +08:00