Skip to content

Conversation

@mistcoversmyeyes
Copy link
Contributor

@mistcoversmyeyes mistcoversmyeyes commented Oct 12, 2025

  • 实现了 SYS_PWRITEV 系统调用
  • 为 SYS_PWRITEV 系统调用添加 C Unit test

Note

Implements SYS_PWRITEV (vectorized positional write) and updates gVisor write test blocklist annotations.

  • VFS Syscalls:
    • sys_pwritev: Add handler SysPwriteVHandle to read user IoVecs, gather buffers, and perform positional writes via do_pwritev -> file.pwrite.
    • Wire into syscall table: add mod sys_pwritev in vfs/syscall/mod.rs and declare_syscall!(SYS_PWRITEV, ...).
  • Tests:
    • Update user/apps/tests/syscall/gvisor/blocklists/write_test with entries/comments for failing write-related cases and kernel error notes.

Written by Cursor Bugbot for commit ff8e812. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings October 12, 2025 03:34
@github-actions github-actions bot added ambiguous The title of PR/issue doesn't match the format enhancement New feature or request labels Oct 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the SYS_PWRITEV system call for vectorized positional writing to files in the VFS (Virtual File System).

  • Implements the SYS_PWRITEV system call that allows writing from multiple buffers to a file at a specified offset
  • Adds comprehensive C unit tests covering basic functionality, edge cases, and error handling
  • Integrates the new system call into the VFS module structure

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
user/apps/c_unitest/test_pwritev.c Complete test suite with 6 test cases covering basic pwritev functionality, EOF scenarios, error handling, and offset preservation
kernel/src/filesystem/vfs/syscall/sys_pwritev.rs Implementation of SysPwriteVHandle struct with system call handling and do_pwritev function
kernel/src/filesystem/vfs/syscall/mod.rs Module declaration to include the new pwritev system call

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sparkzky sparkzky changed the title Feat(vfs): 实现了 SYS_PWRITEV 系统调用 feat(vfs): 实现 SYS_PWRITEV 系统调用 Oct 12, 2025
@github-actions github-actions bot removed the ambiguous The title of PR/issue doesn't match the format label Oct 12, 2025
@sparkzky sparkzky linked an issue Oct 12, 2025 that may be closed by this pull request
@fslongjin
Copy link
Member

要格式化代码

@mistcoversmyeyes mistcoversmyeyes force-pushed the feat/syscall-SYS_PWRITEV branch from 8431715 to d03ccbb Compare October 14, 2025 06:47
@fslongjin
Copy link
Member

看看这俩测例,在有了这个pr之后,能不能通过测试?
blocklist里面删掉他们,然后编译测试套件看看?

https://code.dragonos.org.cn/xref/DragonOS/user/apps/tests/syscall/gvisor/blocklists/write_test?r=7f1a7eff4859f56bb9b91b010ef2af036384b653

测例代码
https://cnb.cool/DragonOS-Community/gvisor/-/tree/dragonos/release-20250616.0/test/syscalls/linux

@mistcoversmyeyes
Copy link
Contributor Author

Ok,预计下周找个时间使用 gVisor测试一下。最近几天有别的事情。

@mistcoversmyeyes
Copy link
Contributor Author

mistcoversmyeyes commented Nov 1, 2025

测试进度

通过 write_test 所有测试

image 在系统根目录下使用 `make test-syscall` 能够通过 write_test

问题

进入 DragonOS gvisor 文件夹手动测试完成,退出测试的时候会出现段错误,表现如下:

