bugfix: OFD:FLAGS
This commit is contained in:
@@ -40,16 +40,12 @@ lseek(int fd, off_t offset, int whence)
|
||||
|
||||
zvfs_ensure_init();
|
||||
|
||||
/*
|
||||
* O_APPEND fd 的 lseek:POSIX 允许 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user