obj: add read() and write() object callbacks

This commit is contained in:
2023-05-14 21:11:32 +01:00
parent 0238008986
commit d02d05d922
10 changed files with 91 additions and 28 deletions

View File

@@ -121,6 +121,36 @@ struct object *object_header(void *p)
return obj;
}
kern_status_t object_read(struct object *obj, void *p, size_t max,
size_t *nr_read, socks_flags_t flags)
{
kern_status_t status = KERN_UNSUPPORTED;
if (obj->ob_type->ob_ops.read) {
status = obj->ob_type->ob_ops.read(obj, p, &max, flags);
} else {
max = 0;
}
if (nr_read) {
*nr_read = max;
}
return status;
}
kern_status_t object_write(struct object *obj, const void *p, size_t max,
size_t *nr_written, socks_flags_t flags)
{
kern_status_t status = KERN_UNSUPPORTED;
if (obj->ob_type->ob_ops.write) {
status = obj->ob_type->ob_ops.write(obj, p, &max, flags);
}
return status;
}
kern_status_t object_get_child_named(struct object *obj, const char *name, struct object **out)
{
kern_status_t status = KERN_UNSUPPORTED;