* Fixed CID 1199-1202: only call the cache listener in case the open succeeded
(this might also have derefenced a potentially freed vnode). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38196 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5361,13 +5361,15 @@ file_open_entry_ref(dev_t mountID, ino_t directoryID, const char* name,
|
|||||||
return B_LINK_LIMIT;
|
return B_LINK_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd = open_vnode(vnode, openMode, kernel);
|
int newFD = open_vnode(vnode, openMode, kernel);
|
||||||
if (fd < 0)
|
if (newFD >= 0) {
|
||||||
|
// The vnode reference has been transferred to the FD
|
||||||
|
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache, mountID,
|
||||||
|
directoryID, vnode->id, name);
|
||||||
|
} else
|
||||||
put_vnode(vnode);
|
put_vnode(vnode);
|
||||||
|
|
||||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache, mountID, directoryID,
|
return newFD;
|
||||||
vnode->id, name);
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5394,13 +5396,13 @@ file_open(int fd, char* path, int openMode, bool kernel)
|
|||||||
|
|
||||||
// open the vnode
|
// open the vnode
|
||||||
int newFD = open_vnode(vnode, openMode, kernel);
|
int newFD = open_vnode(vnode, openMode, kernel);
|
||||||
// put only on error -- otherwise our reference was transferred to the FD
|
if (newFD >= 0) {
|
||||||
if (newFD < 0)
|
// The vnode reference has been transferred to the FD
|
||||||
|
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache,
|
||||||
|
vnode->device, parentID, vnode->id, NULL);
|
||||||
|
} else
|
||||||
put_vnode(vnode);
|
put_vnode(vnode);
|
||||||
|
|
||||||
cache_node_opened(vnode, FDTYPE_FILE, vnode->cache,
|
|
||||||
vnode->device, parentID, vnode->id, NULL);
|
|
||||||
|
|
||||||
return newFD;
|
return newFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5631,13 +5633,15 @@ dir_open_entry_ref(dev_t mountID, ino_t parentID, const char* name, bool kernel)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
int fd = open_dir_vnode(vnode, kernel);
|
int newFD = open_dir_vnode(vnode, kernel);
|
||||||
if (fd < 0)
|
if (newFD >= 0) {
|
||||||
|
// The vnode reference has been transferred to the FD
|
||||||
|
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, mountID, parentID,
|
||||||
|
vnode->id, name);
|
||||||
|
} else
|
||||||
put_vnode(vnode);
|
put_vnode(vnode);
|
||||||
|
|
||||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, mountID, parentID,
|
return newFD;
|
||||||
vnode->id, name);
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5657,11 +5661,13 @@ dir_open(int fd, char* path, bool kernel)
|
|||||||
|
|
||||||
// open the dir
|
// open the dir
|
||||||
int newFD = open_dir_vnode(vnode, kernel);
|
int newFD = open_dir_vnode(vnode, kernel);
|
||||||
if (newFD < 0)
|
if (newFD >= 0) {
|
||||||
|
// The vnode reference has been transferred to the FD
|
||||||
|
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, vnode->device,
|
||||||
|
parentID, vnode->id, NULL);
|
||||||
|
} else
|
||||||
put_vnode(vnode);
|
put_vnode(vnode);
|
||||||
|
|
||||||
cache_node_opened(vnode, FDTYPE_DIR, vnode->cache, vnode->device, parentID,
|
|
||||||
vnode->id, NULL);
|
|
||||||
return newFD;
|
return newFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user