Commit Graph

499 Commits

Author SHA1 Message Date
Petro Karashchenko d445282566 fs/vfs: Add file descriptor based timers support
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-20 04:00:20 -06:00
Xiang Xiao 0896d0680b eventfd: Change mode_semaphore from uint8_t to bool
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 01:41:11 -06:00
Xiang Xiao 76a4ca01a3 eventfd: Change minor type from size_t to unsigned int
to avoid the potential overflow devpath buffer on 64bit platform

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 01:41:11 -06:00
Xiang Xiao 8cb24a2964 eventfd: Fix the typo error
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 01:41:11 -06:00
Xiang Xiao f9c1117c88 eventfd: Remove the unused and private eventfd_get_minor
since it isn't defined by Linux kernel too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 01:41:11 -06:00
Jiuzhu Dong e5f8acab97 ftruncate: sanity check for parameter:length
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-11-01 11:08:03 +01:00
chao.an 6dde42d79b vfs/poll: correct the return event if inode has closed
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-15 12:02:53 +08:00
Alin Jerpelea 151f6eab3c author: Anton D. Kachalov: update licenses to Apache
Anton D. Kachalov has submitted the ICLA
as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-09-01 21:02:34 +08:00
chao.an 9701a678bd net/tcp: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 19:19:05 -07:00
Xiang Xiao 6c61d032db fs: Add utimens and lutimens
https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html
https://www.daemon-systems.org/man/utimens.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-09 17:55:44 -03:00
Xiang Xiao 307cc61893 fs: Add fchstat and chstat callback into mountpt_operations
and implement all status related change function. the individual
file system change will provide in other upcoming patchset.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8fde9db8eba9586e9c8da078b67e020c26623cf4
2021-07-29 06:33:49 -03:00
Jiuzhu Dong 11faf0cb20 fs/inode: add sanity check for inode to avoid nullpointer
Change-Id: Ib2c74ba308b8f15756fac4e69632c296243eb4ab
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-07-25 23:01:37 -07:00
Xiang Xiao 02a6966ad5 fs: mkdir return EEXIST if the path already exist
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie1808697b860974367c17e0ba614ca5cae79f324
2021-07-18 10:25:54 -03:00
Xiang Xiao 663104a2e9 fs: Simplify sendfile implementation
and avoid call nx_ file API in the kernel space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id951ca161df2c2ee267dc4b5a0d7dfa67df4c1e6
2021-07-17 07:39:15 -03:00
Xiang Xiao 2e0901fcaa net: Add file_socket function
and move the socket special process from fstat/nx_vfcntl/ to file_fstat/file_vfcntl

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia10341538488ba3a8444df8e73fb5257b2a1f512
2021-07-17 07:39:15 -03:00
Xiang Xiao a44f62ddf7 fs: should only apply umask to the userspace caller
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I608e3107aaf3d85045958163a742a1ef1107de91
2021-07-17 13:58:58 +09:00
Xiang Xiao a0f2f6c362 fs: Move umask to task_info_s
and implement the related semantic correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I0587341e2c505e41b5e24e55dba039ed200d65f2
2021-07-14 10:35:15 -03:00
Xiang Xiao 0148e1d501 fs: Support the root file system attributes(mode, uid, gid and time)
Note: all attributes is guarded by PSEUDOFS_ATTRIBUTES to save the space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I664d60382e356068fd920f08aca5b4a49d8d92a9
2021-07-14 10:35:15 -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 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
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
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
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
spiriou 0ddefd7c69 fs/vfs/fs_epoll: fix epoll_wait function 2020-08-20 11:49:20 -05: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
spiriou a4a9eb2f5a fs/vfs: Add file descriptor based events support 2020-07-31 15:09:35 -06:00
Xiang Xiao 91ed14c631 vfs/stat: Make the flag defintion more confirm POSIX standard
specified here:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-07 13:41:10 +01:00
Xiang Xiao 651eefc8f7 fs: Rename link to symlink
since the current implementation is really a symoblic link not hard link

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I59d30d0a620b0b5714fe91bbe90d4405cf53d187
2020-07-01 11:58:12 +02:00
Xiang Xiao b598ab43d7 fs: Implement lstat function
specified here:
https://pubs.opengroup.org/onlinepubs/009695399/functions/lstat.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iefc23a02d425ff84fa4027aea7da1181b01eced7
2020-06-30 13:09:58 -06:00
chao.an f56e0e004b fs/setfd: correct the return value
Change-Id: I766f3760e7167a579b73673c44b70847ee06850b
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-06-24 13:48:41 +01:00
Matias Nitsche 8c74a31fe2 vfs: fix support for PTY when CONFIG_NET is not enabled 2020-06-16 09:56:21 +08:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Gregory Nutt 1c002e1049 fs/vfs/fs_fstat: Correct fstat() for proxied block and MTD drivers.
Block and MTD drivers may be opened and managed as though they were character drivers.  But this is really sleight of hand; there is a hidden character driver proxy that mediates the interface to the block and MTD drivers in this case.

