diff options
Diffstat (limited to 'bfs/inode.ha')
| -rw-r--r-- | bfs/inode.ha | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bfs/inode.ha b/bfs/inode.ha new file mode 100644 index 0000000..cdd3a80 --- /dev/null +++ b/bfs/inode.ha @@ -0,0 +1,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)?; +}; |
