Commit Graph

1537 Commits

Author SHA1 Message Date
Xiang Xiao
1f3a8b5adf Fix mmap compiler error when CONFIG_FS_RAMMAP equals y
fs_munmap.c:122:15: error: ‘struct fs_rammap_s’ has no member named ‘kernel’
fs_rammap.c:110:52: error: expected ‘:’ before ‘;’ token

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-13 14:39:14 -03:00
Xiang Xiao
30135b5f18 vfs: stat_recursive should return -ENOSYS if stat callback is NULL
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic342b6fff112d24c7355ddc8aa0937dfc544f1b4
2021-07-13 11:32:52 -03:00
Xiang Xiao
d539998446 fs: fstat shouldn't follow the symbol link
since the decision is already done at open time(from path to fd)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idc1df3c1d7fe60927b0643173f3f40895aaffd4c
2021-07-13 10:05:50 -03:00
Xiang Xiao
c3c4053263 fs/profs: Add ordblks in meminfo_progmem
forget in commit:
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Wed Apr 28 11:05:20 2021 +0800

    cmd/free: add nused/nfree field in command free

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-12 16:49:56 -03:00
Xiang Xiao
7ef29ecce6 profs: Print StackAlloc by procfs_snprintf
since snprintf return the wrong number in case of insufficient buffer

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-12 16:49:56 -03:00
hujie1
025bddfc6c nuttx: littlefs_close should return value bugfix
N/A

Change-Id: I5fea016fe01ac0e87ddeabdae67d36ab4125ea55
2021-07-12 10:05:49 -03:00
Jiuzhu Dong
9b1f554429 sched: Dynamically extend the pid hash table
Change-Id: I3a719bc575cd408cd530a39efa203f507b44fa9c
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-07-11 19:42:30 -07:00
Xiang Xiao
2fa1e55628 libc: Implement ttyname and ttyname_r
Note: this patch can get file path from root pseudo file handle,
but a general infrastructure is setup for other file system too.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I86cd79ebb741f2f43fdd398bb7498c40687d949b
2021-07-09 18:23:34 -03:00
zhouliang3
b7653e2fae fs: Add parent node of inode
N/A

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
Change-Id: I006c6172ced8edd47b9d4661880e04d3a4274854
2021-07-09 18:23:34 -03:00
Xiang Xiao
ee767021b3 fs: Remove the inernal st_count field from struct stat
it's more simple to reuse the resolve argument as the recursive count

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I826b2fef3af8b12aae230e4766ab09f8de988f8a
2021-07-09 16:38:51 -03:00
Xiang Xiao
643ee82e9c fs: pseudorename should call inode_release in the error path
to avoid the memory leak

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8f7e4c8fb89188614d03dcf383a1707f25c65174
2021-07-09 15:18:32 -03:00
Xiang Xiao
13651cde99 fs: Move the default ioctl handle from nx_vioctl to file_vioctl
ensure the behaviour is same in all ioctl function variant

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie67cfbc579004c8488ef5004c9be7fb179e77041
2021-07-08 09:17:04 -03:00
Xiang Xiao
d5c1979aad fs/procfs: layout the output of meminfo correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic30e70772e19a43e2ad3b298e3ba1ac77f2f2219
2021-07-06 05:39:02 -07:00
Xiang Xiao
8612af4ae5 fs: Implement file_mmap and file_munmap API
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-06 11:18:13 +09:00
Xiang Xiao
2b0b298ab6 fs/mmap: Remove rammap_initialize declaration
Forget in patch:
commit ec30d6ef6b6e246dc32407675c4b54140df33673
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Thu Jun 24 01:42:11 2021 +0800

    fs: Initialize fs_allmaps_s::exclsem in declaration directly

    and then remove rammap_initialize and caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-06 11:18:13 +09:00
