49eb1f4806
Primary purpose of change: to support the mmap implementation, VM must know both (a) about some block metadata for FS cache blocks, i.e. inode numbers and inode offsets where applicable; and (b) know about *all* cache blocks, i.e. also of the FS primary caches and not just the blocks that spill into the secondary one. This changes the interface and VM data structures. This change is only for the interface (libminixfs) and VM data structures; the filesystem code is unmodified, so although the secondary cache will be used as normal, blocks will not be annotated with inode information until the FS is modified to provide this information. Until it is modified, mmap of files will fail gracefully on such filesystems. This is indicated to VFS/VM by returning ENOSYS for REQ_PEEK. Change-Id: I1d2df6c485e6c5e89eb28d9055076cc02629594e
62 lines
1.6 KiB
C
62 lines
1.6 KiB
C
|
|
#include "syslib.h"
|
|
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
#include <sys/mman.h>
|
|
#include <minix/vm.h>
|
|
#include <minix/sysutil.h>
|
|
#include <machine/vmparam.h>
|
|
|
|
int vm_cachecall(message *m, int call, void *addr, u32_t dev, u64_t dev_offset,
|
|
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
|
|
{
|
|
if(blocksize % PAGE_SIZE)
|
|
panic("blocksize %d should be a multiple of pagesize %d\n",
|
|
blocksize, PAGE_SIZE);
|
|
|
|
if(ino_offset % PAGE_SIZE)
|
|
panic("inode offset %d should be a multiple of pagesize %d\n",
|
|
ino_offset, PAGE_SIZE);
|
|
|
|
if(dev_offset % PAGE_SIZE)
|
|
panic("dev offset offset %d should be a multiple of pagesize %d\n",
|
|
dev_offset, PAGE_SIZE);
|
|
|
|
memset(m, 0, sizeof(*m));
|
|
|
|
assert(dev != NO_DEV);
|
|
|
|
m->m_u.m_vmmcp.dev_offset_pages = dev_offset/PAGE_SIZE;
|
|
m->m_u.m_vmmcp.ino_offset_pages = ino_offset/PAGE_SIZE;
|
|
m->m_u.m_vmmcp.ino = ino;
|
|
m->m_u.m_vmmcp.block = addr;
|
|
m->m_u.m_vmmcp.flags_ptr = flags;
|
|
m->m_u.m_vmmcp.dev = dev;
|
|
m->m_u.m_vmmcp.pages = blocksize / PAGE_SIZE;
|
|
m->m_u.m_vmmcp.flags = 0;
|
|
|
|
return _taskcall(VM_PROC_NR, call, m);
|
|
}
|
|
|
|
void *vm_map_cacheblock(u32_t dev, u64_t dev_offset,
|
|
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
|
|
{
|
|
message m;
|
|
|
|
if(vm_cachecall(&m, VM_MAPCACHEPAGE, NULL, dev, dev_offset,
|
|
ino, ino_offset, flags, blocksize) != OK)
|
|
return MAP_FAILED;
|
|
|
|
return m.m_u.m_vmmcp_reply.addr;
|
|
}
|
|
|
|
int vm_set_cacheblock(void *block, u32_t dev, u64_t dev_offset,
|
|
u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
|
|
{
|
|
message m;
|
|
|
|
return vm_cachecall(&m, VM_SETCACHEPAGE, block, dev, dev_offset,
|
|
ino, ino_offset, flags, blocksize);
|
|
}
|