summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.h
blob: 0e96db6c7f7a4b5959e3880d5385cab58d4fc9ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <shared/flags.h>
#include <shared/types.h>
#include <stdbool.h>

enum vfs_backend_type {
	VFS_BACK_ROOT,
	VFS_BACK_USER,
};

// describes something which can act as an access function
struct vfs_backend {
	enum vfs_backend_type type;

	// only used with VFS_BACK_USER
	struct process *handler;
	struct process *queue;
};

// describes an in-process vfs call
struct vfs_request {
	enum vfs_operation type;
	struct {
		bool kern; // if false: use .buf ; if true: use .buf_kern
		union {
			char __user *buf;
			char *buf_kern;
		};
		int len;
	} input;
	struct {
		char __user *buf;
		int len;
	} output;

	int id; // handle.file.id
	int offset;

	struct process *caller;
	struct vfs_backend *backend;
};

/** Assigns the vfs_request to the caller, and calls the backend. Might not
 * return - can switch processes! */
int vfs_request_create(struct vfs_request);
_Noreturn void vfs_request_pass2handler(struct vfs_request *);
int vfs_request_finish(struct vfs_request *, int ret);