Xiang Xiao
7b54b7502c fs/tmpfs: Account the filename in the allocation block
and caclulate the available block more accurately

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia6382239f422970771ccefbd6e461241a5f995a5
2021-07-04 18:51:12 -03:00
Xiang Xiao
6a09ed09f1 fs/tmpfs: Remove the temporary strdup in all place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I224cc9d4ec5fd08937f9f2ddfff022866090be29
2021-07-04 18:51:12 -03:00
Xiang Xiao
c406e03cfe fs/tmpfs: Fix the memory corruption when reallocate tmpfs_directory_s
since it's hard to adjust all childern to point back the new parent
location. Let's allocate the dynamical part(e.g. tdo_entry) separately
and remove the back pointer.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I53afb8336360b7845bd8ecb5aa908acea20e7797
2021-07-04 18:51:12 -03:00
Nathan Hartman
ce20211357 Fix various typos in comments and documentation
Fix typos in these files:
    * Documentation/components/drivers/character/foc.rst
    * Documentation/guides/cpp_cmake.rst
    * Kconfig
    * arch/arm/src/imxrt/imxrt_lpspi.c
    * arch/arm/src/kinetis/kinetis_spi.c
    * arch/arm/src/kl/kl_spi.c
    * arch/arm/src/lpc31xx/lpc31_spi.c
    * arch/arm/src/nrf52/nrf52_radio.h
    * arch/arm/src/s32k1xx/s32k1xx_lpspi.c
    * arch/arm/src/stm32/Kconfig
    * arch/arm/src/stm32/stm32_adc.c
    * arch/arm/src/stm32/stm32_foc.c
    * arch/arm/src/stm32/stm32_foc.h
    * arch/arm/src/stm32/stm32_pwm.c
    * arch/arm/src/stm32/stm32_spi.c
    * arch/arm/src/stm32f0l0g0/stm32_spi.c
    * arch/arm/src/stm32f7/Kconfig
    * arch/arm/src/stm32f7/stm32_spi.c
    * arch/arm/src/stm32h7/Kconfig
    * arch/arm/src/stm32h7/stm32_allocateheap.c
    * arch/arm/src/stm32h7/stm32_fmc.c
    * arch/arm/src/stm32h7/stm32_fmc.h
    * arch/arm/src/stm32h7/stm32_pwm.c
    * arch/arm/src/stm32h7/stm32_qspi.c
    * arch/arm/src/stm32h7/stm32_spi.c
    * arch/arm/src/stm32l4/stm32l4_pwm.c
    * arch/arm/src/stm32l4/stm32l4_spi.c
    * arch/arm/src/stm32l5/Kconfig
    * arch/arm/src/stm32l5/stm32l5_spi.c
    * arch/renesas/src/rx65n/rx65n_dtc.c
    * arch/renesas/src/rx65n/rx65n_usbdev.c
    * arch/risc-v/src/rv32m1/rv32m1_serial.c
    * boards/arm/stm32/b-g431b-esc1/src/stm32_foc.c
    * boards/arm/stm32/nucleo-f103rb/src/stm32_foc_ihm07m1.c
    * boards/arm/stm32/nucleo-f302r8/src/stm32_foc_ihm07m1.c
    * boards/arm/stm32h7/nucleo-h743zi2/README.txt
    * boards/risc-v/rv32m1/rv32m1-vega/README.txt
    * boards/sim/sim/sim/scripts/Make.defs
    * drivers/1wire/1wire.c
    * drivers/1wire/1wire_internal.h
    * drivers/lcd/Kconfig
    * drivers/syslog/ramlog.c
    * fs/fat/Kconfig
    * libs/libc/debug/Kconfig
    * libs/libc/machine/Kconfig
    * libs/libc/stdio/lib_libvsprintf.c
    * libs/libc/stdlib/lib_div.c
    * libs/libc/stdlib/lib_ldiv.c
    * libs/libc/stdlib/lib_lldiv.c
    * libs/libdsp/lib_observer.c
