Commit Graph

281 Commits

Author SHA1 Message Date
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
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
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
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
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
wangshuo
cb54c838a0 vfs: adjust the error code of write to be consistent with read
According to POSIX, the EACCES will be set when file can not be
written access. Just like fs_read
2021-04-08 21:52:14 -05:00
chao.an
4abf8e6587 fs/epoll: correct the return value of epoll_ctl(2)
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-23 00:28:18 -07:00
Jiuzhu Dong
e96c8b9283 fs: allocate file/socket dynamically
Change-Id: I8aea63eaf0275f47f21fc8d5482b51ffecd5c906
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-17 06:46:42 -07:00
YAMAMOTO Takashi
5652de3fdf fs: try blockproxy only if BCH is enabled 2021-03-17 01:25:16 -07:00
buyuer
3b23f3f0b8 vfs/epoll: Fix one bug of EPOLL_CTL_DEL.
N/A

Signed-off-by: buyuer <dingddding@163.com>
2021-03-13 10:55:41 -08:00
buyuer
c0f9c7b48c vfs: Fix epoll cannot work under 64-bit operating system
by switching to the real file handle

Signed-off-by: buyuer <dingddding@163.com>
2021-03-13 10:55:41 -08:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
ligd
48d49e5a7c mqueue: add poll support
Change-Id: I7e908f6a6c00158c0946587dd79ae3dc5d279d37
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-04 07:11:43 -08:00
Jiuzhu Dong
4d5a964f29 net: unify socket into file descriptor
Change-Id: I9bcd21564e6c97d3edbb38aed1748c114160ea36
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-03 19:01:41 -08:00
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
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
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
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
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
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
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
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
YAMAMOTO Takashi
8ce63a47fc fs/vfs/fs_epoll.c: Fix syslog formats 2020-11-20 22:22: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
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
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