Contains block struct and its methods.
More...
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include "inode.h"
Go to the source code of this file.
|
struct | __attribute__ ((__packed__)) block_record |
| Contains information about filename/dirname. More...
|
|
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]. More...
|
|
void | destruct_block_record (struct block_record *block_record) |
| Destructor of block_record. More...
|
|
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. More...
|
|
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]. More...
|
|
void | destruct_block (struct block *block) |
| Destructor of block. More...
|
|
ssize_t | read_block (int fd, struct block *block, uint16_t block_id, const struct superblock *superblock) |
| Read block from memory. More...
|
|
ssize_t | write_block (int fd, struct block *block, const struct superblock *superblock) |
| Write. More...
|
|
uint8_t | get_max_records_count (const struct superblock *superblock) |
|
uint32_t | get_max_data_in_block (const struct superblock *superblock) |
|
uint32_t | get_max_data_size_of_all_blocks (const struct superblock *superblock) |
|
uint32_t | get_remain_data (const struct block *block, const struct superblock *superblock) |
|
Contains block struct and its methods.
- Author
- yaishenka
- Date
- 13.03.2021
Definition in file block.h.
struct __attribute__ |
( |
(__packed__) |
| ) |
|
Contains information about filename/dirname.
Main suberblock struct Contains fs_info and masks for blocks and inodes.
Main inode struct.
Contains information about block.
Contains meta info about block.
Block can contain file data or records about directory
This struct represent inode
Definition at line 18 of file block.h.
void destruct_block |
( |
struct block * |
block | ) |
|
Destructor of block.
- Parameters
-
Definition at line 118 of file block.c.
void destruct_block_record |
( |
struct block_record * |
block_record | ) |
|
Destructor of block_record.
- Parameters
-
Definition at line 32 of file block.c.
uint32_t get_max_data_in_block |
( |
const struct superblock * |
superblock | ) |
|
- Parameters
-
- Returns
- max data size in one block
Definition at line 246 of file block.c.
uint32_t get_max_data_size_of_all_blocks |
( |
const struct superblock * |
superblock | ) |
|
- Parameters
-
- Returns
- max data size in FS
Definition at line 250 of file block.c.
uint8_t get_max_records_count |
( |
const struct superblock * |
superblock | ) |
|
- Parameters
-
- Returns
- Maximum number of records in a block
Definition at line 241 of file block.c.
uint32_t get_remain_data |
( |
const struct block * |
block, |
|
|
const struct superblock * |
superblock |
|
) |
| |
- Parameters
-
- Returns
- remain size of block
Definition at line 255 of file block.c.
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.
- Parameters
-
block | |
superblock | |
block_id | |
inode_id | |
Definition at line 94 of file block.c.
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].
- Parameters
-
block_record | |
superblock | |
inode_id | id of inode with associated with dir or file |
Definition at line 24 of file block.c.
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].
- Parameters
-
block | |
superblock | |
block_id | |
inode_id | |
records_count | |
Definition at line 107 of file block.c.
ssize_t read_block |
( |
int |
fd, |
|
|
struct block * |
block, |
|
|
uint16_t |
block_id, |
|
|
const struct superblock * |
superblock |
|
) |
| |
Read block from memory.
- Parameters
-
fd | |
block | |
block_id | |
superblock | |
- Returns
- sizeof(block) if reading is ok; -1 otherwise and destruct block object
Definition at line 133 of file block.c.
ssize_t write_block |
( |
int |
fd, |
|
|
struct block * |
block, |
|
|
const struct superblock * |
superblock |
|
) |
| |
Write.
- Parameters
-
- Returns
- sizeof(block) if writing is ok; -1 otherwise
Definition at line 189 of file block.c.