Commit Graph

1351 Commits

Author SHA1 Message Date
dongjiuzhu
c22ab31728 fs: flashback to release all file descriptors in group to increase debugging time.
Change-Id: I47851f7e679addf36077c491ef7d1a5a29d1c2be
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-11-17 18:54:31 -08:00
YAMAMOTO Takashi
4f514f41d4 fs/procfs/fs_procfsiobinfo.c: Add a missing entry for can
Found by the following compiler warning:

    procfs/fs_procfsiobinfo.c: In function 'iobinfo_read':
    procfs/fs_procfsiobinfo.c:344:20: error: '%-16s' directive argument is null [-Werror=format-overflow=]
      344 |       linesize   = snprintf(iobfile->line, IOBINFO_LINELEN,
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      345 |                             "\n%-16s%16lu%16lu\n",
          |                             ~~~~~~~~~~~~~~~~~~~~~~
      346 |                             g_iob_user_names[IOBUSER_GLOBAL],
          |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      347 |                             (unsigned long)userstats->totalconsumed,
          |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      348 |                             (unsigned long)userstats->totalproduced);
          |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
95a9843284 fs/procfs/fs_procfsproc.c: Fix prinf format warnings 2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
f1bc94bd32 fs/procfs/fs_procfscpuload.c: Fix printf format warnings 2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
48765a7160 fs/smartfs/smartfs_procfs.c: Fix printf format warnings 2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
008d411fc3 fs/procfs/fs_procfsproc.c: Fix a printf format warning 2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
08b4cb6517 fs/procfs/fs_procfsuptime.c: Fix a printf format 2020-11-16 08:29:00 -08:00
YAMAMOTO Takashi
711371a855 fs/procfs/fs_procfsiobinfo.c: Appease nxstyle 2020-11-16 05:46:53 -08:00
chao.an
6aee468d72 eventfd: remove the unique minor limit
The unique minor limit of 255 will overflow easily in
some scenarios where eventfd needs to be create/destroy
frequently:

  while (1)
    {
      fd = eventfd(0, 0);  // minor++
      sleep(1);
      close(fd);
    }

remove the unique minor limit.

Change-Id: I0ea1c825ce9b542c883166cb3e72574455ffdd0d
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-11 18:26:59 -08:00
Xiang Xiao
84b90e00f0 libc/stdio: Preallocate the stdin, stdout and stderr
to handle the uninitialized stdin/stdout/stderr gracefully
report here:
https://github.com/apache/incubator-nuttx/issues/2203

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-11-11 09:56:10 -08:00
Juha Niskanen
ca7a7ccbeb Fix some typos in comments
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-11-08 18:58:20 +01:00
Juha Niskanen
1577726f05 fs/inode/fs_fileopen.c: use nx_close instead of close
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-10-28 09:11:50 -07:00
dongjiuzhu
d452a05910 pollnotify: we should send poll events before semaphore incrementes.
There is a good case on sim platform:
When we input some cmd and click enter key to start application in terminal,
this context will change to application from IDLE loop. Althrough entey key '\r'
has been received to recv buffer and complete post semaphore of reader, but
pollnotify may not be called because context change. So when application run
poll function, because no events happend and poll enter wait, context will
again change to IDLE loop, this pollnotify of IDLE loop will run to send poll
events, poll function of applicaton will wake up. It's wrong!

Change-Id: I812a889f2e90781a9c3cb4b0251cccc4d32bebd1
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-10-26 08:27:09 -03:00
dongjiuzhu
bcf3381d06 epoll_create: mofidy return value for epoll_create1
Change-Id: I422d7640c37105e1120db18b29d56547f447846f
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-10-25 11:06:37 -07:00
Xiang Xiao
eb4121ce38 Change all 'Nuttx' to 'NuttX'
Unify the naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-20 01:45:06 -07:00
zhongan
5aa0e302a4 fs: add missing macro 'CONFIG_FS_HOSTFS' for 'NODFS_SUPPORT'.
When just enable 'CONFIG_FS_HOSTFS', NODFS_SUPPORT may not enable.

