Ext
 All Files Functions
block.h
Go to the documentation of this file.
1 
7 #ifndef EXT_FILESYSTEM_CORE_BLOCK_H_
8 #define EXT_FILESYSTEM_CORE_BLOCK_H_
9 
10 #include <stdint.h>
11 #include <stdbool.h>
12 #include <unistd.h>
13 #include "inode.h"
14 
18 struct __attribute__((__packed__)) block_record {
19  uint16_t inode_id;
20  char* path;
21 };
22 
26 struct __attribute__((__packed__)) block_info {
27  uint16_t block_id;
28  uint16_t inode_id;
29  uint8_t records_count;
30  uint16_t data_size;
31 };
32 
38 struct __attribute__((__packed__)) block {
39  struct block_info* block_info;
40  struct block_record* block_records;
41  char* data;
42 };
43 
51 void init_block_record(struct block_record* block_record,
52  const struct superblock* superblock,
53  uint16_t inode_id);
54 
59 void destruct_block_record(struct block_record* block_record);
60 
69 void init_block(struct block* block,
70  const struct superblock* superblock,
71  uint16_t block_id,
72  uint16_t inode_id);
73 
83 void init_block_with_records(struct block* block,
84  const struct superblock* superblock,
85  uint16_t block_id,
86  uint16_t inode_id,
87  uint8_t records_count);
88 
93 void destruct_block(struct block* block);
94 
103 ssize_t read_block(int fd,
104  struct block* block,
105  uint16_t block_id,
106  const struct superblock* superblock);
107 
115 ssize_t write_block(int fd,
116  struct block* block,
117  const struct superblock* superblock);
118 
123 uint8_t get_max_records_count(const struct superblock* superblock);
124 
129 uint32_t get_max_data_in_block(const struct superblock* superblock);
130 
135 uint32_t get_max_data_size_of_all_blocks(const struct superblock* superblock);
136 
142 uint32_t get_remain_data(const struct block* block,
143  const struct superblock* superblock);
144 
145 #endif //EXT_FILESYSTEM_CORE_BLOCK_H_
void init_block_with_records(struct block *block, const struct superblock *superblock, uint16_t block_id, uint16_t inode_id, uint8_t records_count)
Constructor of block Init block and set its block_records array to bloc_record[records_count].
Definition: block.c:107
ssize_t write_block(int fd, struct block *block, const struct superblock *superblock)
Write.
Definition: block.c:189
uint32_t get_max_data_size_of_all_blocks(const struct superblock *superblock)
Definition: block.c:250
void init_block_record(struct block_record *block_record, const struct superblock *superblock, uint16_t inode_id)
Constructor of block record Init block record and set its path array to char[max_len_path].
Definition: block.c:24
void destruct_block_record(struct block_record *block_record)
Destructor of block_record.
Definition: block.c:32
ssize_t read_block(int fd, struct block *block, uint16_t block_id, const struct superblock *superblock)
Read block from memory.
Definition: block.c:133
uint32_t get_remain_data(const struct block *block, const struct superblock *superblock)
Definition: block.c:255
void destruct_block(struct block *block)
Destructor of block.
Definition: block.c:118
uint8_t get_max_records_count(const struct superblock *superblock)
Definition: block.c:241
uint32_t get_max_data_in_block(const struct superblock *superblock)
Definition: block.c:246
Contains inode struct and its methods.
void init_block(struct block *block, const struct superblock *superblock, uint16_t block_id, uint16_t inode_id)
Constructor of block Init block and set its block_records array to nullptr.
Definition: block.c:94
struct __attribute__((__packed__)) block_record
Contains information about filename/dirname.
Definition: block.h:18