mirror of
https://review.haiku-os.org/haiku
synced 2025-01-18 12:38:51 +01:00
ramfs: A write lock is needed when truncating files.
Should fix all KDLs in #19360.
This commit is contained in:
parent
48bfa9ee2f
commit
c9892ac20f
@ -952,8 +952,8 @@ ramfs_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
|
|||||||
|
|
||||||
FUNCTION(("node: %lld\n", node->GetID()));
|
FUNCTION(("node: %lld\n", node->GetID()));
|
||||||
|
|
||||||
VolumeReadLocker locker(volume);
|
VolumeReadLocker readLocker(volume);
|
||||||
if (!locker.IsLocked())
|
if (!readLocker.IsLocked())
|
||||||
RETURN_ERROR(B_ERROR);
|
RETURN_ERROR(B_ERROR);
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@ -974,10 +974,16 @@ ramfs_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
|
|||||||
if (!cookie)
|
if (!cookie)
|
||||||
SET_ERROR(error, B_NO_MEMORY);
|
SET_ERROR(error, B_NO_MEMORY);
|
||||||
}
|
}
|
||||||
|
readLocker.Unlock();
|
||||||
|
|
||||||
// truncate if requested
|
// truncate if requested
|
||||||
if (error == B_OK && (openMode & O_TRUNC))
|
if (error == B_OK && (openMode & O_TRUNC)) {
|
||||||
|
VolumeWriteLocker writeLocker(volume);
|
||||||
|
|
||||||
error = node->SetSize(0);
|
error = node->SetSize(0);
|
||||||
NodeMTimeUpdater mTimeUpdater(node);
|
NodeMTimeUpdater mTimeUpdater(node);
|
||||||
|
}
|
||||||
|
|
||||||
// set result / cleanup on failure
|
// set result / cleanup on failure
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
*_cookie = cookie;
|
*_cookie = cookie;
|
||||||
|
Loading…
Reference in New Issue
Block a user