Change-Id: I8317f18bf3ceae873e29c027561948c17b4aab38
Signed-off-by: zhongan <zhongan@xiaomi.com>
2020-10-17 23:22:35 +08:00
Nathan Hartman
80ce7800a9 Sources and Docs: Fix typos and nxstyle issues
Documentation/contributing/coding_style.rst:

    * Fix repeated words: ("this this").
    * Remove trailing spaces.

boards/z80/z80/z80sim/README.txt:

    * Fix repeated words: ("this this") and rewrap lines.

graphics/Kconfig,
libs/libc/math/Kconfig:

    * Fix repeated words: ("this this").

arch/arm/src/armv7-a/arm_assert.c,
arch/arm/src/armv7-r/arm_assert.c,
arch/arm/src/imxrt/imxrt_enet.c,
arch/arm/src/kinetis/kinetis_enet.c,
arch/arm/src/kinetis/kinetis_flexcan.c,
arch/arm/src/s32k1xx/s32k1xx_enet.c,
arch/arm/src/s32k1xx/s32k1xx_flexcan.c,
arch/arm/src/stm32/stm32_pwm.c,
arch/arm/src/stm32h7/stm32_pwm.c,
arch/arm/src/stm32l4/stm32l4_pwm.c,
arch/renesas/src/rx65n/rx65n_usbdev.c,
binfmt/libnxflat/libnxflat_bind.c,
drivers/pipes/pipe_common.c,
net/igmp/igmp_input.c,
net/tcp/tcp_conn.c,
sched/sched/sched_roundrobin.c:

    * Fix typo in comment ("this this").

arch/arm/src/cxd56xx/cxd56_usbdev.c,
arch/arm/src/lc823450/lc823450_usbdev.c:

    * Fix typo in comment and rewrap lines.

arch/arm/src/imxrt/imxrt_usbdev.c,
arch/arm/src/stm32/stm32_dac.c,
arch/arm/src/stm32f0l0g0/stm32_pwm.c,
arch/arm/src/stm32f7/stm32_pwm.c,
arch/arm/src/tiva/lm/lm4f_gpio.h,
fs/nxffs/nxffs_write.c,
include/nuttx/analog/pga11x.h,
include/nuttx/usb/usbdev.h,
net/mld/mld_join.c:

    * Fix typo in comment ("this this").
    * Fix nxstyle issues.
2020-10-02 04:54:52 +02:00
Xiang Xiao
b422f49fa7 fs: Skip the enumeration of root directory in foreach_inode
ensure the behaviour same before:
commit b76c4672d6 (origin/root)
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Tue Sep 15 17:42:42 2020 +0800

    vfs: Create a node as the root of pseudo file system

    to remove the special process for root

    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-30 12:26:57 +02:00
Xiang Xiao
66057a4612 fs: Add the relative path support
all functions which accept the path argument should support the relative path:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-24 03:13:27 -07:00
Xiang Xiao
de45e8647a Revert "s/dirent: Corrects a problem with opendir() noted by Petteri Aimonen in Bitbucket Issue 132: "opendir() fails for FAT filesystem with trailing slash in path":"
because:
1.The name of directory may terminated by the whitespace
2.inode_search can handle the trailing '/' correctly
3.Let fix the issue in FAT filesystem instead

This reverts commit 97b0235d77.
2020-09-22 23:05:10 +01:00
Xiang Xiao
8567637378 fs/fat: Handle the tail '/' correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I72c4d018c174d094d777941d0679ad792a1f5527
2020-09-22 23:05:10 +01:00
Xiang Xiao
43f0070582 fs: Simplify the symbol link process in inode_search
avoid the recursive call by moving the path catenation into _inode_search

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-22 16:39:47 +08:00
chao.an
9241725312 fs/munmap: export the symbols to avoid build break on C++ syntax
base/metrics/persistent_memory_allocator.cc:1009:18: error: expected id-expression before ‘-’ token
 1009 |   int result = ::munmap(memory, size);
      |                  ^~~~~~

