summaryrefslogtreecommitdiff
path: root/src/kernel/fd.h
blob: bcc9902d3518f96ca57419fa09d86479f1aa2a97 (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
#pragma once
#include <kernel/types.h>
#include <stddef.h>

#define FD_MAX 16

typedef int fd_t; // TODO duplicated in syscalls.h

enum fd_type {
	FD_EMPTY,
	FD_SPECIAL_TTY,
};

struct fd {
	enum fd_type type;
};


enum fdop { // describes the operations which can be done on file descriptors
	FDOP_MOUNT, // also closes the original fd
	FDOP_READ,
	FDOP_WRITE,
	FDOP_CLOSE,
};

struct fdop_args {
	enum fdop type;
	struct fd *fd;
	union {
		struct { // FDOP_MOUNT
			struct mount *target;
		} mnt;
		struct { // FDOP_READ, FDOP_WRITE
			user_ptr ptr;
			size_t len;
		} rw;
	};
};

int fdop_dispatch(struct fdop_args args);