Commit Graph

1455 Commits

Author SHA1 Message Date
Xiang Xiao
e7c97ce7f0 fs: Merge fs_poll into poll_fdsetup
to avoid the user misuse the wrong funciton

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-23 08:39:48 -03:00
Xiang Xiao
72928cebcf fs/procfs: Avoid the duplicated 0x prefix in pthread cmdline
like this:
... <pthread> 0x0x341de68c
by removing "0x" from format string

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-20 10:11:30 -08:00
Byron Ellacott
9a1b726bae fs: change geometry types from size_t to blkcnt_t and blksize_t
This change reflects that the geometry isn't related to the largest
allocatable unit on the platform.

Calls to read and write block devices are also affected and have
been updated.
2021-02-18 20:38:22 -08:00
YAMAMOTO Takashi
73dde4b63b fs/procfs/fs_procfsmeminfo.c: Allow longer heap names 2021-02-12 03:16:03 -08:00
YAMAMOTO Takashi
929e438052 procfs: Use procfs_register_meminfo for "Kmem" 2021-02-12 03:16:03 -08:00
YAMAMOTO Takashi
c25f4233aa procfs: Use procfs_register_meminfo for "Umem" 2021-02-12 03:16:03 -08:00
YAMAMOTO Takashi
f305cefe82 procfs: Add procfs_register_meminfo
This allows subsystems to register their mallinfo-like functions
to be shown in /proc/meminfo.
2021-02-12 03:16:03 -08:00
Xiang Xiao
280fe41306 fs/eventfd: Convert the indent under EVENT_FD_VFS_PATH option to tab
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5648ca278fccb35010d6c354908b9031930bc5fa
2021-02-05 12:17:47 -03:00
Alin Jerpelea
f9fb182809 Author: Gregory Nutt: update licenses to Apache
Update files from Gregory Nutt to Apache 2.0 license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-05 12:15:56 -03:00
Alin Jerpelea
a544c3f499 fs: nxffs: nxstyle error fix
Fix nxstyle errors to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-05 12:15:56 -03:00
Jiuzhu Dong
13100cf248 fs/readdir: Must reserve a byte for the NUL terminator
Change-Id: I1df0c278d289b90cc54512c0ee256a95549785ca
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-01-26 18:22:35 -08:00
Juha Niskanen
a5ff391bb3 fs/driver: change unlink to nx_unlink to avoid setting errno
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-01-22 17:10:13 +01:00
Juha Niskanen
eaa34b458a fs/driver: update comments about block_proxy()
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-01-22 17:10:13 +01:00
Xiang Xiao
b33d967548 fs/tmpfs: Iterate the entry reversely in readdir
to avoid readdir return the wrong entry in the following code:
void rmdir_recursive(FAR const char *path)
{
  FAR DIR *dir = opendir(path);

  while (1)
    {
      char fullpath[MAX_PATH];
      FAR dirent *ent = readdir(dir);

      if (ent == NULL)
        {
          break;
        }

      sprintf(fullpath, "%s/%s", path, ent->d_name);
      if (DIRENT_ISDIRECTORY(ent->d_type))
        {
          rmdir_recursive(fullpath);
        }
      else
        {
          unlink(fullpath);
        }
    }
}

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ide60fe8db6aada88ad3d8e45367f11599a6f33b1
2021-01-21 15:07:01 -03:00
Xiang Xiao
e49bae1300 fs: Remove fs_dupfd and fs_dupfd2 internal functions
let's call either nx_dup/nx_dup2 or file_dup/file_dup2
instead just like other fs api: xxx->nx_xxx->file_xxx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I1aacfb9e25dc7b3fcb0345ff7b269b1953a01e5b
2021-01-13 16:39:45 +08:00
Xiang Xiao
1e5bfa623a fs: file_dup2 shouldn't hold the file list lock
the argument passed to file_dup2 doesn't always come from task file list
so it doesn't make sense to hold the file list lock and then it is better
to do the protection in the new function files_dupfd2

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ibf02cea9b0b275e7472f9c04fd66b9242285b957
2021-01-13 16:39:45 +08:00
Xiang Xiao
0dc6990166 Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-13 08:57:58 +01:00
Xiang Xiao
0536953ded Kernel module should prefer functions with nx/kmm prefix
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-13 08:57:58 +01:00
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