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
|
use io;
// BFS inode: structure that stores metadata about
// resources in the filesystem
export type inode = struct {
// Root block of the file content
@offset(0) block: u64,
// Length of file
@offset(8) length: u64,
// Timestamp of last modification
@offset(16) last_modified: u64,
// Owning user name
@offset(24) owner: [17]u8,
// Owning group name
@offset(41) group: [17]u8,
// Number of references of the inode
@offset(58) references: u16,
// Permission flags
@offset(60) permissions: u8,
// Attribute flags
@offset(61) attributes: u8,
// Levels of mapping for file content
@offset(62) map_levels: u8,
// Reserved
@offset(63) reserved0: u8
};
// Get an inode from the filesystem given inode ID
export fn getinode(filesystem: *bfs, inid: u64, in: *inode) (void | io::error) = {
const inaddr = (inid << 6): io::off;
pread(filesystem.device, in: *[size(inode)]u8, inaddr)?;
};
// Sets an inode in the filesystem given inode ID
export fn setinode(filesystem: *bfs, inid: u64, in: *inode) (void | io::error) = {
const inaddr = (inid << 6): io::off;
pwrite(filesystem.device, in: *[size(inode)]u8, inaddr)?;
};
|