Commit Graph

1537 Commits

Author SHA1 Message Date
Xiang Xiao
fe96250c40 fs: Make nx_vxxx and file_vxxx as internal functions
these functions are the implementation detail and then
don't need expose to external

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ief832391d5b42d1f1645907eb465631650490234
2021-01-12 17:08:22 +01:00
Xiang Xiao
1604fe0b4b fs: Remove file_detach since it is unefficient to call open and file_detach
the kernel user should call file_open directly instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5bf7f661006f5d43739bc8618abfb4b983fde78d
2021-01-11 23:47:57 +01:00
Xiang Xiao
0032ddb8bf fs: Reimplement file_open to not depend on nx_open
on the other hand, open/nx_open call file_open instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I66990a77cdeb6ff18f7bf48a65bbc7b701dad552
2021-01-11 23:47:57 +01:00
ligd
e772be8c8a fs/inode/fs_files.c: fix DEBUGASSERT in romfs
up_assert: Assertion failed at file:romfs/fs_romfs.c line: 643

newp->f_priv should be NULL.

Change-Id: I5f72b1329a8938ce39cf1ac5fbee561ca106f4f6
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-01-08 10:20:47 -06:00
Xiang Xiao
1aa69f4c73 fs: Remove the special hack for pty in nx_vopen
let's replace the content of file in place instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I538910d55815c7aec656c05dba4eab2fa1d6d964
2021-01-08 11:04:24 +08:00
Xiang Xiao
86fab49c46 fs: Fix the race condition in file_dup
NULL inode passed to files_allocate doesn't mark file struct in the
allocated state, so other threads which invovle in file allocation
(e.g. open or dup) may allocate the same file struct again.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I53ff876eae3c7a1e311e7f671686b73a4b4ef891
2021-01-08 11:01:46 +08:00
Xiang Xiao
b343caae4d fs: file_dup2 shouldn't destroy filep2 before the duplication of filep1 succeed
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I10956f5e32cc0add414076465c06a24a858e52bc
2021-01-08 11:01:46 +08:00
YAMAMOTO Takashi
b3d36219e4 spiffs: Document how to generate images 2021-01-06 03:06:39 -06:00
YAMAMOTO Takashi
7305e04336 spiffs/Kconfig: Mention that CONFIG_SPIFFS_MAX_NAME is an on-flash thing 2021-01-06 03:06:39 -06:00
YAMAMOTO Takashi
3ba050a4c2 spiffs: Rename the upsteam readme to README-spiffs.md
To make a room for NuttX specific documentation.
2021-01-06 03:06:39 -06:00
YAMAMOTO Takashi
c9b783e5e6 spiffs: Prefix filenames with '/' as other implmenetations do 2021-01-06 03:06:39 -06:00
YAMAMOTO Takashi
9b7e7efeb8 spiffs_pgobj_ndxheader_s: Add a missing alignment
Withtout this change, I was not able to read images built
with the following tools:

    * https://github.com/igrr/mkspiffs
    * spiffsgen.py from ESP-IDF

Introduce a new Kconfig option, SPIFFS_COMPAT_OLD_NUTTX,
for those who prefer to keep the on-disk (bug-to-bug?) compatibility
with the older NuttX.
2021-01-06 03:06:39 -06:00
YAMAMOTO Takashi
e38463ffff fs/spiffs/src/spiffs_core.h: Appease nxstyle 2021-01-06 03:06:39 -06:00
ligd
f63db66382 mqueue: add file_mq_xx for kernel use
Change-Id: Ida12f5938388cca2f233a4cde90277a218033645
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-01-05 02:40:43 -06:00
ligd
3bc33572e3 mqueue: simplify the mqueue reailize
1. remove descript management in mqueue, save code size
2. use i_ops instead of i_mqueue to remove the dup logic

