Commit Graph

2020 Commits

Author SHA1 Message Date
Xiang Xiao
d84aba8a42 fs: Change inode_checkflags to static function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-22 21:23:08 +03:00
Xiang Xiao
b1c8c84e81 stdio: Merge fs_fdopen into fdopen to simplify the code logi
since fs_fdopen could avoid call the kernel specific function now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
Xiang Xiao
62c2b1abba stdio: Initialize stdin, stdout and stderr directly
and then remove group_setupstreams

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
ThomasNS
696717b28b add munmap logic to pseudofs 2023-10-13 03:17:27 +08:00
yinshengkai
ddb87d3b86 clock: replace all up_perf_xx with perf_xx
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-02 16:11:43 +02:00
anjiahao
a2c5cb729a fs:support zipfs,can mount zipfile
we can mount a zipfile in nuttx use mount command like this:

mount -t zipfs -o /data/test.zip /zip

The zipfs is a read only file system,The advantage is that it
does not occupy additional space when reading the decompressed file.

When used, reading and decompression operations are simultaneous.
The known disadvantage is that when using seek to read forward,
it will reopen and cause slow speed problems.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-09-27 01:06:04 +08:00
guohao15
2bce0f404c fs:add syncfs api for sync whole fs data
Signed-off-by: guohao15 <guohao15@xiaomi.com>
2023-09-23 15:58:00 +08:00
wanggang26
40a2adf720 procfs: fix a typo
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-09-21 15:02:27 +03:00
zhengshaobo1
be767dde01 vela fs procfs add clock procfs entry
procfs enrty add clock feature procfs operations

Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-19 10:34:48 +08:00
chao an
5026a96cfa nxstyle: cleanup UTF-8 Unicode to ASCII
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-18 11:54:17 -04:00
Petro Karashchenko
e77ec6c8c6 fs/mqueue: add missing FAR specifier
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Petro Karashchenko
0e42808923 fs/vfs: remove redundant return in nx_vopen
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
xuxin19
e5ee8f7470 Fix error: procfs/fs_procfscritmon.c:184:10: error: variable 'remaining' set but not used [-Werror,-Wunused-but-set-variable]
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-11 20:34:46 +08:00
dongjiuzhu1
6367f2469c fs/vfs: fix dup issue for eventfd/signalfd/timerfd
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-11 19:57:34 +08:00
xuxin19
b1cc5b50b1 cmake:complete missing changes during cmake reforming for fs
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-08 21:20:16 +03:00
dongjiuzhu1
e43194f5ea Revert "rpmsgfs: cache statfs result in case of deadlock"
This reverts commit 572d865034.
2023-09-08 00:58:48 +03:00
chao an
664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
chao an
b60f01a55b inode/i_private: remove all unnecessary cast for i_private
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 08:58:07 +02:00
chao an
7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
wanggang26
3dbface167 Revert commit 35602cc2ef
Reason for revert: when block device enable bch proxy, fsync calling would be failed

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-08-25 20:37:38 +03:00
Ville Juven
a37d094f31 fs/shmfs: Fix illegal usage of void* arithmetics
Fixes build error with -Werror:

shm/shmfs.c: In function 'shmfs_read':
shm/shmfs.c:122:33: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
  122 |       memcpy(buffer, sho->paddr + startpos, nread);
      |                                 ^
shm/shmfs.c: In function 'shmfs_write':
shm/shmfs.c:166:25: error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]
  166 |       memcpy(sho->paddr + startpos, buffer, nwritten);
      |                         ^
cc1: all warnings being treated as errors
2023-08-22 23:33:20 +08:00
yinshengkai
8fa4f2d61d add the startup process tracepoint
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-19 21:50:08 +08:00
chenrun1
709301cbfd hostfs:support SEEK_CUR
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-19 01:48:48 +08:00
wanggang26
d8f316b998 fs/ioctl: add BIOC_BLKGETSIZE cmd to get block sector numbers
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2023-08-19 01:43:59 +08:00
chenrun1
35602cc2ef fs_fsync.c:Fix unknown command message in non-block device situations
This command is called only if the device is a block device or mtd
device.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-18 14:47:27 +08:00
fangxinyong
903e87a7bd builtin: support uid/gid config for binfs app
Implement I_SUID/I_SGID feature for binfs in the POSIX compliant way.
If set-user-ID bit is set in the file permissions, then the effective
user ID of process shall be set to UID of the new process image file.

test case:
hello example emulates to set uid and file set-user-ID bit, and call
geteuid and getegid API.
UID  = 2000
GID  = 3000
MODE = 06555

nsh> ls -l /bin/hello
 -r-sr-sr-x    2000    3000       0 hello
nsh> hello
geteuid:2000
getegid:3000

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-14 01:37:00 +08:00
Petro Karashchenko
4bebf64d6b fs/inode: add missing FAR
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Petro Karashchenko
1b0baa8337 nuttx: use lib_free for memory de-allocation after strdup or asprintf
The memory allocated with strdup and asprintf is done via lib_malloc
so we need to use lib_free to deallocate memory otherwise the assertion
"Free memory from the wrong heap" is hit with flat mode and user separated
heap enabled mode.

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-08 11:58:29 -03:00
Petro Karashchenko
b3d620152e Revert "Don't call lib_free in the kernel code"
This reverts commit 7884c18620.
2023-08-08 11:58:29 -03:00
xucheng5
f1287a9996 fs_open: add ioctl checkflag
fixed open error when driver not implement write

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2023-08-07 01:09:52 -07:00
Xiang Xiao
7884c18620 Don't call lib_free in the kernel code
since kernel just allocate memory from kmm_malloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-08-06 06:51:24 -03:00
Brennan Ashton
46b0f6d6ee fdt: Add initial FDT support and procfs for userspace export
VELAPLATFO-12536

