mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
tmpfs/ext2: remove VOP_MMAP and VOP_MUNMAP implementation
This commit is contained in:
+2
-32
@@ -1462,41 +1462,11 @@ static int ext2_symlink(vnode_t *vnode, char *name, vattr_t *attr, char *path, c
|
|||||||
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
||||||
|
|
||||||
static int ext2_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
static int ext2_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||||
void *paddr = pmm_allocpage(PMM_SECTION_DEFAULT);
|
__assert(!"unreachable");
|
||||||
if (paddr == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
if (arch_mmu_map(_cpu()->vmmctx->pagetable, paddr, addr, MMAPTMPFLAGS) == false) {
|
|
||||||
pmm_release(paddr);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t readc;
|
|
||||||
int e = ext2_read(node, addr, PAGE_SIZE, offset, flags, &readc, cred);
|
|
||||||
if (e) {
|
|
||||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
pmm_release(paddr);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset((void *)((uintptr_t)addr + readc), 0, PAGE_SIZE - readc);
|
|
||||||
|
|
||||||
arch_mmu_remap(_cpu()->vmmctx->pagetable, paddr, addr, vnodeflagstommuflags(flags));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ext2_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
static int ext2_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||||
if (flags & V_FFLAGS_SHARED) {
|
__assert(!"unreachable");
|
||||||
size_t wc;
|
|
||||||
__assert(ext2_write(node, addr, PAGE_SIZE, offset, flags, &wc, cred) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *paddr = arch_mmu_getphysical(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
__assert(paddr);
|
|
||||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
pmm_release(paddr);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleinodeunlink(ext2fs_t *fs, ext2node_t *node, int inode) {
|
static int handleinodeunlink(ext2fs_t *fs, ext2node_t *node, int inode) {
|
||||||
|
|||||||
+2
-33
@@ -367,42 +367,11 @@ static int tmpfs_readlink(vnode_t *node, char **link, cred_t *cred) {
|
|||||||
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
#define MMAPTMPFLAGS (ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC | ARCH_MMU_FLAGS_WRITE)
|
||||||
|
|
||||||
static int tmpfs_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
static int tmpfs_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||||
void *paddr = pmm_allocpage(PMM_SECTION_DEFAULT);
|
__assert(!"unreachable");
|
||||||
if (paddr == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
if (arch_mmu_map(_cpu()->vmmctx->pagetable, paddr, addr, MMAPTMPFLAGS) == false) {
|
|
||||||
pmm_release(paddr);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t readc;
|
|
||||||
int e = tmpfs_read(node, addr, PAGE_SIZE, offset, flags, &readc, cred);
|
|
||||||
if (e) {
|
|
||||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
pmm_release(paddr);
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset((void *)((uintptr_t)addr + readc), 0, PAGE_SIZE - readc);
|
|
||||||
|
|
||||||
arch_mmu_remap(_cpu()->vmmctx->pagetable, paddr, addr, vnodeflagstommuflags(flags));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tmpfs_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
static int tmpfs_munmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||||
if (flags & V_FFLAGS_SHARED) {
|
__assert(!"unreachable");
|
||||||
size_t wc;
|
|
||||||
// TODO no growing flag
|
|
||||||
__assert(tmpfs_write(node, addr, PAGE_SIZE, offset, flags, &wc, cred) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *paddr = arch_mmu_getphysical(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
__assert(paddr);
|
|
||||||
arch_mmu_unmap(_cpu()->vmmctx->pagetable, addr);
|
|
||||||
pmm_release(paddr);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user