Change-Id: I24e55c18d09553d3acc341a27063d01489d905ec
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-09-18 20:05:10 -07:00
Xiang Xiao
b76c4672d6 vfs: Create a node as the root of pseudo file system
to remove the special process for root

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-16 11:44:57 -07:00
Yoshinori Sugino
5eefe8609c fs/vfs/fs_ioctl.c: Call F_GETFD to avoid clear other flag we will add in the future 2020-09-16 02:31:33 -07:00
Yoshinori Sugino
d4ec1ababd fs/vfs/fs_ioctl.c: Add FIOCLEX/FIONCLEX support 2020-09-16 02:31:33 -07:00
Xiang Xiao
6584bfa361 fs: Add static to stat_recursive
since it is called in one source file

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-16 01:06:53 -07:00
Xiang Xiao
1e848e5d8b fs: Call RELEASE_SEARCH to free resource in pseudorename
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-16 01:06:53 -07:00
Xiang Xiao
59fbd35609 fs: rename the mountpoint should go through pseudorename branch
to avoid this type of error:
mount -t procfs /a/b
mv /a/b /
mv: rename failed: 88

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-09-15 23:07:20 -07:00
Xiang Xiao
b0797263ca libc/stdio: Allocate file_struct dynamically
1.Reduce the default size of task_group_s(~512B each task)
2.Scale better between simple and complex application

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia872137504fddcf64d89c48d6f0593d76d582710
2020-09-11 17:58:17 +08:00
liuhaitao
bf06776f7c fs/vfs: reuse file_dup2 directly in file_dup to fix segfault issue
Or close the fd2 return by dup() would segment fault since filep->f_priv
null access.

Change-Id: I285c86f54bbb486d6c2c5aea53952f69083dca72
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-09-09 07:49:40 -07:00
Nathan Hartman
91b52c38f9 Fix wrong executable bit on two source files
boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h:

    * Remove erroneous executable bit.

fs/tmpfs/fs_tmpfs.c:

    * Remove erroneous executable bit.
2020-08-31 19:19:14 +01:00
anatasluo
ab37b14972 fs/tmpfs: Remove duplicated code
Signed-off-by: anatasluo <luolongjuna@gmail.com>
2020-08-31 10:41:30 +08:00
Xiang Xiao
389b45359d epoll: Don't save fd into the field of epoll_data_t
since epoll_data_t is reserved to the caller and
then shouldn't be touched by the implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-25 21:06:48 +01:00
Xiang Xiao
a354b9a9d1 fs/vfs: Implement EPOLLONESHOT flag
https://linux.die.net/man/2/epoll_ctl:
EPOLLONESHOT (since Linux 2.6.2)
Sets the one-shot behavior for the associated file descriptor.
This means that after an event is pulled out with epoll_wait(2)
the associated file descriptor is internally disabled and
no other events will be reported by the epoll interface.
The user must call epoll_ctl() with EPOLL_CTL_MOD to
rearm the file descriptor with a new event mask.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6c0dc93e1cdae0e8cea5b487c7005de2da2c2ec3
2020-08-25 21:06:48 +01:00
Xiang Xiao
6c9ff72b9a fs/vfs: Implement epoll_pwait API
specified here:
https://linux.die.net/man/2/epoll_pwait

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I20106fdbe4f403ded7eab43f3523edd262e1d9a3
2020-08-25 21:06:48 +01:00
Xiang Xiao
ae356001cf Change all files come from Xiaomi/Pinecone to Apache License 2.0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Gregory Nutt
e880bc9a71 Remove unused, non-modular procfs reference
fs/procfs/fs_procfs.c contained an unused reference to an STM32 procfs structure.  This is wrong in two ways:  (1) There should be not STM32 references outside of arch/arm and boards/arm and (2) the declare STM32 structure is not used anyway.
2020-08-22 16:22:18 +01:00
Esteban Zamora
8beb1edbda Fix inverted errno in mq_open
Signed-off-by: Esteban Zamora <esteban.zamora@hpe.com>
2020-08-20 20:35:16 -03:00
spiriou
0ddefd7c69 fs/vfs/fs_epoll: fix epoll_wait function 2020-08-20 11:49:20 -05:00
David Sidrane
2953880f5c fs_cromfs: Removed DEBUGASSERT on non-exiting var node 2020-08-20 14:10:02 +01:00
chao.an
6176e33ed2 fs/littlefs: enable the low level log only on debug mode
Change-Id: I2fa95e2f1e861f76bb394a06344d90fac28ae195
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-08-18 12:13:32 +01:00
chao.an
b89737395b vfs/epoll: add epoll_create1(2) implement
Linux Programmer's Manual

