forked from davidsaOpenu/xv6-ns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.h
113 lines (102 loc) · 2.15 KB
/
file.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef XV6_FILE_H
#define XV6_FILE_H
#include "fs.h"
#include "sleeplock.h"
#include "cgfs.h"
#include "param.h"
struct file {
enum { FD_NONE, FD_PIPE, FD_INODE, FD_CG } type;
int ref; // reference count
char readable;
char writable;
uint off;
union {
// FD_PIPE
struct pipe *pipe;
// FD_INODE
struct {
struct inode *ip;
struct mount *mnt;
};
// FD_CG
struct {
struct cgroup *cgp;
char cgfilename[MAX_CGROUP_FILE_NAME_LENGTH];
union {
// cpu
union {
struct {
char active;
int usage_usec;
int user_usec;
int system_usec;
int nr_periods;
int nr_throttled;
int throttled_usec;
} stat;
struct {
int weight;
} weight;
struct {
int max;
int period;
} max;
} cpu;
// pid
union {
struct {
char active;
int max;
} max;
} pid;
// cpu_set
union {
struct {
char active;
int cpu_id;
} set;
} cpu_s;
// freezer
union {
struct {
int frozen;
} freezer;
} frz;
// memory
union {
struct {
char active;
} stat;
struct {
char active;
unsigned int max;
} max;
} mem;
};
};
};
};
// in-memory copy of an inode
struct inode {
uint dev; // Device number
uint inum; // Inode number
int ref; // Reference count
struct sleeplock lock; // protects everything below here
int valid; // inode has been read from disk?
short type; // copy of disk inode
short major;
short minor;
short nlink;
uint size;
uint addrs[NDIRECT+1];
};
// table mapping major device number to
// device functions
struct devsw {
int (*read)(struct inode*, char*, int);
int (*write)(struct inode*, char*, int);
};
extern struct devsw devsw[];
#define CONSOLE_MAJOR 1
#define CONSOLE_MINOR 0
#endif