/opt/tests/gvisor # ./tests/write_test 
[ WARN ] (src/syscall/mod.rs:391)        SYS_RSEQ has not yet been implemented
[==========] Running 12 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 12 tests from WriteTest
[ RUN      ] WriteTest.WriteNoExceedsRLimit
[       OK ] WriteTest.WriteNoExceedsRLimit (12 ms)
[ RUN      ] WriteTest.WriteExceedsRLimit
[ WARN ] (src/syscall/mod.rs:449)        SYS_RT_SIGTIMEDWAIT has not yet been implemented
[  FAILED  ] WriteTest.WriteExceedsRLimit (28 ms)
[ RUN      ] WriteTest.WriteIncrementOffset
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WriteIncrementOffset (28 ms)
[ RUN      ] WriteTest.WriteIncrementOffsetSeek
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WriteIncrementOffsetSeek (24 ms)
[ RUN      ] WriteTest.WriteIncrementOffsetAppend
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WriteIncrementOffsetAppend (20 ms)
[ RUN      ] WriteTest.WriteIncrementOffsetEOF
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WriteIncrementOffsetEOF (24 ms)
[ RUN      ] WriteTest.PwriteNoChangeOffset
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.PwriteNoChangeOffset (16 ms)
[ RUN      ] WriteTest.WriteWithOpath
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WriteWithOpath (16 ms)
[ RUN      ] WriteTest.WritevWithOpath
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.WritevWithOpath (16 ms)
[ RUN      ] WriteTest.PwriteWithOpath
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[       OK ] WriteTest.PwriteWithOpath (16 ms)
[ RUN      ] WriteTest.PartialWriteSIGSEGV
[ WARN ] (src/filesystem/vfs/open.rs:64)         do_fchmodat: not implemented yet

[ ERROR ] (src/arch/x86_64/mm/fault.rs:319)      vma access error, error_code: (empty), address: 0x95a000
Segmentation fault

@github-actions github-actions bot added the test Unitest/User space test label Nov 1, 2025
@mistcoversmyeyes mistcoversmyeyes force-pushed the feat/syscall-SYS_PWRITEV branch from d03ccbb to cf0ba0e Compare November 1, 2025 08:48
@fslongjin
Copy link
Member

可是,pwritev应该是去看pwritev_test吧

@mistcoversmyeyes
Copy link
Contributor Author

mistcoversmyeyes commented Nov 2, 2025

回复

gvisor 自动测试忘记取消对于以下两个测试的屏蔽,导致在 DragonOS 根目录下运行 make test-syscall 的时候一切正常,但是手动进行测试的时候出现 ERROR

  • WriteTest.PartialWriteSIGSEGV
  • WriteTest.PartialWriteSIGBUS

新的错误定位(简单描述见最新提交)

image image

计划

这两个 Error 都能稳定复现,计划调试内核详细定位问题

  • 理解 DragonOS mm 模块实现方式
  • 调试定位具体错误位置
  • 修复 mm 模块问题

@mistcoversmyeyes mistcoversmyeyes changed the title feat(vfs): 实现 SYS_PWRITEV 系统调用 feat(vfs): 实现 SYS_PWRITEV 系统调用,并修复 mm 模块 pagefault 处理问题 Nov 2, 2025
@github-actions github-actions bot removed the test Unitest/User space test label Nov 2, 2025
@sparkzky
Copy link
Collaborator

sparkzky commented Nov 3, 2025

可以去cnb看看测例内容

@fslongjin
Copy link
Member

这里为什么要改为4gb? 原本的2gb应该是很空余的

@mistcoversmyeyes mistcoversmyeyes force-pushed the feat/syscall-SYS_PWRITEV branch 2 times, most recently from 00881e9 to c9ac35b Compare November 6, 2025 11:29
- WriteTest.PartialWriteSIGSEGV 的报错是 x86_64::mm 模块 pagefault 处理模块引起的。
- WriteTest.PartialWriteSIGBUS 的报错是 mm 模块 pagefault 处理模块引起的。
@mistcoversmyeyes mistcoversmyeyes force-pushed the feat/syscall-SYS_PWRITEV branch from c9ac35b to 7731e07 Compare November 6, 2025 11:30
@mistcoversmyeyes mistcoversmyeyes changed the title feat(vfs): 实现 SYS_PWRITEV 系统调用,并修复 mm 模块 pagefault 处理问题 feat(vfs): 实现 SYS_PWRITEV 系统调用 Nov 6, 2025
@fslongjin fslongjin merged commit d6b2e86 into DragonOS-Community:master Nov 6, 2025
3 checks passed
@mistcoversmyeyes mistcoversmyeyes deleted the feat/syscall-SYS_PWRITEV branch December 2, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 支持pwritev

3 participants