Commit Graph

1984 Commits

Author SHA1 Message Date
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
yangjiao bef756c004 fs/mqueue: Fix the wrong field type in mq_attr as the spec and add the logical judgment to deal with the condition when mq_maxmsg or mq_msgsize is less than zero or equal to zero.
In POSIX standard spec https://pubs.opengroup.org/onlinepubs/7908799/xsh/mqueue.h.html, the field type in mq_attr should be long not size_t. And no logical judgment when mq_maxmsg <= 0 or mq_msgsize <= 0. In this change, i update the field type in mq_attr, and add the missing logical judgment.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
fangxinyong 1adef07a79 fs/shmfs: implement read and write interface
To pass LTP posix case mmap/1-2.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong ea52220509 fs/shmfs: fix inode leak issue
If the shm file is removed and a subsequent close, only release shm
object, but inode is leaked. Should decrease refcount to release inode
when unmapped, that matched with refcount increase when mapped.

Another fix that remove the shm file failed.
nsh> rm /var/shm/pts_mmap_1_2_5
nsh: rm: unlink failed: 6

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong bfeb73e850 fs/tmpfs: fix use after free issue
mmap establish a mapping address space that refer to a tmpfs file,
there are two issues:

1. if the tmpfs file is removed and a subsequent close(), tmpfs_close
will release the backend memory object, use after free errors occur
when operating the mapping memory. We add an extra reference to memory object,
memory will be released when there are no more mappings.

2. if unmap only a portion of the memory, fix the bug that adds another map.
Use realloc and shrink the mapping memory instead.

The fix pass LTP posix case mmap/10-1.c and mmap/12-1.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong 43b0421b2a mm/map: limit the count of memory mapping for the task
No memory map count limit that will exhaust memory and cause
the system hang. Also that fix pass LTP posix case mmap/24-1.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong d1825a7acb fs/mmap: only MAP_SHARED mapping need file write permisson
If MAP_PRIVATE is specified, do not change the underlying object,
that is OK to open file with read-only permission. Change to pass:
testcases/open_posix_testsuite/conformance/interfaces/mmap/6-5.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong d892cda167 fs/mmap: fix mmap() wrong errno
As posix spec, mmap() function shall fail with ENODEV if fd refers
to a file whose type is not supported. Change to pass ltp open_posix test:
testcases/open_posix_testsuite/conformance/interfaces/mmap/23-1.c

https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong 5176fb917a fs/vfs: ftruncate produce EINVAL if fd is not open for writing
As posix spec, ftruncate should produce EBADF or EINVAL error,
if the file descriptor fd is not open for writing.

Change the behavior to be similar to Linux and pass ltp open_posix test:
testcases/open_posix_testsuite/conformance/interfaces/shm_open/20-1.c

https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
https://man7.org/linux/man-pages/man2/ftruncate.2.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
Zhe Weng d563717827 fs/romfs: Fix FIOC_FILEPATH for dup'ed file
The FIOC_FILEPATH ioctl needs rf->rf_path, which is not initialized for
dup'ed romfs file and cause problems.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-02 06:12:25 -07:00
Fotis Panagiotopoulos 0fcf6f2e41 open: Use file mode only when O_CREAT is specified. 2023-08-02 06:08:20 -07:00
hujun5 0b2b5b781c fs: remove sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-08-01 23:15:37 +02:00
dongjiuzhu1 f8ce0cd4ca fs/pseudofile: config pseudofile feature
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-31 22:22:58 -07:00
dongjiuzhu1 8336ee78b8 vfs/fs_pseudofile: fix coverity issue
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-31 22:22:58 -07:00
dongjiuzhu1 0f6d0eac52 fs/pesudofile: support pseudo-file operation
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-31 22:22:58 -07:00
dongjiuzhu1 80004ef07d fs/nfs: fix coding style issue
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-31 21:41:30 -07:00
yangyalei f2844a2e3c vfs: return OK when fsync dir
Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-07-31 07:50:10 -07:00
wangbowen6 b0ab41beee memdump: support dump the leak memory (malloced but task exit)
1. command "memdump leak" can dump the leacked memory node;
2. fix the leak memory stat bug in memory manager;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-07-31 05:48:33 -07:00
dongjiuzhu1 e4c015f0aa fs/nfs: support seek, fsync operation
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-31 03:46:13 -07:00
Xiang Xiao 427e574bd1 fs/unionfs: Remove unionfs_mount function
since the same function can be achieved by mount:
mount(NULL, "/mnt/unionfs", "unionfs", 0,
      "fspath1=/mnt/path1,prefix1=prefix1,"
      "fspath2=/mnt/path2,prefix2=prefix2");

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-30 18:51:26 -03:00
wangjianyu3 0a52dfaa66 TXTABLE: Support backup table
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2023-07-29 20:27:10 -07:00
wangjianyu3 ca08f069a7 partition: Add TXTABLE parser
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2023-07-29 20:27:10 -07:00
fangxinyong dfa6a43744 fs/mmap: fix wrong return value check
while iterate throuh all mapping memory to munmap and release,
the last entry is NUlL.
We need differentiate the case with invald entry at the first.