2021-07-04 11:23:26 -05:00
GAEHWILER Reto
38eadbb575 FAT32 kconfig entry to enforce computation of free clusters at mount
Follow up commit for [1] in response to the request to make the mount
behaviour configurable whether the number of free clusters is read
from the fsinfo section or computed (as the white paper suggests).

Default is the original behaviour of NUTTX, just read fsinfo.

[1] https://github.com/apache/incubator-nuttx/pull/3760
2021-07-04 08:26:11 -05:00
ligd
6d3ccf37ab fs: move out nx_close from filelock
If the close is blocked(like net close timeout 5s),
then other file operation can't access in this 5s.

Change-Id: Ia6c4ec88d90db0330134d0aaa30e94cb71c8a066
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-03 07:25:51 -05:00
ligd
2d32a52353 sched_critmon: add thread run time to critmonitor
Change-Id: Ib44e45f0f9a1b249b4067db324c9dbdf0cf3f288
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-02 08:25:02 -05:00
ligd
dbdb24e2e0 procfs: fix cat status error when meet long thread name
nsh> cat /proc/3/status
Name:       init123456789987654Type:       Task
Group:      3
State:      Running

Change-Id: Iddef8fa1fe3a02d407244f46fa05e3f35dd7c84e
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-02 08:25:02 -05:00
ligd
2c775bb0c9 fs/procfs: fix heap overflow when snprintf meet long string
Change-Id: I90f2d9fab55b6e69f159855af3d6dbcb81142eb8
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-02 08:25:02 -05:00
Jiuzhu Dong
554310bd78 fs/fs_dup2: correct check before dup
Change-Id: I2387ab447f0d8ed9429960922a72de35b2730acb
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-07-02 04:54:43 -05:00
Jiuzhu Dong
f57ba35151 fs/procfs: add StackAlloc field for task stack info
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-07-02 04:51:55 -05:00
Xiang Xiao
06215be327 mmap: Implement the minial but reasonable mlock/munlock/mprotect
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I538e0d78ecd0680374a2e0f56adbc61d7a4e6d1f
2021-07-01 08:06:54 +09:00
Xiang Xiao
ec30d6ef6b fs: Initialize fs_allmaps_s::exclsem in declaration directly
and then remove rammap_initialize and caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ife9f04d409b3a14a3be4bbb61c23da6e7a9f8a3d
2021-07-01 08:06:54 +09:00
Masayuki Ishikawa
abc2767b0d fs: nfs: Reconnect to the NFS server in TCP mode
Summary:
- I noticed that an NFS connection is automatically dropped.
- Actually, this happens in TCP mode if no traffic happens
  for 600 seconds.
- I confirmed that the NFS client on Ubuntu automatically
  reconnects to the NFS server when an RPC call failed.
- This commit adds the same behavior to fix the issue.

Impact:
- NFS client in TCP mode

Testing:
- Tested with spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-06-28 01:11:52 -05:00
Xiang Xiao
ae9b5fd306 Replace mktime with timegm in rtc and fs driver
since kernel component should use UTC instead local time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Icf939e1ab0af8e577105f539d2553bc67b3b3d10
2021-06-23 13:43:32 -03:00
Xiang Xiao
2e49e1bc5c mtd: Add MTDIOC_FLUSH IOCTL like MTDIOC_XIPBASE
since the old design reuse BIOC_FLUSH for
MTD device which make some confusion

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-15 13:26:45 -03:00
chao.an
0d8e5b66fd net/sock: move the psock calloc out of sockfd_allocate
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 05:00:21 -05:00
Xiang Xiao
5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
Xiang Xiao
2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Xiang Xiao
d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
Alin Jerpelea
75797039fb fs: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-27 08:07:25 +09:00
GAEHWILER Reto
104bbc50e7 Fix skipping sectors at computing the number of free clusters
Double increment of sector made computation skipping every second sector
and to go beyond fat-table!
2021-05-26 11:36:12 -07:00
Jiuzhu Dong
fea1da2f53 cmd/free: add nused/nfree field in command free
Change-Id: I74aa4b1e7394a17c3b117322a4cc24aa52aac3b8
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-05-25 01:01:38 -07:00
GAEHWILER Reto
fc55f25fff Fix calculation of free clusters at mounting a fat partition
Previously the value of the FSInfo section was taken as granted.
As described in the white paper of FAT [1] this value is unreliable
and has to be computed at mount time.

    [1] https://www.win.tue.nl/~aeb/linux/fs/fat/fatgen103.pdf