Change-Id: Ie88960e50ddcae9c87977c9ad65a45297c663291
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-01-05 02:40:43 -06:00
Nathan Hartman
5791bbe17e fs/mqueue/Kconfig: Fix typo
fs/mqueue/Kconfig:

    * config FS_MQUEUE_MPATH:
      Fix typo in name string (queuee -> queue)
2021-01-03 20:28:13 -06:00
Xiang Xiao
38a068b7e6 fs: Move file_close from fs/inode/fs_fileclose.c to fs/vfs/fs_close.c
just like other vfs public functions

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id833da690f88013095fbbe1ea425227f808a5608
2021-01-03 15:45:52 +01:00
Xiang Xiao
5a7d988a43 fs: Remove _files_close and reuse file_close
to save the code space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I08455010ba121a61b0e29334b580aa83e69a9418
2021-01-03 15:45:52 +01:00
Xiang Xiao
cfd7390676 fs: Let files_allocate return -EMFILE instead ERROR
since the internal function normally return the error code directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifccbcfb07d2f8f7d5fef1b2a867538f51b73655c
2021-01-03 11:48:35 +01:00
Xiang Xiao
14a3c35917 fs: Ensure fs_dupfd2 always return fd2 in the sucessful path
it's wrong to return file_dup2 directly since file_dup2 never return file handle

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I943537849c75d83b3d646a6a22f035187d9fd521
2021-01-03 00:03:22 +01:00
Xiang Xiao
63bc3efd25 fs: Remove inode null check from file_dup and fs_dupfd2
since the same check already done in file_dup2

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I7ba1309c55be1ac564f798df02fc6725c4a0d469
2021-01-03 00:03:22 +01:00
Xiang Xiao
0defe43282 OS internal function should indicate the error by return negative value
instead to change errno value by calling set_errno

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-31 09:37:29 +01:00
Brennan Ashton
1473768ffc vfs: Fix unsed label warning
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
2020-12-30 21:20:17 -06:00
ligd
3386941a10 fs: remove INODE_IS_SPECIAL() use others instead
Change-Id: I949f1ad012836e6cb233d5362fe2542732b5ecf4
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-12-30 12:21:02 -06:00
ligd
f5b59e287a fs/vfs: add nx_unlink support
Change-Id: If9009cb7301bb4e49bdce3aea2d56c243256f5a2
Signed-off-by: ligd <liguiding1@xiaomi.com>
2020-12-30 12:21:02 -06:00
chao.an
39146ee367 fs/epoll: add asynchronous epoll control support
In current implementation, the asynchronous call "epoll_ctl()" unable
to wakeup the thread if pending on "epoll_wait()", the newly
added/delete FD cannot be used in the current waiting list,
this patch uses a reserved file object to wake up pending poll internal,
re-traverse the waiting list when a new event comes.

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-27 11:08:12 -06:00
chao.an
0114f7c58f fs/epoll: add sanity check to handle invalid control option
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-27 11:08:12 -06:00
AVykhovanets
39caf09df0 Fix inode lock at umount2 2020-12-26 00:32:19 -06:00
Huang Qi
073912e232 Replace all wget with curl
wget is missing from some system (like macOS and Windows native),
it's better to use curl to simplify build environment.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2020-12-22 03:36:10 -06:00
YAMAMOTO Takashi
1d438bfb9b fs/spiffs/src/spiffs_vfs.c: Fix a comment typo 2020-12-18 06:32:40 -06:00
YAMAMOTO Takashi
b4d68feee9 fs/spiffs/src/spiffs_vfs.c: Fix a typo in a message
"page pages" -> "pages"
2020-12-18 06:32:40 -06:00
Xiang Xiao
29c6f11239 fs: Skip call fs_checkfd if fd < 3 in fs_fdopen
since the stdin, stdout and stderr may initialize later
in userspace if CONFIG_DEV_CONSOLE isn't enabled.
Note: it isn't bigger issue here to skip the check because
vfs will check the validation again in read and write syscall

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-16 07:53:21 +09:00
chao.an
32bf92c5c3 fs/unionfs: remove excessive protection to avoid deadlock
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|#21 0x08049713 in nxtask_start () at task/task_start.c:144
|#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-15 09:50:29 -06:00
Juha Niskanen
cd41ed9b6d fs: fully parenthesize MIN and MAX macros
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-08 12:58:40 -06:00
Matias N
8a9f995d40 procfs: make array const to reduce memory use 2020-12-07 16:55:00 -05:00
YAMAMOTO Takashi
97b86d5848 fs/spiffs/src/spiffs_core.c: Don't assume finfo() is a macro 2020-12-06 09:03:09 -06:00
YAMAMOTO Takashi
45444edc16 fs/nxffs/nxffs_write.c: Fix a syslog format 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
5bead4aa37 fs/nxffs/nxffs_unlink.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
c9d8570040 fs/nxffs/nxffs_reformat.c: Fix a syslog format 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
78356a7df2 fs/nxffs/nxffs_read.c: Fix a syslog format 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
e891e0aaa6 fs/nxffs/nxffs_pack.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
0a99d1396e fs/nxffs/nxffs_open.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
da67e80ca9 fs/nxffs/nxffs_inode.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
d0dd04e24a fs/nxffs/nxffs_inode.c: Appease nxstyle 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
942b1e925d fs/nxffs/nxffs_initialize.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
f6ca8bfe45 fs/nxffs/nxffs_dirent.c: Fix a syslog format 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
75d0077cd1 fs/nxffs/nxffs_blockstats.c: Fix syslog formats 2020-12-05 08:13:32 -06:00
YAMAMOTO Takashi
01e0c41759 fs/nxffs/nxffs_blockstats.c: Appease nxstyle 2020-12-05 08:13:32 -06:00
chao.an
c56785bd0d style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
YAMAMOTO Takashi
cde04a6523 fs/unionfs/fs_unionfs.c: Fix syslog formats 2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
e58a966dd6 fs/binfs/fs_binfs.c: Fix a syslog format 2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
e8695d61ca fs/nfs/nfs_vfsops.c: Fix syslog formats
The following nxstyle errors are not new.
(macros like SIZEOF_rpc_reply_readdir)

