Skip to content

Conversation

@kaleidoscope416
Copy link
Contributor

PR Summary

  • Align truncate/ftruncate semantics: reject负长度,要求常规文件,非可写/非可写能力返回EINVAL,O_PATH返回EBADF,超出RLIMIT_FSIZE发送SIGXFSZ并报EFBIG。

  • 移除在 FAT resize 中意外的文件大小限制,恢复正常扩展能力。

Testing

  • gVisor truncate_test(剩余 shm 未挂载导致的打开失败需环境侧解决)。

@github-actions github-actions bot added the Bug fix A bug is fixed in this pull request label Dec 7, 2025
@fslongjin
Copy link
Member

https://github.com/DragonOS-Community/DragonOS/actions/runs/20005297190

这里拉到底有个CR报告。
(至于为啥没comment上来,我得再看看

@kaleidoscope416
Copy link
Contributor Author

https://github.com/DragonOS-Community/DragonOS/actions/runs/20005297190

这里拉到底有个CR报告。 (至于为啥没comment上来,我得再看看

可以

@fslongjin
Copy link
Member

改进空间:

  1. 512 * 1024的缓冲区大小建议使用带文档说明的命名常量,在全局定义
    🐛 潜在缺陷与问题
    关键问题:
  2. 零字节写入静默失败(kernel/src/filesystem/fat/entry.rs:205-209)
    ◦ 当磁盘写入返回0字节时,循环中断但返回包含部分数据的Ok(write_ok)
    ◦ 建议:返回Err(SystemError::EIO)而非静默接受部分写入

次要问题:

  1. 缓冲区大小常量不一致
    ◦ ZERO_BUF_SIZE在多个位置定义(entry.rs:332, fs.rs:1763)
    ◦ 建议:在共享位置统一定义
  2. 整数溢出风险——长度验证检查len > isize::MAX as usize但未检查文件系统特定限制(MAX_FILE_SIZE)

@kaleidoscope416
Copy link
Contributor Author

主线中OpenTest.AppendConcurrentWrite 测试不稳定,有时会失败

[ RUN      ] OpenTest.AppendConcurrentWrite
test/syscalls/linux/open.cc:349: Failure
Expected equality of these values:
  st.st_size
    Which is: 49999
  kThreadCount * kBytesPerThread
    Which is: 50000

https://github.com/DragonOS-Community/DragonOS/blob/master/kernel/src/filesystem/fat/entry.rs#L203
write_at_bytes()不会返回0,不会在loop中死循环,故回退

关键问题:
2. 零字节写入静默失败(kernel/src/filesystem/fat/entry.rs:205-209)
◦ 当磁盘写入返回0字节时,循环中断但返回包含部分数据的Ok(write_ok)
◦ 建议:返回Err(SystemError::EIO)而非静默接受部分写入

@github-actions github-actions bot added the test Unitest/User space test label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants