bugfix: OFD:FLAGS
This commit is contained in:
@@ -241,7 +241,7 @@ zvfs_open_impl(int real_fd, const char *abspath, int flags, mode_t mode)
|
||||
/* ---- 创建路径 -------------------------------------------- */
|
||||
|
||||
/* 1. 创建 blob */
|
||||
if (blob_create(0, &blob_id, &handle_id) != 0) {
|
||||
if (blob_create(0, flags, &blob_id, &handle_id) != 0) {
|
||||
int saved = errno;
|
||||
if (saved == 0) saved = EIO;
|
||||
fprintf(stderr,
|
||||
@@ -311,7 +311,7 @@ zvfs_open_impl(int real_fd, const char *abspath, int flags, mode_t mode)
|
||||
(unsigned long)inode->blob_id);
|
||||
/* path_cache 命中:直接用缓存的 inode,重新 blob_open */
|
||||
blob_id = inode->blob_id;
|
||||
if (blob_open(blob_id, &handle_id) != 0) {
|
||||
if (blob_open(blob_id, flags, &handle_id) != 0) {
|
||||
if (errno == 0) errno = EIO;
|
||||
zvfs_debug_open_log(abspath, NULL,
|
||||
"open existing path_cache-hit blob_open fail errno=%d(%s)",
|
||||
@@ -344,7 +344,7 @@ zvfs_open_impl(int real_fd, const char *abspath, int flags, mode_t mode)
|
||||
zvfs_debug_open_log(abspath, NULL,
|
||||
"open existing inode_table hit blob_id=%lu",
|
||||
(unsigned long)blob_id);
|
||||
if (blob_open(blob_id, &handle_id) != 0) {
|
||||
if (blob_open(blob_id, flags, &handle_id) != 0) {
|
||||
if (errno == 0) errno = EIO;
|
||||
zvfs_debug_open_log(abspath, NULL,
|
||||
"open existing inode_table-hit blob_open fail errno=%d(%s)",
|
||||
@@ -381,7 +381,7 @@ zvfs_open_impl(int real_fd, const char *abspath, int flags, mode_t mode)
|
||||
pthread_mutex_lock(&g_fs.path_mu);
|
||||
path_cache_insert(abspath, inode);
|
||||
pthread_mutex_unlock(&g_fs.path_mu);
|
||||
if (blob_open(blob_id, &handle_id) != 0) {
|
||||
if (blob_open(blob_id, flags, &handle_id) != 0) {
|
||||
if (errno == 0) errno = EIO;
|
||||
zvfs_debug_open_log(abspath, NULL,
|
||||
"open existing new-inode blob_open fail errno=%d(%s)",
|
||||
@@ -397,7 +397,7 @@ zvfs_open_impl(int real_fd, const char *abspath, int flags, mode_t mode)
|
||||
}
|
||||
|
||||
/* ---- 分配 openfile,插入 fd_table ---------------------------- */
|
||||
struct zvfs_open_file *of = openfile_alloc(real_fd, inode, flags, handle_id);
|
||||
struct zvfs_open_file *of = openfile_alloc(real_fd, inode, handle_id);
|
||||
if (!of) { errno = ENOMEM; goto fail_handle; }
|
||||
|
||||
pthread_mutex_lock(&g_fs.fd_mu);
|
||||
@@ -1150,7 +1150,7 @@ zvfs_dup_attach_newfd(int oldfd, int newfd, int new_fd_flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
new_of = openfile_alloc(newfd, old_of->inode, old_of->flags, old_of->handle_id);
|
||||
new_of = openfile_alloc(newfd, old_of->inode, old_of->handle_id);
|
||||
if (!new_of) {
|
||||
saved = (errno != 0) ? errno : ENOMEM;
|
||||
(void)blob_close(old_of->handle_id);
|
||||
@@ -1159,7 +1159,6 @@ zvfs_dup_attach_newfd(int oldfd, int newfd, int new_fd_flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
new_of->offset = old_of->offset;
|
||||
fd_flags = (new_fd_flags >= 0) ? new_fd_flags : old_of->fd_flags;
|
||||
new_of->fd_flags = fd_flags;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user