bugfix: OFD:FLAGS

This commit is contained in:
2026-04-14 07:40:56 +00:00
parent ea64511f95
commit 15d6a90e2f
19 changed files with 1030 additions and 160 deletions

View File

@@ -40,16 +40,12 @@ lseek(int fd, off_t offset, int whence)
zvfs_ensure_init();
/*
* O_APPEND fd 的 lseekPOSIX 允许 lseek但下次 write 时
* 仍会从文件末尾写。lseek 只影响 read 的位置。
* 我们照常更新 of->offset。
*/
pthread_mutex_lock(&of->inode->mu); /* SEEK_END 需读 logical_size */
uint64_t new_off = openfile_seek(of, (int64_t)offset, whence);
pthread_mutex_lock(&of->inode->mu);
uint64_t logical_size = of->inode->logical_size;
pthread_mutex_unlock(&of->inode->mu);
if (new_off == (uint64_t)-1) {
uint64_t new_off = 0;
if (blob_seek(of->handle_id, (int64_t)offset, whence, logical_size, &new_off) != 0) {
ZVFS_HOOK_LEAVE();
return (off_t)-1;
}
@@ -104,7 +100,7 @@ zvfs_truncate_inode_with_handle(struct zvfs_inode *inode,
* 这种情况下 truncate(path, ...) 被调用但文件没有 fd。
*/
uint64_t temp_handle_id = 0;
if (blob_open(inode->blob_id, &temp_handle_id) < 0) {
if (blob_open(inode->blob_id, O_RDWR, &temp_handle_id) < 0) {
errno = EIO;
return -1;
}