fstat(), however, did not account for this.  It would report the characteristics of the proxy character driver, not of the underlying block or MTD driver.

This change corrects that.  fstat now checks if the character driver is such a proxy and, if so, reports the characteristics of the underlying block or MTD driver, not the proxy character driver.
2020-05-28 17:34:09 +01:00
Oleg Evseev 3b75201447 fs/vfs/fs_stat.c: correct style 2020-05-26 16:56:10 +08:00
Oleg dd9d9878ad fs/vfs/fs_stat.c: fill file size for mtd inode
Now when stat() is calling for mtd device it also set size of file as number of bytes of all sectors related to this mtd device.
2020-05-25 13:53:50 -06:00
Oleg e1dbb6b2a9 Update fs/vfs/fs_stat.c
Co-authored-by: patacongo <spudarnia@yahoo.com>
2020-05-25 10:10:52 -06:00
Oleg f6c3296f76 fs/vfs/fs_stat.c: fill file size for block inode 2020-05-25 10:10:52 -06:00
Gregory Nutt 154a87993f fs/vfs/fd_open.c: fs_fdopen() must not set errno
Functions within the OS must never set the errno value.  fs_fdopen() was setting the errno value.  Now, after some parameter changes, it reports errors via a negated errno integer return value as do most all other internal OS functions.
2020-05-23 15:22:09 +08:00
Gregory Nutt a569006fd8 sched/: Make more naming consistent
Rename various functions per the quidelines of https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions

    nxsem_setprotocol -> nxsem_set_protocol
    nxsem_getprotocol -> nxsem_get_protocol
    nxsem_getvalue -> nxsem_get_value