NAME
       epoll_create, epoll_create1 - open an epoll file descriptor

...
SYNOPSIS
       #include <sys/epoll.h>

       int epoll_create1(int flags);
...

   epoll_create1()
       If flags is 0, then, other than the fact that the obsolete
       size argument is dropped, epoll_create1() is the same as
       epoll_create(). The following value can be included in flags
       to obtain different behavior:

       EPOLL_CLOEXEC
              Set the close-on-exec (FD_CLOEXEC) flag on the new file
              descriptor. See the description of the O_CLOEXEC flag in
              open(2) for reasons why this may be useful.

https://man7.org/linux/man-pages/man7/epoll.7.html
2020-08-17 23:41:13 -05:00
Xiang Xiao
85428036ab fs/vfs: Don't check CONFIG_NFILE_STREAMS for mkdir/rename/rmdir/fs_unlink
since these function don't depend on standard input/output function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I011a387a1e2c1360e8f37716d512bd32f93ad467
2020-08-17 00:16:26 +01:00
Xiang Xiao
acca9fcc3b sched/wdog: Remove MAX_WDOGPARMS and related stuff
since the variable arguments are error prone and seldom used.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-14 08:19:50 -06:00
Xiang Xiao
a0ce81d659 sched/wdog: Don't dynamically allocate wdog_s
to save the preserved space(1KB) and also avoid the heap overhead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I694073f68e1bd63960cedeea1ddec441437be025
2020-08-11 12:28:55 -06:00
Gregory Nutt
b256b2055f Add support to hard links to CROMFS
This will resolve numerous problems with the way that hard links, in particular "." and ".." are handled.  Instead of trying to fudge the stat flags, the correct implementation is to follow the hard link to the final link target node.  That is what must determine the attributes of the directory entry.
2020-08-11 07:48:08 -07:00
Gregory Nutt
32e98790c0 Correct ROMFS hardlink handling
This PR corrects an error in the ROMFS file system.  The error occurred after following a hard link (depending on how the ROMFS image is organized).  The error occurred because some of the information buffered before following the links was stale and, hence, out of sync after following the hard link.  This would cause random errors when paths containing hardlinks were used with ROMFS.

This PR resolves Issue #1543.  Please compare the following output with the output in Issue #1543 to see how the problem was resolved:

    NuttShell (NSH) NuttX-9.1.0
    nsh> mount
      /etc type romfs
      /proc type procfs
      /tmp type vfat
    nsh> ls -Rl /etc
    /etc:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    /etc/init.d:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS

    nsh> ls -l /etc/init.d
    /etc/init.d:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS
    nsh> ls -l /etc/init.d/.
    /etc/init.d/.:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      71 rcS

    nsh> ls -l /etc/init.d/..
    /etc/init.d/..:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    nsh> ls -l /etc/init.d/../.
    /etc/init.d/../.:
     dr-xr-xr-x       0 .
     dr-xr-xr-x       0 ..
     -r-xr-xr-x      20 group
     dr-xr-xr-x       0 init.d/
     -r-xr-xr-x      35 passwd
    nsh>
2020-08-10 07:32:06 -07:00
Xiang Xiao
4c706771c3 sched/wdog: Replace all callback argument from uint32_t to wdparm_t
and alwasy cast the argument of wd_start to wdparm_t

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-08 17:30:26 -03:00
David Sidrane
2eccc960a9 fs_cromfs:Remove duplicate case intorduced by 67ef70d 2020-08-04 21:20:25 -05:00