Commit Graph

141 Commits

Author SHA1 Message Date
guohao15 38f0056dcd romfs:extend romfs to enable write part4
add sem for write safe

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 322765b442 fs/romfs: Align up the file size to 16 bytes
and set volume size to 96 bytes in romfs_mkfs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 7814c40a99 fs/romfs: Replace strlcpy and strcmp with memcpy and memcmp
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 4d9512f0d4 fs/romfs: Add romfs_devstrcpy and romfs_devmemcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 808beabc83 fs/romfs: Compute rf_endsector correctly when the file end on the sector boundary
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao cca7b7cb37 fs/romfs: romfs_read return the partail read size instead error code
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 96900845a5 fs/romfs: Change the type of num from uint8_t to uint16_t
to support the directory with more than 255 files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
Xiang Xiao 4ebcc130b9 fs/romfs: Remove the reference to OK and ERROR
and fix the minor style issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 23aef2d7b4 romfs:extend romfs to enable write part3
add romfs_mkfs to support autoformat && forceformat

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 7d8d766018 romfs:bugfix use origoffset instead of offset
origoffset represent the offset of current node
offset represent the offset of the file when
the current node is a soft or hard link

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 3e58620ccc romfs:bugfix romfs_statfs
fix for df cmd infomation of romfs

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 c61734a469 romfs:extend romfs to enable write part2
add sparelist api

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
guohao15 f3840cf141 romfs:extend romfs to enable write part1
change romfs_cachenode to find all headers

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2024-10-11 10:42:20 +08:00
zhangshoukui 10c0d00e6d Fix to compile parameters not taking effect When cmake version is greater than 3.18
https://cmake.org/cmake/help/latest/command/set_source_files_properties.html

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-10-09 18:12:50 +08:00
Xiang Xiao f838987e44 fs/romfs: Call block_operations::close when romfs_bind fail
to avoid the resource leak

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-07 21:10:07 +08:00
anjiahao ee07a269af fs/ioctl:add FIOC_XIPBASE to get file xip address
in tmpfs/romfs, we can get file real xip address to execute program

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-30 18:25:46 +08:00
chenrun1 96206cbf9d fs/xxfs:Replace kmm with fs heap
Summary:
  1.Add configuration to allocate memory from the specified section
  2.Replace all memory operations (kmm_) in the vfs with
    fs_heap_. When FS_HEAPSIZE > 0, memory is requested for the file system by specifying a configured heap location. By default (i.e. FS_HEAPSIZE=0) fs_heap_ is equivalent to kmm_

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-30 16:30:56 +08:00
Shoukui Zhang 175fcb799e add sched note for littlefs/romfs/rpmsgfs
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 15:21:54 -03:00
dongjiuzhu1 d2591380ae Revert "fs/mount and fs/romfs: Add support to mount a ROMFS volume using an MTD driver interface using the standard mount() operation."
This reverts commit 5708a1ac73.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 12:27:40 +08:00
Xiang Xiao 2ab9a848a0 fs/romfs: Move rn_child/rn_count before rn_namesize
which could save 4 bytes for each node

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-01-20 09:27:50 -03:00
yinshengkai 9852428953 fs: procfs add poll support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 19:23:13 -08:00
Xiang Xiao 6783051aed Fix the wrong comment banner
"Private Type"->"Private Types"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-03 17:50:35 +01: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
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
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
wangbowen6 279667a8f5 fs_romfs: avoid the romfs ERROR log when enable FDSAN
Error log:
[    0.003400] [remote] romfs_ioctl: ERROR: Invalid cmd: 783
[    0.003400] [remote] romfs_ioctl: ERROR: Invalid cmd: 782
[    0.003500] [remote] romfs_ioctl: ERROR: Invalid cmd: 783
[    0.003600] [remote] romfs_ioctl: ERROR: Invalid cmd: 782
[    0.042900] [remote] romfs_ioctl: ERROR: Invalid cmd: 783
[    0.043100] [remote] romfs_ioctl: ERROR: Invalid cmd: 782

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-06-17 19:31:17 +08:00
zhanghongyu b723e90356 fs: move memset to upper lever for statfs
if struct statfs add new members, such as f_fsid, no additional code
changes are required.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-06-16 11:10:25 +08:00
Xiang Xiao 08ababd704 fs/vfs: Add a new argument(size_t len) to inode_getpath
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-08 09:57:01 +02:00
Xiang Xiao dd631265c4 fs: Add g_ prefix for all global mountpt_operations instances
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-04-24 16:13:29 +02:00
dongjiuzhu1 f8b27d9fbe fs/mmap: try rammap when filesystem mmap don't support
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-03-10 10:43:33 +02:00
lilei19 38f64f559d change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
Xiang Xiao 7179d57026 fs: Check offset and length more carefully in mmap callback
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 17:43:59 +02:00
Xiang Xiao b0a0ba3ad7 fs: Move mmap callback before truncate in [file|mountpt]_operations
since mmap may exist in block_operations, but truncate may not,
moving mmap beforee truncate could make three struct more compatible

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-04 17:43:59 +02:00
Jukka Laitinen f33dc4df3f Change FIOC_MMAP into file operation call
- Add mmap into file_operations and remove it from ioctl definitions.
- Add mm_map structure definitions to support future unmapping
- Modify all drivers to initialize the operations struct accordingly

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-02 11:23:20 -03:00
Jukka Laitinen 41e9df2f3e Add ftruncate into file operation calls
- Add truncate into file_operations
- Move truncate to be common for mountpt_operations and file_operations
- Modify all drivers to initialize the operations struct accordingly

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-02 11:23:20 -03:00
ligd 11fa70d53a romfs: change lock to recursion lock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 18:04:38 +08:00
anjiahao d7b4e91dda Call nxsem_destroy or nxmutex_destry in the error path
1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-30 13:56:52 +01:00
Jiuzhu Dong d6423b5527 romfs: expand file cache by CONFIG_FS_ROMFS_FCACHE_NSECTORS
The default size of file cache is size of a sector, it may
not be good size for optimizing read/write speed in physical
device. So we can set the config according to speed test profile
to optimize access IO speed.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-24 20:49:09 +08:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Jiuzhu Dong fe17f747a7 fs/directory: move private directory information to filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Jiuzhu Dong 90db4daca9 fs/directory: update readdir interface for all filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Jiuzhu Dong 8a80a853b7 fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-01 12:16:14 +03:00
Jiuzhu Dong ca8ce37433 fs/romfs: fix bug about compare path with same prefix
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-30 09:04:57 +03:00
Petro Karashchenko 989e8ac48f fs/romfs: fix size of pointer during memory allocation
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 10:47:50 +08:00
Jiuzhu Dong a721bc8830 fs/romfs: fix bug about test:examples/romfs
Mounting ROMFS filesystem at target=/usr/local/share with source=/dev/ram1
Traversing directory: /usr/local/share
  DIRECTORY: /usr/local/share/adir/
Traversing directory: /usr/local/share/adir
  FILE: /usr/local/share/adir/anotherfile.txt/
  DIRECTORY: /usr/local/share/adir/subdir/
Traversing directory: /usr/local/share/adir/subdir
  FILE: /usr/local/share/adir/subdir/subdirfile.txt/
Continuing directory: /usr/local/share/adir
  FILE: /usr/local/share/adir/yafile.txt/
Continuing directory: /usr/local/share
  FILE: /usr/local/share/afile.txt/
  FILE: /usr/local/share/hfile/
ERROR: ldir never found
Finished with  1 errors

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-27 14:24:19 +03:00
Jiuzhu Dong 2197fb2b51 fs/romfs: fix read file mismatch when the length of file name is 16
romfs: file name must end with '\0'

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 11:44:27 -03:00
Jiuzhu Dong f677a0d316 romfs: cache romfs entry to improve access file speed
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong bc43206920 fs/romfs: always save linkoffset in romfs_nodeinfo_s
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00
Jiuzhu Dong 07bfa32e87 fs/romfs: get file path by ioctl with FION_FILEPATH
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-01 12:25:19 +08:00