This provides the initial hooks for Flattened Device Tree support
with QEMU RV. It also provides a new procfs file that exposes the
fdt to userspace much like the /sys/firmware/fdt endpoint in Linux.
See https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw

Nodes in the fdt are not yet usable by the OS.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
2023-08-05 12:41:06 -07:00
yinshengkai
a6fcb0a5a9 fs: add pipe type support to inode
Both the device and the pipe used the FSNODEFLAG_TYPE_DRIVER type before,
and now add an independent pipe type

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-05 06:32:50 -07:00
cuiziwei
a0206adcfa nuttx/fs:remove (flags & MAP_PRIVATE) == 0.
NuttX not support MAP_PRIVATE currently.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-04 04:20:06 -07:00
ligd
ea03d06ab3 tmpfs: fix tmpfs_read overwrite after seek over tfo_size
reproduce:
fs = open("tmpfs", xx);
lseek(fd, 256, SEEK_END);  // filep->f_pos = size + 256
read(fd, buf, len);        // overwrite

resolve:
directly return 0 when seek over tfo_size

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-08-03 10:40:28 -07:00
chenrun1
eb0a43f4cf fs_procfsproc:Fix the wrong position of information display, integrate the fd information of socket and file
By left-aligned display, the effect is as follows (0, 1, 2 is fd information, 3 is sd information)

    FD  OFLAGS  TYPE POS       PATH
    0   3       1    0         /dev/console
    1   3       1    0         /dev/console
    2   3       1    0         /dev/console
    3   65      2

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-03 10:33:53 -07:00
chenrun1
9381e929dd procfsproc:Optimize fd information output format
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-08-03 10:33:53 -07:00
yinshengkai
e3c637baf4 fs: procfs add show file typee
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-08-03 10:33:53 -07:00
yangjiao
a543950951 fs/mqueue/mq_open.c: Add the judgment for mq_attr is NULL.
Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
yangjiao
bef756c004 fs/mqueue: Fix the wrong field type in mq_attr as the spec and add the logical judgment to deal with the condition when mq_maxmsg or mq_msgsize is less than zero or equal to zero.
In POSIX standard spec https://pubs.opengroup.org/onlinepubs/7908799/xsh/mqueue.h.html, the field type in mq_attr should be long not size_t. And no logical judgment when mq_maxmsg <= 0 or mq_msgsize <= 0. In this change, i update the field type in mq_attr, and add the missing logical judgment.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
2023-08-03 03:10:56 -07:00
fangxinyong
1adef07a79 fs/shmfs: implement read and write interface
To pass LTP posix case mmap/1-2.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
ea52220509 fs/shmfs: fix inode leak issue
If the shm file is removed and a subsequent close, only release shm
object, but inode is leaked. Should decrease refcount to release inode
when unmapped, that matched with refcount increase when mapped.

Another fix that remove the shm file failed.
nsh> rm /var/shm/pts_mmap_1_2_5
nsh: rm: unlink failed: 6

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
bfeb73e850 fs/tmpfs: fix use after free issue
mmap establish a mapping address space that refer to a tmpfs file,
there are two issues:

1. if the tmpfs file is removed and a subsequent close(), tmpfs_close
will release the backend memory object, use after free errors occur
when operating the mapping memory. We add an extra reference to memory object,
memory will be released when there are no more mappings.

2. if unmap only a portion of the memory, fix the bug that adds another map.
Use realloc and shrink the mapping memory instead.

The fix pass LTP posix case mmap/10-1.c and mmap/12-1.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
43b0421b2a mm/map: limit the count of memory mapping for the task
No memory map count limit that will exhaust memory and cause
the system hang. Also that fix pass LTP posix case mmap/24-1.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
d1825a7acb fs/mmap: only MAP_SHARED mapping need file write permisson
If MAP_PRIVATE is specified, do not change the underlying object,
that is OK to open file with read-only permission. Change to pass:
testcases/open_posix_testsuite/conformance/interfaces/mmap/6-5.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
d892cda167 fs/mmap: fix mmap() wrong errno
As posix spec, mmap() function shall fail with ENODEV if fd refers
to a file whose type is not supported. Change to pass ltp open_posix test:
testcases/open_posix_testsuite/conformance/interfaces/mmap/23-1.c

https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong
5176fb917a fs/vfs: ftruncate produce EINVAL if fd is not open for writing
As posix spec, ftruncate should produce EBADF or EINVAL error,
if the file descriptor fd is not open for writing.

Change the behavior to be similar to Linux and pass ltp open_posix test:
testcases/open_posix_testsuite/conformance/interfaces/shm_open/20-1.c

https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
https://man7.org/linux/man-pages/man2/ftruncate.2.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
Zhe Weng
d563717827 fs/romfs: Fix FIOC_FILEPATH for dup'ed file
The FIOC_FILEPATH ioctl needs rf->rf_path, which is not initialized for
dup'ed romfs file and cause problems.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-02 06:12:25 -07:00
Fotis Panagiotopoulos
0fcf6f2e41 open: Use file mode only when O_CREAT is specified. 2023-08-02 06:08:20 -07:00
hujun5
0b2b5b781c fs: remove sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-08-01 23:15:37 +02:00