2021-05-21 09:54:30 -03:00
SPRESENSE
0cc0c3d503 fs/vfs: Fix bug that select() did not return
Fix bug that select() did not return when the nfds argument
was set to a negative value. The specification is that -1 is
set to the return value and EINVAL is set to errno.
2021-05-19 06:43:22 -05:00
Jukka Laitinen
105f305b1b fs/fat/fat32util.c: Fix calculation of current sector with invalid cluster
If the current cluster is invalid, don't use the error code for calculating
the sector number. Instead just return the error code.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-05-19 03:06:34 -05:00
Jiuzhu Dong
9980a1c27d fs/hostfs: fix bug about getting error file size by fstat
Change-Id: I10a0d52da649e4c3138e5a2301bcb6525e2e3350
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-05-16 01:13:09 -07:00
Masayuki Ishikawa
e1b14271c8 fs: nfs: Do not bind to a local port in TCP mode
Summary:
- Since binding to a local port is not necessary in TCP mode,
  it should be done only in UDP mode

Impact:
- None

Testing:
- Tested with NFS server on Ubuntu 18.04 (x86_64)
- Tested with spresense:rndis (defconfig will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-05-13 22:33:12 -03:00
Masayuki Ishikawa
2873f33bc4 fs: nfs: Fix to read a large packet in TCP mode
Summary:
- I noticed that receiving a read large packet (e.g. 2KB) in TCP
  mode does not work correctly
- Actually, rpcclnt_receive() only received up to MSS
- This commit fixes this issue

Impact:
- TCP mode only

Testing:
- Tested with Ubuntu 18.04 (x86_64)
- Tested with spresense:rndis (defconfig will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-05-13 22:33:12 -03:00
Masayuki Ishikawa
f0372dde6a fs: nfs: Fix rpcclnt_send() in TCP mode
Summary:
- I noticed that NFS over TCP does not work with Ubuntu 18.04
- Finally, I found that the record marking packet should not
  be sent separately
- This commit fixes this issue

Impact:
- TCP mode only

Testing:
- Tested with NFS server on Ubuntu 18.04 (x86_64)
- Tested with spresense:rndis (defconfig will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-05-13 22:33:12 -03:00
Simon Piriou
87375ae2ac fs/eventfd: add EVENT_FD_POLL as a Kconfig dependency for EVENT_FD_NPOLLWAITERS 2021-05-08 08:29:21 -07:00
David Sidrane
22b719945f fs:cromf Use inttypes in printing macros 2021-05-04 09:40:51 +01:00
chao.an
58bd0468ab fs/inode: correct the return value
correct the return value of fs_getfilep() since the
semaphore take may probably fail if the thread canceled

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-04-19 09:50:45 +01:00
Xiang Xiao
2335b69120 arch: Allocate the space from the beginning in up_stack_frame
arch: Allocate the space from the beginning in up_stack_frame

and modify the affected portion:
1.Correct the stack dump and check
2.Allocate tls_info_s by up_stack_frame too
3.Move the stack fork allocation from arch to sched

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-04-16 12:41:41 +09:00
Alin Jerpelea
08612337f6 NuttX: nxstyle fixes
nxstyle fixes to pass CI.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-04-10 06:42:19 -05:00