blob: af9d45a28b141be604cc07eff1b0af8ed7274fb4 (
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
|
#pragma once
#include <kernel/types.h>
#include <kernel/vfs/mount.h>
#include <kernel/vfs/request.h>
#include <stddef.h>
enum handle_type {
HANDLE_INVALID = 0,
HANDLE_FILE,
HANDLE_PIPE,
HANDLE_FS_FRONT,
HANDLE_FS_REQ,
HANDLE_NULL,
};
// TODO use unions
// when making changes, keep in mind that dup creates copies of HANDLE_FILEs
struct Handle {
enum handle_type type;
VfsBackend *backend; /* HANDLE_FILE | HANDLE_FS_FRONT */
void __user *file_id; /* only applicable to HANDLE_FILE */
bool readable, writeable; /* HANDLE_FILE | HANDLE_PIPE */
VfsReq *req; /* HANDLE_FS_REQ */
struct {
Proc *queued;
Handle *sister; // the other end, not included in refcount
} pipe;
Handle *base; /* used by dup'd HANDLE_FILEs. */
size_t refcount;
};
Handle *handle_init(enum handle_type);
void handle_close(Handle *);
|