kernel: Create a new shared memory object if the old one was lost

This commit is contained in:
apio 2023-08-03 10:31:29 +02:00
parent 842b212685
commit f150425222
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 11 additions and 0 deletions

View File

@ -39,6 +39,11 @@ Result<u64> FramebufferDevice::query_shared_memory(off_t offset, usize count)
}
auto* shm = g_shared_memory_map.try_get_ref(*m_shmid);
if (!shm)
{
m_shmid = {};
return query_shared_memory(offset, count);
}
if (shm->offset > offset)
{
TRY(shm->grow_backward(Framebuffer::ptr() + offset, (shm->offset - offset) / ARCH_PAGE_SIZE));

View File

@ -144,6 +144,12 @@ namespace TmpFS
}
auto* shm = g_shared_memory_map.try_get_ref(*m_shmid);
if (!shm)
{
m_shmid = {};
return query_shared_memory(offset, count);
}
if (shm->offset > offset)
{
TRY(shm->grow_backward(m_data_buffer.data() + offset, (shm->offset - offset) / ARCH_PAGE_SIZE));