2020-05-17 14:01:00 -03:00
Xiang Xiao 517974787f Rename clock_systime[r|spec] to clock_systime_[ticks|timespec]
follow up the new naming convention:
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-10 14:35:50 -06:00
Gregory Nutt a4218e2144 include/nuttx/sched.h: Make naming of all internal names consistent:
1. Add internal scheduler functions should begin with nxsched_, not sched_
2. Follow the consistent naming patter of https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-09 14:19:08 -03:00
Xiang Xiao 4a3d28a957 fs: Move inode_checkflags from include/nuttx/fs/fs.h to fs/inode/inode.h
since this function is only used inside fs subsystem

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-08 07:20:49 -06:00
Xiang Xiao 6604cdb3f2 fs: Remove all LIBC_IOCTL_VARIADIC related stuff
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-05 08:27:58 -06:00
Xiang Xiao 390f9a5fb7 fs/vfs: Add nx_dup and nx_dup2 function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-04 07:20:02 -06:00
Xiang Xiao 1da8cd6b89 fs/vfs: Add nx_poll function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-04 07:20:02 -06:00
Xiang Xiao 4c680bfadc fs/vfs: Rename fdesc_poll to fs_poll
and reorder the function declaration

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-03 12:15:54 -06:00
Xiang Xiao 4b5360362e fs/vfs: Add nx_ioctl/nx_fcntl function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-03 12:15:54 -06:00
Xiang Xiao 65308eabb4 fs/vfs: Add nx_stat function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-03 12:15:54 -06:00
Xiang Xiao 6418d13b92 fs/vfs: Add nx_close function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-03 12:15:54 -06:00
Xiang Xiao 7980673b59 fs/vfs: Add nx_seek function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-03 12:15:54 -06:00
Xiang Xiao f8a809eb5b Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 10:43:47 -03:00
Xiang Xiao eca7059785 Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 10:43:47 -03:00
YAMAMOTO Takashi 87f2e578ac Fix typos in comments 2020-04-13 09:50:32 -06:00
Gregory Nutt ca2b0a3657 Fix more warnings noted in PR checks
arp/arp_notify.c:132:43: warning: for loop has empty body [-Wempty-body]
           prev = curr, curr = curr->nt_flink);
                                              ^

    sixlowpan/sixlowpan_tcpsend.c:806:31: warning: implicit conversion from 'unsigned int' to 'uint16_t' (aka 'unsigned short') changes value from 4294967295 to 65535 [-Wconstant-conversion]
                                  _SO_TIMEOUT(psock->s_sndtimeo));
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Numerous warnings like:

    ieee802154_getreq.c:93:3: warning: implicit declaration of function 'memcpy' is invalid in C99 [-Wimplicit-function-declaration]
      IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
      ^

    nxfonts/nxfonts_cache.c:839:35: warning: for loop has empty body [-Wempty-body]
               fcache = fcache->flink);

    bluetooth/bluetooth_finddev.c💯11: warning: implicit declaration of function 'memcmp' is invalid in C99 [-Wimplicit-function-declaration]
          if (BLUETOOTH_ADDRCMP(dev->d_mac.radio.nv_addr, match->bf_addr))
              ^

    rwbuffer.c:559:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      if (rwb->rhmaxblocks > 0 && rwb->rhnblocks > 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-04-13 02:09:34 +08:00
Gregory Nutt a4d6af8343 Check return from nxsem_wait_initialize()
Resolution of Issue 619 will require multiple steps, this part of the first step in that resolution:  Every call to nxsem_wait_uninterruptible() must handle the return value from nxsem_wait_uninterruptible properly.  This commit is only for those files under fs/inode.  Utility functions under fs/incode were modified so the changes do extend to other fs/ sub-directories as well.
2020-03-30 01:33:31 +01:00
Gregory Nutt 547a3cb3d9 Run all .c and .h files in previous commits through nxstyle. 2020-03-22 08:24:07 -05:00
Gregory Nutt 7a871e2f29 fs/: Remove support for CONFIG_FS_WRITABLE 2020-03-22 08:24:07 -05:00
Xiang Xiao cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
chao.an d07afc934e fcntl: add O_CLOEXEC/FD_CLOEXEC support 2020-02-20 08:20:38 -06:00
chao.an 58599e8e2e fs/vfs/fs_ioctl.c: Add FIONBIO support 2020-02-19 12:08:08 -06:00
Xiang Xiao 5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
Xiang Xiao 9f9566c0eb Rename net_clone/net_dupsd[2] to psock_dup2/net_dup[2] like vfs 2020-01-31 13:45:14 -06:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Juha Niskanen a762c06ed9 Fix typos and some incorrect comments
Author: Alan Carvalho de Assis <acassis@gmail.com>

    Run nxstyle against .c and .h files and fix it

Author: Juha Niskanen <juha.niskanen@haltian.com>

    Fix typos and some incorrect comments
2020-01-20 09:32:36 -03:00
junmin-kim aad99a5f17 Fix typo in the file_read description (#44)
Signed-off-by: junmin-kim <junmindd.kim@samsung.com>
2020-01-07 07:07:39 -03:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Xinhe Zhou 25b788a9ed fs/vfs/fs_open.c: Fix error in nx_vopen() function. 'va_start' is used in function with fixed args. 'va_start'/'va_end' should not be used in nx_vopen function, because it has fixed arguments. 2019-12-14 07:38:36 -06:00
Junmin Kim e06329f5e7 fs/vfs/fs_open.c: Fix description of nx_open and nx_vopen comments indicate that they return zero on success when, in fact, they return the new file descriptor. 2019-12-12 08:24:14 -06:00
Gregory Nutt d2af57169b tools/nxstyle.c: Fix a rare false alarm that could occur if a variable or function name begins with the sub-string 'union' or 'struct'. misc fixes under fs/ and sched/ from application of current version of nxstyle. 2019-12-01 13:01:16 -06:00
Juha Niskanen a085a0a70b fs/smartfs/smartfs_smart.c: Honor O_APPEND on writes. Also document pwrite() bug/limitation. 2019-11-05 07:32:23 -06:00
Gregory Nutt bd3cc792ff fs/: Run all .c files under fs/ through tools/nxstyle. 2019-10-27 11:48:14 -06:00
Nathan Hartman 46aaec7ba0 Fix minor typos in docs and comments. 2019-09-29 12:52:20 -06:00
Juha Niskanen e8b5dd4528 Fix use of undefined pp-token #errror, other typos. 2019-09-19 18:19:18 -06:00
Dave Marples 5179fa9a64 drivers/serial/serial.c: Limit the number of times that the poll semaphore is incrmented. 2019-06-13 16:23:04 -06:00
Gregory Nutt ee9e8c6bc2 udp\udp_callback.c: Fix another C89 compatibility problem. Empty initializers are not permitted. Caused ez80 build failure. 2019-06-03 09:23:19 -06:00
Gregory Nutt b49be4bb20 Squashed commit of the following:
arch/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    sched/ audio/ crypto/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    Documentation/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    fs/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    graphics/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    net/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    drivers/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    include/, syscall/, wireless/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    configs/:  Remove all references to CONFIG_DISABLE_POLL.  Standard POSIX poll can no longer be disabled.
2019-05-21 18:57:54 -06:00
Gregory Nutt be3dd0bac6 fs/: Fix various coding standard issues found while testing tools/nxstyle.c 2019-03-01 15:01:04 -06:00
Gregory Nutt b5e6af60ac tools/nxstyle.c: Add check for multiple definitions of local variables on a line. 2019-02-14 18:33:23 -06:00
Gregory Nutt efe65749ce Fix condition logic: The setup seems to support a network without sockets. That is not the case.
Squashed commit of the following:

    sched/sched/sched_getsockets.c:  Fix an error in conditional compilation.
    fs/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    Documentation/:  Remove all references to CONFIG_NSOCKET_DESCRIPTORS == 0
    include/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    libs/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    net/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    sched/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    syscall/:  Remove all conditional logic based on CONFIG_NSOCKET_DESCRIPTORS == 0
    tools/:  Fixups for CONFIG_NSOCKET_DESCRIPTORS no longer used to disable sockets.
2019-02-11 15:47:25 -06:00
Gregory Nutt a64869aa67 CONFIG_NFILE_DESCRIPTORS=0 can no longer be used to disable the file system. NuttX with no file system does not make sense.
Squashed commit of the following:

    configs/:  The few configurations that formerly set CONFIG_NFILE_DESCRIPTORS=0 should not default, rather they should set the number of descriptors to 3.
    fs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    tools/:  Tools updates for changes to usage of CONFIG_NFILE_DESCRIPTORS.
    syscall/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    libs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    include/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    drivers/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    Documentation/:  Remove all references to CONFIG_NFILE_DESCRIPTORS == 0
    binfmt/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    arch/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    net/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/Kconfig:  CONFIG_NFILE_DESCRIPTORS may no longer to set to a value less than 3
    configs/:  Remove all settings for CONFIG_NFILE_DESCRIPTORS < 3
2019-02-11 12:09:26 -06:00
David Sidrane ffd37a0175 fs/vfs/fs_open.c: Fix not returning failure for block_proxy() call. 2019-01-25 06:23:34 -06:00
Gregory Nutt 0cd5a232ea Fix a few typos. 2018-12-27 08:45:26 -06:00
David Sidrane 010d5da4e6 fs/vfs: dup() and dup2() were broken some time back. fs_dupfd() was return returing OK on success, not fit the file descriptor of the duplicated fd. 2018-12-10 13:25:52 -06:00
Xiang Xiao d2cfd398ba Fix compiler error and warning when CONFIG_NET_SENDFILE=y 2018-11-09 11:17:43 -06:00
Xiang Xiao e674edfa19 fd/dirent, fs/driver/, and fs/vfs: Make MTD device accessible via a character driver proxy like block devices 2018-11-08 09:59:18 -06:00
Gregory Nutt 706b20a49f fs/vfs/fs_read.c: Elimnate a warning noted by Anonymouns in Issue 124. 2018-10-12 14:58:21 -06:00
Gregory Nutt 913d013d8f Revert last change to the TODO list. There is no issue. 2018-09-19 12:15:04 -06:00
Gregory Nutt a7fd58c4db Squashed commit of the following:
many locations:  Change occurences of open() followed by file_detach() to file_open().  Change most non-controversion calls to open() to nx_open().

    fs/inode/fs_fileopen.c:  Flesh out file_open() with some interim, placeholder logic.

    fs/inode/fs_fileopen.c:  Add a framework for a file_open() implementation (no real logic in place yet).

    fs/vfs/fs_open.c:  Add nx_open() which is the same as open() except that it does not create a cancellation point nor does it modify the errno variable.
2018-09-15 10:49:41 -06:00
Gregory Nutt d88cb93d95 fs/vfs and fs/inode: Trivial typo fixes gleaned from the fileopen branch. 2018-08-29 16:01:56 -06:00
Gregory Nutt 05faba2514 include/nuttx/fs/fs.h: ... conflicting types for file_fstat(). 2018-08-26 16:13:09 -06:00
dongjianli 56883eef3b fs/vfs/fs_poll.c: Add poll use in kernel space. 2018-08-26 13:44:07 -06:00
Xiang Xiao 3f50451046 fs/vfs/fs_fcntl.c, net/socket/net_dupsd.c, and net/socket/net_vfcntl.c: Add file_fcntl, psock_fcntl, and psock_dupsd for use within the kernel. 2018-08-26 13:31:18 -06:00
ligd aa52c457cc fs/vfs/fs_fstat.c: Add file_fstat() function for internal OS use. 2018-08-26 13:26:37 -06:00
anchao 6361f93fda fs/vfs/fs_select.c: Make select be more consistent with Linux man page: 'The timeout
... Some code calls select() with all three sets empty, nfds zero, and a non-NULL timeout as a fairly portable way to sleep with subsecond precision.'
2018-08-26 13:19:28 -06:00
Gregory Nutt 8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Gregory Nutt f5d0fc7447 fs/vfs and net/udp: Repartition logic of commit 0c963449d6, moving into net/udp. Add support to handle connected UDP sockets. The correct 'optimal blksize' to return is the MSS. The MTU is always too big. 2018-04-27 08:36:25 -06:00
Pelle Windestam 0c963449d6 fs/vfs: Added support for checking if a descriptor is a socket in fstat(). 2018-04-26 06:49:13 -06:00
Michał Łyszczek 94b4a86aa6 fs/vfs: Fix negative errno set in fs_open.c 2018-04-20 17:05:42 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt 885ab75045 drivers/lcd: Add support for creating display lists incrementally. 2018-02-17 14:48:18 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt 39fe6a0dff Squashed commit of the following:
fs/nxffs:  Add partial implementation of the truncate method:  It extend files, but cannot yet shrink them.
    fs/smartfs:  Add partial implementation of the truncate method:  It extend files, but cannot yet shrink them.
    fs/fat:  Add partial implementation of the truncate method:  It extend files, but no yet shrink them.
    fs/nfs:  Add support for the truncate method to the NFS file system.
2018-01-04 10:54:54 -06:00
Gregory Nutt e4652bd3dc Squashed commit of the following:
fs: Add truncate() support for userfs
    fs/unionfs:  Add truncate() support to the unionfs
    fs/tmpfs:  Add ftruncate() support to tmpfs
    syscall/: Add system call support for ftruncate()
    net/route:  Adding ftruncate() support eliminates an issue in file-based routing table management.
    fs:  Add basic framework to support truncate() and ftruncate().  The infrastructure is complete.  Now, however, the actual implementation of ftruncate() will have to be done for each file system.
2018-01-03 16:03:56 -06:00
Gregory Nutt cc09e77a94 fs/vfs: Fix after recent changes. write() was return negative values in errno. Noted by Jussi Kivilinna. 2017-10-18 10:17:55 -06:00
Gregory Nutt 181875f3ba fs/vfs: Add new internal OS interface nx_read(). nx_read() is functionally equivalent to read() except that it does not modify the errno variable and it is not a cancellation point. Changed all references to read() in the OS to nx_read(). 2017-10-11 12:13:41 -06:00
Gregory Nutt a00d8e16a1 Adds OS internal function nx_write() which is functionally equivalent to write() except that it does not set the errno variable and do not cause cancellation points. 2017-10-11 10:18:30 -06:00
Gregory Nutt af072d52bc Adds OS internal functions nx_send(), ns_recv(), and nx_recvfrom() which are functionally equivalent to send(), recv(), and recvfrom() except that they do not set the errno variable and do not cause cancellation points. 2017-10-11 09:25:43 -06:00
Gregory Nutt 536e4d7fa6 fs/vfs: Change the return value of internal function fs_getfilep(). It no longer sets the errno variable but, rather, returns errors in the same manner as other internal OS functions. 2017-10-11 08:39:19 -06:00
Gregory Nutt aeb3944f0a fs/vfs and net/socket: fcntl() is not return success fail for F_SETFL. Reported by Jussi Kivilinna. 2017-10-06 08:27:38 -06:00
Gregory Nutt 9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Gregory Nutt 9232da4af8 fs/vfs: Remove warning generated by fcntl() 2017-10-02 14:04:50 -06:00
Gregory Nutt e4dd33280d Squashed commit of the following:
psock_close() and net_close() are internal OS functions and should not set the errno variable.

    psock_ioctl() and netdev_ioctl() are internal OS functions and should not set the errno variable.

    net_dupsd() and net_dupsd2() are internal OS functions and should not set the errno variable.

    net/ and fs/: net_vfcntl(), file_fcntl(), file_dup(), and file_dup2() are all internal OS interfaces and should not modify the errno value.
2017-09-30 10:41:21 -06:00
Xiao Qin e5c79ba1a6 Merged in x_qin/nuttx/null_check_for_open_and_write (pull request #498)
fs/vfs:null check for path on open and buf on write

Null path check is depend on CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_ASSERTIONS, added null checking so it's always performed
Added null checking on buf for write()

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2017-09-29 18:15:33 +00:00
Gregory Nutt 44d88abb83 This commit adds support for routing tables in files in a file system. This might be useful for customized, per-unit routing tables.
There are two issues with it however:

1. Reading from file system on a per packet basis could be slow.  I think it probably should have a small, in-memory cache of most frequently used routes for good problem.

2. Currently the delroute logic is disabled due to a problem with the design.  NuttX does not currently support truncate().  Therefore, it is not possible to delete entries from the routing table file.

In this current implementation, that leaves the last entry intact at the end of the file.  An alternative design might include a tag on each record to indicate if the record is valid or not.  That would work but would add complexity to the other routing table functions.

The existing implementation is available for testing purposes only if CONFIG_EXPERIMENTAL=y.

Squashed commit of the following:

    net/route:  The current delroute design depends on file truncation.  However, NuttX does not currently support truncate.  Alternative, more complex designs are possible but not implemented.  At present the file routing table are otherwise functional but the delroute logic is disabled via CONFIG_EXPERIMENTAL.  Enable it only if you plan to fix it.

    net/route:  Fix some issues with locking routing table files.

    net/route:  Add partial implementation of delroute for the case where the routing table is in a file.

    net/route:  Add support for seeking to positions in the routing table.

    net/route: Add net_addroute_ipv4/6() using a file-based routing table.

    net/route: Add net_foreach_ipv4/4() using a file-based routing table.

    net/route:  Initial build, configuration, and fs utilies to support routing tables in a file.
2017-09-29 08:33:36 -06:00
Gregory Nutt 7b7ca87941 fs/vfs: file_write() and file_pwrite() are internal OS interfaces and should not report errors via the errno 2017-09-28 14:49:05 -06:00
Gregory Nutt e761b80ea7 fs/vfs: file_read() is an internal OS interface and should not errors via the errno 2017-09-28 14:14:32 -06:00
Gregory Nutt 9043b9cb6a fs/vfs: file_seek() is an internal OS interface and should not errors via the errno 2017-09-28 13:55:36 -06:00
Gregory Nutt 12c4c4c8a6 In some cases, packets are still not sent behind the router. I found that NuttX sends the ARP requests not to the router but to the target. Mistake in file net/route/netdev_router.c. From Aleksandr Kazantsev 2017-09-20 13:19:05 -06:00
Jussi Kivilinna 027a446158 poll: fix poll for regular files and block devices. Open Group documentation tells that poll (and select) support regular files and that 'Regular files shall always poll TRUE for reading and writing'. 2017-08-03 09:58:20 -06:00
Simon Piriou 643f5782aa epoll: fix epoll_wait function 2017-07-22 09:01:24 -06:00
Julien Lecoeur f26e83d0a1 Fix -Werror=implicit-fallthrough on gcc7 2017-06-28 17:48:04 +02:00
Jim Paris db80696d21 vfs/poll: fix timeout calculation 2017-06-09 11:37:30 -06:00
Harri Luhtala b8b9309d2b vfs: fdopen: add missing file stream flags clearing. Clear file stream structure regardless of config options. Structure clearing is needed as previous use of stream list entry might leave fs_flags set. 2017-05-31 06:20:18 -06:00
Gregory Nutt 41680d376d Replace 'the the' with 'the' 2017-05-11 13:15:13 -06:00
Gregory Nutt e3d865f6c2 In last changed to poll(),cConverted timeout to unsigned to eliminate the possibility of overflow of signed overflow. 2017-04-28 11:02:54 -06:00
Jussi Kivilinna 37ca797d1c vfs/poll: round timeout up to next full tick. Calling poll() with timeout less than half tick (thus MSEC2TICK(timeout) => 0) caused returning error with EAGAIN. Instead of rounding timeout down, value should be rounded up. Open Group spec for poll says: "Implementations may place limitations on the granularity of timeout intervals. If the requested timeout interval requires a finer granularity than the implementation supports, the actual timeout interval will be rounded up to the next supported value." 2017-04-28 08:42:37 -06:00
Gregory Nutt d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Gregory Nutt 7457875447 VFS poll(): Add some error handling logic 2017-04-20 19:15:17 -06:00
Gregory Nutt d3408809e4 sendfile(): Fix error introduced with commit ff73be870e. Noted by Maciej Wójcik 2017-03-05 11:50:34 -06:00
Gregory Nutt ee8abb8160 FS: Don't build block driver proxy if PSEUDOFS_OPERATIONS are disabled. 2017-03-04 08:25:20 -06:00
Gregory Nutt 0a192361de Revert "FS: Fix backward conditional logic that prevent unlink() from building in some configurations."
Oops.  It was not backward.  Enable == !Disable.  Negative logic is confusing.

This reverts commit 1fcf353e89.
2017-03-04 08:16:46 -06:00
Gregory Nutt 1fcf353e89 FS: Fix backward conditional logic that prevent unlink() from building in some configurations. 2017-03-04 07:48:56 -06:00
Masayuki Ishikawa e239961be8 Fix open() a block device with CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y 2017-03-01 13:43:12 +09:00
Gregory Nutt 4fa389898a Fix a warning when STDIO buffering is disabled 2017-02-27 11:06:13 -06:00
Gregory Nutt a78593d66d fstatfs: Rethink last commit. Add verification that the file descriptor refers to an open file. This also should eliminate the warning while doing something useful. 2017-02-22 14:17:14 -06:00
Gregory Nutt 8c7ec7419a Eliminate a warning 2017-02-22 14:04:06 -06:00
Gregory Nutt 656935ed7e C library: Add fstatfs(); fix a reference counting error in fstat(). 2017-02-17 08:35:59 -06:00
Gregory Nutt 2325ea4a45 statfs() should not fail on path '/' 2017-02-14 06:30:35 -06:00
Gregory Nutt 10378bb10b fstat: Add fstat() support to nfs. 2017-02-13 10:07:43 -06:00
Gregory Nutt 4748e9352d fstat: Add fstat() support to romfs 2017-02-12 16:25:12 -06:00
Gregory Nutt c5a8e96dbc Add basic fstat() support. Now all that is needed is to modify ALL of the file systems. 2017-02-12 12:48:24 -06:00
Gregory Nutt 3055025e00 rename(): Correct more issues. (1) Move to the root directory in the pseudo file system, (2) Fix path naming calculation when the path is the root directory of a mounted file system, and (3) dont't do the rename if the source and destination of the rename are the same. 2017-02-12 08:37:28 -06:00
Gregory Nutt e20e9f0fe4 Update a comment 2017-02-11 18:55:13 -06:00
Gregory Nutt 2d11d8f1a4 rename: An inode with no operations should be treated like a directory for the purposes of rename 2017-02-11 12:02:50 -06:00
Gregory Nutt bd7d3a92f5 Add logic to VFS rename: If target of rename exists and is a directory, then the source file should be moved 'under' the target directory. POSIX also requires that if the target is a file, then that old file must be deleted. 2017-02-11 11:18:30 -06:00
Gregory Nutt af5a8e73d3 VFS rename: Fix issues with rename to subdirectories and some softlink issues. 2017-02-11 10:08:23 -06:00
Gregory Nutt 1d290c2b37 setvbuf: Add support for disabling I/O buffering. Initially cut; untested. 2017-02-09 09:24:44 -06:00
Gregory Nutt a92887c63d setvbuf: Correct some errors detected by code review. 2017-02-08 14:06:29 -06:00
Gregory Nutt 9f859774a1 setvbuf: Add support for configuration of line buffering. 2017-02-08 11:28:24 -06:00
Gregory Nutt 51a14c9b2f C Library: Add a very limited, first step implementation of setvbuf(). This is a collaborative effort. Alan Carvalho de Assis did the initial prototype. 2017-02-08 10:33:18 -06:00
Gregory Nutt 2d2fe301cb Update some comments; link counter can be uint8_t; Add a debug assertion. 2017-02-07 15:50:54 -06:00
Gregory Nutt b758176963 stat(): Add logic to avoid infinite recursive in circular paths containing soft links. 2017-02-07 12:32:45 -06:00
Gregory Nutt aefe32d33f soft links: Fix a memory leak by correcting a reference counting problem. 2017-02-05 15:14:16 -06:00
Gregory Nutt 45fd98da88 Add macros support that will eventually allow dynamic allocation of strings need to support soft links. 2017-02-05 14:25:45 -06:00
Gregory Nutt 8f2c7198ed inode_find: Now takes struct inode_desc_s type as input. This was necessary before that structure includes some data storage. It was used within inode_find(), but that means that the life of the data was the life of inode_find(). That data must persist longer. It is now provided by the caller so that the life of the data persists for the entire life of the caller. 2017-02-05 09:51:42 -06:00
Gregory Nutt 0c9935f8ac FS: Remove inode_find_nofollow. Instead provide a bool nofollow argument to inode_find. 2017-02-04 11:46:54 -06:00
Gregory Nutt 36704b7d9c FS: Argument is now a structure describing the search. 2017-02-04 11:21:44 -06:00
Gregory Nutt 70dcec7df7 readlink: Fix bugs from initial testing 2017-02-03 14:12:24 -06:00
Gregory Nutt 4417e74977 Soft links: Add an (untested) implementation of readlink() 2017-02-03 13:57:12 -06:00
Gregory Nutt 60ba5a5261 Soft links: Fix logic and remove kludge of last commit. Rename inode_dereference() as inode_linktarget() and make global. 2017-02-03 13:22:33 -06:00
Gregory Nutt 7c59e05305 FS: Separate inode_search() and inode_free() from fs_inode.c and put in separate files. Flesh out symbolic link logic in stat() and readdir(). There are still some issues with stat(). 2017-02-03 11:23:57 -06:00
Gregory Nutt 372e399bbc Fix a typo 2017-02-03 07:36:25 -06:00
Gregory Nutt b39d962021 Soft links: Update Documentation, rename file, add system calls 2017-02-02 17:11:08 -06:00
Gregory Nutt 35d738d85f Soft links: Fix compile problems on first build with soft links enabled. 2017-02-02 15:24:39 -06:00
Gregory Nutt bdc002fadc Finish implementation of soft links. 2017-02-02 13:01:21 -06:00
Gregory Nutt 92305e400a Soft links: Initial, incompete implementation 2017-02-02 10:39:41 -06:00
Gregory Nutt b52e4e5ecd Move cancellation point definitions to their own header file. 2016-12-10 09:08:26 -06:00
Gregory Nutt bc3ca25cc7 Cancellation points: Close up some logic to eliminte some race conditions. 2016-12-10 08:36:58 -06:00
Gregory Nutt 03a58b2ebc write(): Fix a misplaced #endif 2016-12-09 18:12:42 -06:00
Gregory Nutt 05f61def6a Fix warning and link error due to missing header file. 2016-12-09 17:02:27 -06:00
Gregory Nutt 3eba0acb1c More cancellation points. 2016-12-09 13:49:36 -06:00
Gregory Nutt c9ca97b4b5 cancellation points are basically function. More tested is needed and additional cancellation points must be implemented before this can be merged back to master. 2016-12-09 12:01:18 -06:00
Gregory Nutt dbbe46a2bc fs: Disable priority inheritance on all semaphores used for signaling 2016-11-03 12:23:31 -06:00
Alan Carvalho de Assis 8fa14b8fed Fix poll-related compile issues introduced with recent PTY changes 2016-07-16 07:03:38 -06:00
Gregory Nutt 11fe9378df Fix some warnings 2016-07-16 07:02:06 -06:00
Gregory Nutt bcb6095f1f Add an assertion 2016-07-15 17:47:00 -06:00
Gregory Nutt 6a75f2df89 PTY: Add some encode to reduce the likely of misinterpreting the return value of the file open() method 2016-07-15 17:13:21 -06:00
Gregory Nutt 4b1553d3ad PTY: Fix some tricky issues. Now seems to be working. A lot more testing is needed 2016-07-15 14:29:32 -06:00
Gregory Nutt 9ecd558002 Add the correct implementation of the file_poll() function 2016-07-15 11:34:08 -06:00
Gregory Nutt 6e6c04f778 Rename file_poll as fdesc_poll. The file_ namespace is used for other things. 2016-07-15 11:21:11 -06:00
Gregory Nutt 2689645b97 VFS ioctl() again. Per comments from David Sidrane, file_ioctl() should not return success if the ioctl method is not supported. It probably should return ENOTTY in that case. 2016-07-09 07:23:12 -06:00
Sagitta Li 1925df8faa Fix some recently introduced errors 2016-07-09 06:51:07 -06:00
Gregory Nutt 02b91d9880 Add a SYSLOG character device that can be used to re-direct output to the SYSLOG 2016-07-05 12:58:18 -06:00
Gregory Nutt a39ce80add SYSLOG logic should use existing file interfaces, not re-invent them. 2016-07-05 12:12:44 -06:00
Gregory Nutt ad2f7b0119 fs/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 17:14:02 -06:00
Gregory Nutt a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt 86b79b33cf Reserver the name 'err' for other purposes 2016-06-11 14:40:07 -06:00
Gregory Nutt fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt 001715d57b FS: Add logic to detach a file structure from a file descriptor. This is for use only within the OS. It permits an open file or driver to be used across multiple threads. 2016-05-26 09:41:50 -06:00
Gregory Nutt aa7a981674 Update some comments 2016-05-26 08:37:40 -06:00