fs/nfs/nfs_vfsops.c:848:12: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1020:16: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1420:13: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1818:11: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1819:11: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1830:8: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:1851:42: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:2049:54: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:2115:58: error: Mixed case identifier found
fs/nfs/nfs_vfsops.c:2172:54: error: Mixed case identifier found
2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
73dd8a1ba2 fs/nfs/nfs_util.c: Fix syslog formats
The following nxstyle error is a false positive.
https://github.com/apache/incubator-nuttx/issues/387

fs/nfs/nfs_util.c:70:39: error: C++ style comment
2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
bed9c3b83d fs/nfs/rpc_clnt.c: Fix a syslog format 2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
0a146273bf fs/nfs/rpc_clnt.c: Appease nxstyle
The following nxstyle errors are intentionally left
because they are parts of the copyright notices.

fs/nfs/rpc_clnt.c:46:80: error: Long line found
fs/nfs/rpc_clnt.c:63:78: error: Long line found
2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi
0dee21503d fs/spiffs/src/spiffs_mtd.c: Fix syslog formats 2020-11-24 22:31:33 -08:00
YAMAMOTO Takashi
be013cc338 fs/spiffs/src/spiffs_gc.c: Fix syslog formats 2020-11-24 22:31:33 -08:00
YAMAMOTO Takashi
a6b4c1b755 fs/spiffs/src/spiffs_core.c: Fix syslog formats 2020-11-24 22:31:33 -08:00
YAMAMOTO Takashi
88bc46f4a6 fs/spiffs/src/spiffs_vfs.c: Fix syslog formats 2020-11-24 22:31:33 -08:00
YAMAMOTO Takashi
c0b4076d3b fs/userfs/fs_userfs.c: Fix syslog formats 2020-11-24 22:31:33 -08:00
YAMAMOTO Takashi
4911b1121b fs/cromfs/fs_cromfs.c: Fix a syslog format 2020-11-24 22:31:33 -08:00
Matias N
d5b6ec450f Parallelize depend file generation 2020-11-22 09:02:59 -03:00
YAMAMOTO Takashi
13e55ce0d4 fs/romfs/fs_romfsutil.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
67fbbf935b fs/romfs/fs_romfs.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
ae45a66d70 fs/nxffs/nxffs_write.c: Fix a syslog format 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
d543f7f16f fs/nxffs/nxffs_stat.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
7df9d89d54 fs/nxffs/nxffs_reformat.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
d28d5a29c2 fs/nxffs/nxffs_reformat.c: Appease nxstyle 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
d22c8a2a31 fs/nxffs/nxffs_read.c: Fix a syslog format 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
3f2390e781 fs/nxffs/nxffs_read.c: Appease nxstyle 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
889c33277c fs/nxffs/nxffs_pack.c: Fix a syslog format 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
660db6b248 fs/nxffs/nxffs_pack.c: Appease nxstyle 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
99407f4ab9 fs/nxffs/nxffs_open.c: Fix a syslog format 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
e1a8f8a736 fs/nxffs/nxffs_open.c: Appease nxstyle 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
35c30c2c4a fs/nxffs/nxffs_cache.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
042881eed3 fs/nxffs/nxffs_cache.c: Appease nxstyle 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi
ac6b08c8e9 fs/spiffs/src/spiffs_mtd.c: Fix a syslog format 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
38e6f68535 fs/spiffs/src/spiffs_core.c: Fix a syslog format 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
3aa29095b2 fs/spiffs/src/spiffs_vfs.c: Fix a syslog format 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
f940c3d7a4 fs/fat/fs_fat32util.c: Fix syslog formats 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
8ce63a47fc fs/vfs/fs_epoll.c: Fix syslog formats 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
ad0ee4fbeb fs/binfs/fs_binfs.c: Fix a syslog format error 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
da1b593485 fs/romfs/fs_romfs.c: Fix syslog format errors 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
bc9e28eb35 fs/mmap/fs_mmap.c: Fix a syslog format error 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi
0b48fed6ee fs/spiffs/src/spiffs_core.c: Appease nxstyle 2020-11-20 22:22:53 -08:00
Brennan Ashton
9393572aea Revert "fs/nxffs: Fix scan good block slowly and scan an invalid block"
This reverts commit 97be116a39.

