diff options
author | Ian Moffett <ian@osmora.org> | 2024-04-18 15:06:22 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-18 15:06:22 -0400 |
commit | 0e24592cb32f61bb59caad30ea9acc524974c6dd (patch) | |
tree | f229e71727d51d0a21bf9da0e7111c2376f745a7 /sys/vm/vm_obj.c | |
parent | 691302ee1f22a5458c4dab3d5f85cc3de9332bb5 (diff) |
kernel: vm: Add device pager
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/vm/vm_obj.c')
-rw-r--r-- | sys/vm/vm_obj.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/vm/vm_obj.c b/sys/vm/vm_obj.c index c5fc921..589ca47 100644 --- a/sys/vm/vm_obj.c +++ b/sys/vm/vm_obj.c @@ -32,6 +32,22 @@ #include <sys/errno.h> #include <string.h> +static void +vm_set_pgops(struct vm_object *obj, struct vnode *vnode) +{ + if (vnode == NULL) { + obj->vnode = NULL; + return; + } + + /* Is this a device? */ + if (vnode->type == VCHR || vnode->type == VBLK) { + obj->pgops = &g_dev_pagerops; + } else { + obj->pgops = &g_vnode_pagerops; + } +} + int vm_obj_init(struct vm_object **res, struct vnode *vnode) { @@ -43,7 +59,8 @@ vm_obj_init(struct vm_object **res, struct vnode *vnode) memset(obj, 0, sizeof(struct vm_object)); obj->vnode = vnode; - obj->pgops = &g_vnode_pagerops; + + vm_set_pgops(obj, vnode); *res = obj; return 0; } |