summaryrefslogtreecommitdiff
path: root/src/kernel/handle.h
blob: df5ad36ad6c5b299b37536bea6d8c9b450b1ce6f (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
#pragma once
#include <kernel/vfs/mount.h>
#include <shared/types.h>
#include <stddef.h>

// TODO make accessible only from proc.c
#define HANDLE_MAX 16

enum handle_type {
	HANDLE_INVALID = 0,
	HANDLE_FILE,

	HANDLE_FS_FRONT,
};

struct handle {
	enum handle_type type;
	union {
		struct {
			struct vfs_backend *backend;
			int id;
		} file;
		struct {
			struct vfs_backend *backend;
		} fs;
	};

	size_t refcount;
};

struct handle *handle_init(enum handle_type);
void handle_close(struct handle *);