This commit broke nxffs.  This leaves the first block as empty which
then exposes another bug where when the pack is called because we
have reached the end of flash and need to look for deleted inodes
we search the first block find no inode and assume that there
are no more inodes.  This then results in corrupting the filesystem
by writing over existing inodes.

This can be seen by runing the sim:nxffs configuration.
Prior to this commit the first pass of writing files would look like
this:
NXFFS Dump:
  BLOCK:OFFS  TYPE  STATE   LENGTH
      0:5     INODE OK       2680
      0:78    DATA  OK        424
      1:5     DATA  OK        497
      2:5     DATA  OK        497
      3:5     DATA  OK        497
      4:5     DATA  OK        497
      5:5     DATA  OK        268
      5:283   INODE OK       7410
      5:425   DATA  OK         77
      6:5     DATA  OK        497

With this commit:
NXFFS Dump:
  BLOCK:OFFS  TYPE  STATE   LENGTH
      0:0     BLOCK ERASED    512
      1:5     INODE OK       6394
      1:39    DATA  OK        463
      2:5     DATA  OK        497
      3:5     DATA  OK        497

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
2020-11-19 18:08:41 -08:00
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
Xiang Xiao
0e610caec8 fs/procfs: Handle /proc/xxx/group/ correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic9f4c38a3baf199712c5497c094dc7af84deee2c
2020-08-03 21:00:18 +01:00
Xiang Xiao
1bad139f88 fs/romfs: Support the path with tail '/' correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I7ea668e50e68cb384d013349a2c8cfc2844f3b73
2020-08-03 21:00:18 +01:00
spiriou
a4a9eb2f5a fs/vfs: Add file descriptor based events support 2020-07-31 15:09:35 -06:00
Johannes Schock
070f4ed7e9 FAT Filesystem: UTF8 support for long filenames, bugfixes.
New CONFIG_FAT_LFN_UTF8: UTF8 strings are converted to UCS2-LFN
Bugfix in fat_createalias: space is now also converted to underbar.
Change (bugfix) in fat_getlfname: init characters (0xff) and '\0' are rewound as well.
2020-07-31 18:01:02 -03:00
YAMAMOTO Takashi
e22dffba8e fs/mqueue/mq_close.c: Remove a redundant assignment
Found by clang-check:

