blob: fc0c5d9a29dc2e02158da222df5029d59f8fc0b2 (
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
|
#pragma once
#include "common/types.h"
#include "fs/fs.h"
enum FileType
{
FD_NONE,
FD_INODE,
FD_DEVICE,
FD_PIPE
};
struct file
{
enum FileType type;
int ref;
char readable;
char writable;
struct pipe *pipe; // pipeline pointer
Inode *ip; // VFS Inode
uint32 off; // Current Offset
};
namespace FileTable
{
void init();
struct file *alloc(); // Allocate a free file handle
struct file *dup(struct file *f); // Duplicate handle (sys_dup)
void close(struct file *f); // Close handle
int stat(struct file *f, uint64 addr);
int read(struct file *f, uint64 addr, int n);
int write(struct file *f, uint64 addr, int n);
} // namespace FileTable
|