mirror of
https://review.haiku-os.org/haiku
synced 2025-01-18 04:28:52 +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()));
|
||||
|
||||
VolumeReadLocker locker(volume);
|
||||
if (!locker.IsLocked())
|
||||
VolumeReadLocker readLocker(volume);
|
||||
if (!readLocker.IsLocked())
|
||||
RETURN_ERROR(B_ERROR);
|
||||
|
||||
status_t error = B_OK;
|
||||
@ -974,10 +974,16 @@ ramfs_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
|
||||
if (!cookie)
|
||||
SET_ERROR(error, B_NO_MEMORY);
|
||||
}
|
||||
readLocker.Unlock();
|
||||
|
||||
// truncate if requested
|
||||
if (error == B_OK && (openMode & O_TRUNC))
|
||||
if (error == B_OK && (openMode & O_TRUNC)) {
|
||||
VolumeWriteLocker writeLocker(volume);
|
||||
|
||||
error = node->SetSize(0);
|
||||
NodeMTimeUpdater mTimeUpdater(node);
|
||||
NodeMTimeUpdater mTimeUpdater(node);
|
||||
}
|
||||
|
||||
// set result / cleanup on failure
|
||||
if (error == B_OK)
|
||||
*_cookie = cookie;
|
||||
|
Loading…
Reference in New Issue
Block a user