mqueue/mq_close.c:127:21: warning: Value stored to 'rtcb' during its initialization is never read
  FAR struct tcb_s *rtcb = (FAR struct tcb_s *)nxsched_self();
                    ^~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
2020-07-30 16:16:21 +02:00
YAMAMOTO Takashi
1078210f7f fs/mount/fs_mount.c: Remove a redandunt assignment
Found by clang-check:

mount/fs_mount.c:287:8: warning: Although the value stored to 'ret' is used in
      the enclosing expression, the value is never actually read from 'ret'
      (ret = find_blockdriver(source, mountflags, &drvr_inode)) >= 0)
       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
2020-07-30 08:59:46 +02:00
YAMAMOTO Takashi
dc6b61caf9 fs/romfs/fs_romfs.c: Remove redundant assignments
Found by clang-check:

romfs/fs_romfs.c:431:7: warning: Value stored to 'bytesread' is never read
      bytesread  = 0;
      ^            ~
romfs/fs_romfs.c:455:11: warning: Value stored to 'sector' is never read
          sector    += nsectors;
          ^            ~~~~~~~~
2 warnings generated.
2020-07-30 08:59:46 +02:00
YAMAMOTO Takashi
ba4a7107df fs/hostfs/hostfs.c: Remove a redundant assignment
Found by clang-check:

hostfs/hostfs.c:1081:3: warning: Value stored to 'ret' is never read
  ret = OK; /* Assume success */
  ^     ~~
1 warning generated.
2020-07-30 08:59:46 +02:00
YAMAMOTO Takashi
9dcc6f6da6 fs/driver/fs_blockproxy.c: Fix an error handling
Found by clang-check:

driver/fs_blockproxy.c:202:7: warning: Value stored to 'ret' is never read
      ret = -errno;
      ^     ~~~~~~
1 warning generated.
2020-07-29 21:13:20 -07:00
Xiang Xiao
338244dbac procfs: Get version info from uname instead
unify the version into one place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I988fb40d3f460b0291114c60edb04db3aabb38f1
2020-07-30 10:33:08 +09:00
SPRESENSE
e249a2f82f Makefile: Fix Make.dep not updated by config changes
Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

 1) Add source files by config symbol
 2) Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.
2020-07-28 03:59:45 -05:00
SPRESENSE
89a79b03cf fs/smartfs: Fix file size corruption when opening with overwriting mode
If a existing file is opened with overwriting mode e.g. fopen(file, "w+"),
the file size will be incorrect after writing any data to the file.
This bug is caused by previous commit 10903b5, and its changes should be
limited to only O_APPEND mode.
2020-07-22 04:22:22 -05:00
Dong Heng
97be116a39 fs/nxffs: Fix scan good block slowly and scan an invalid block 2020-07-20 10:23:58 -03:00
Brennan Ashton
3a58926d01 Cast pointer to uintptr prior to ulong for ioctl
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
2020-07-19 15:49:13 -03:00