The fix is to pass ltp shm related cases.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-07-28 08:05:39 -07:00
dongjiuzhu1 88161bfca5 fs/mmap: add sanity check
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-28 08:05:39 -07:00
dongjiuzhu1 e4739ab575 fs/tmpfs: add munmap interface for tmpfs file map
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-28 08:05:39 -07:00
dongjiuzhu1 f8991f7782 vfs/dup: add nonblock flag to avoid happening block when dup
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-28 07:41:51 -07:00
yangjiao c2e1aa281d fs/semaphore/sem_open: update the logic when the semaphore name length is greater than PATH_MAX or a component length is greater than NAME_MAX.
Follow the POSIX specification in https://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_open.html, update the logic for condition that the semaphore name length is greater than PATH_MAX or a component length is greater than NAME_MAX.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-07-28 07:38:41 -07:00
dongjiuzhu1 1cc67b68f2 fs/procfs: call the close of each component when procfs_close
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-28 05:09:07 -07:00
Xiang Xiao f3269a6caa sched: Rename DEBUG_TCBINFO to ARCH_HAVE_TCBINFO
and select if the arch support to define g_tcbinfo variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-26 09:33:38 +02: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
anjiahao 9f644579b3 fix sim register & tcb info typo
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-07-23 21:59:35 -07:00
Xiang Xiao abfe082a6f Kconfig: Simplify the conditional default statement
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-16 14:39:20 -03:00
Xiang Xiao e031a73aef Kconfig: Change some "default y" to "default !DEFAULT_SMALL"
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-16 14:39:20 -03:00
chao an f10b54a081 cmake: fix CMake build break
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-15 23:32:36 +08:00
dulibo1 13c7138c8d add refcnt using epoll_create to fix bug when use popen which dup the fd and close at end after epoll_create
Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2023-07-13 01:06:53 +08:00
simbit18 9681c52517 Fix nuttx coding style
Remove TABs
Fix indentation
2023-07-11 23:32:17 +08:00
yanghuatao e9d7210d02 sim/posix_test: fix shm_open() return file descriptor associated with FD_CLOEXEC
Make the pthread_setspecific pass the shm_open/11-1.c testcases. Function shm_open() should return a file descriptor for the shared memory object associated with FD_CLOEXEC. Reference to https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html and https://github.com/lattera/glibc/blob/master/sysdeps/posix/shm_open.c#LL38C1-L38C1

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-07-11 13:30:34 +08: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 935f43185f libc/modlib: Replace nx_stat with file_stat
to avoid searching the path twice

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-06 09:20:24 -03:00
Junbo Zheng 7c8adecca8 fs/mount: correct `df -h` output format
config: ./tools/configure.sh sim:nsh
correct before
```
nsh> df
  Block    Number
  Size     Blocks       Used   Available Mounted on
     0          0          0           0 /bin
    64          8          8           0 /etc
     0          0          0           0 /proc
   512        985          2         983 /tmp
nsh>
nsh> df -h
  Filesystem    Size      Used  Available Mounted on
  binfs      0B        0B         0B /bin
  romfs      512B      512B         0B /etc
  procfs     0B        0B         0B /proc
  vfat       492K        1K       491K /tmp
nsh>
```
correct after
```
nsh> df
  Block    Number
  Size     Blocks       Used   Available Mounted on
     0          0          0           0 /bin
    64          8          8           0 /etc
     0          0          0           0 /proc
   512        985          2         983 /tmp
nsh> df -h
  Filesystem      Size      Used  Available Mounted on
  binfs             0B        0B         0B /bin
  romfs           512B      512B         0B /etc
  procfs            0B        0B         0B /proc
  vfat            492K        1K       491K /tmp
nsh>
```

config: ./tools/configure.sh ../vendor/sim/boards/miwear/configs/miwear -j16
correct before
```
nsh>
nsh> df
  Block    Number
  Size     Blocks       Used   Available Mounted on
     0          0          0           0 /bin
  4096  240075962   87644775   152431187 /data
    64       3621       3621           0 /etc
  4096  240075962   87644775   152431187 /font
  4096  240075962   87644775   152431187 /i18n
     0          0          0           0 /proc
  4096  240075962   87644775   152431187 /resource/app
  4096  240075962   87644775   152431187 /resource/misc
  4096  240075962   87644775   152431187 /resource/recovery
  4096  240075962   87644775   152431187 /resource/system
  4096  240075962   87644775   152431187 /system
   512         26         24           2 /tmp
  4096  240075962   87644775   152431187 /vendor
  4096  240075962   87644775   152431187 /watchface
nsh>
nsh> df -h
  Filesystem    Size      Used  Available Mounted on
  binfs      0B        0B         0B /bin
  hostfs     915G      334G       581G /data
  romfs      226K      226K         0B /etc
  hostfs     915G      334G       581G /font
  hostfs     915G      334G       581G /i18n
  procfs     0B        0B         0B /proc
  hostfs     915G      334G       581G /resource/app
  hostfs     915G      334G       581G /resource/misc
  hostfs     915G      334G       581G /resource/recovery
  hostfs     915G      334G       581G /resource/system
  hostfs     915G      334G       581G /system
  tmpfs      13K       12K         1K /tmp
  hostfs     915G      334G       581G /vendor
  hostfs     915G      334G       581G /watchface
```
correct after
```
nsh>
nsh> date
Mon, Jul 03 02:09:53 2023
nsh>
nsh> df
  Block    Number
  Size     Blocks       Used   Available Mounted on
     0          0          0           0 /bin
  4096  240075962   87644776   152431186 /data
    64       3621       3621           0 /etc
  4096  240075962   87644776   152431186 /font
  4096  240075962   87644776   152431186 /i18n
     0          0          0           0 /proc
  4096  240075962   87644776   152431186 /resource/app
  4096  240075962   87644776   152431186 /resource/misc
  4096  240075962   87644776   152431186 /resource/recovery
  4096  240075962   87644776   152431186 /resource/system
  4096  240075962   87644776   152431186 /system
   512         26         24           2 /tmp
  4096  240075962   87644776   152431186 /vendor
  4096  240075962   87644776   152431186 /watchface
nsh>
nsh> df -h
  Filesystem      Size      Used  Available Mounted on
  binfs             0B        0B         0B /bin
  hostfs          915G      334G       581G /data
  romfs           226K      226K         0B /etc
  hostfs          915G      334G       581G /font
  hostfs          915G      334G       581G /i18n
  procfs            0B        0B         0B /proc
  hostfs          915G      334G       581G /resource/app
  hostfs          915G      334G       581G /resource/misc
  hostfs          915G      334G       581G /resource/recovery
  hostfs          915G      334G       581G /resource/system
  hostfs          915G      334G       581G /system
  tmpfs            13K       12K         1K /tmp
  hostfs          915G      334G       581G /vendor
  hostfs          915G      334G       581G /watchface
nsh>
```

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2023-07-03 23:09:46 +03:00
Petro Karashchenko b1dd5d1189 drivers/wireles/gs2200m: add NET_TCP dependency to NFS_DONT_BIND_TCP_SOCKET option
The NFS_DONT_BIND_TCP_SOCKET should be selected only TCP networking is enabled

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-07-03 13:32:31 +08:00
Masayuki Ishikawa c2af551355 fs: nfs: Introduce CONFIG_NFS_DONT_BIND_TCP_SOCKET
Summary:
- Some network drivers such as GS2200M do not support to bind
  a local port for TCP client socket. In this case, this config
  disables to bind the port.
- See also https://github.com/apache/nuttx/pull/3707

Impact:
- None

Testing:
- Tested with spresense:wifi_smp (Kconfig will be updated later)
- Tested with sabre-6quad:netnsh_smp (QEMU)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2023-07-01 13:18:27 +08:00
Masayuki Ishikawa 221d919b77 Revert "fs: nfs: Do not bind to a local port in TCP mode"
This reverts commit e1b14271c8.
2023-07-01 13:18:27 +08:00
guoshichao 1466a9e2b6 libs/libc/aio: refactor the fd flags check procedure
1. make the implementation compatible with c89

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-30 20:23:09 -03:00
guoshichao d5f45dc33b libs/libc/aio: fix aio_cancel compatible issue
1. make the aio_cancel implementation can pass the
ltp/open_posix_testsuite/aio_cancel testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_cancel.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-29 23:25:33 +08:00
guoshichao d4dc0f6ec7 libs/libc/aio: fix aio_fsync compatible issue
1. make the aio_fsync implementation can pass the
ltp/open_posix_testsuite/aio_fsync testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_fsync.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-29 18:15:48 +08:00
guoshichao dc69b108b8 libs/libc/aio: fix aio_write compatible bug
1. make the aio_write implementation can pass the
lpt/open_posix_testsuite/aio_write testcases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_write.html

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-29 00:59:27 +08:00
Mingjie Shen 7d13f5eb78 fs/fat: Fix undefined behavior in signed integer overflow check
Testing for overflow by adding a value to a variable to see if it "wraps
around" works only for unsigned integer values, because signed overflow
has undefined behavior according to the C and C++ standards.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
2023-06-28 23:02:25 +08:00