Ext
 All Files Functions
descriptors_table.h
Go to the documentation of this file.
1 
7 #ifndef EXT_FILESYSTEM_CORE_DESCRIPTORS_TABLE_H_
8 #define EXT_FILESYSTEM_CORE_DESCRIPTORS_TABLE_H_
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include <unistd.h>
12 #include "superblock.h"
13 
18 struct __attribute__((__packed__)) descriptors_table {
19  bool* reserved_fd;
20  uint16_t* fd_to_inode;
21  uint32_t* fd_to_position;
22 };
23 
30 void init_descriptors_table(struct descriptors_table* descriptors_table,
31  const struct superblock* superblock);
32 
38 void destruct_descriptors_table(struct descriptors_table* descriptors_table,
39  const struct superblock* superblock);
40 
48 ssize_t read_descriptors_table(int fd,
49  struct descriptors_table* descriptors_table,
50  const struct superblock* superblock);
51 
59 ssize_t write_descriptor_table(int fd,
60  struct descriptors_table* descriptors_table,
61  const struct superblock* superblock);
62 
70 int reserve_descriptor(struct descriptors_table* descriptors_table,
71  uint16_t inode_id,
72  const struct superblock* superblock);
73 
81 int free_descriptor(struct descriptors_table* descriptors_table,
82  uint16_t fd,
83  const struct superblock* superblock);
84 
90 uint16_t sizeof_descriptors_table(const struct superblock* superblock);
91 
92 #endif //EXT_FILESYSTEM_CORE_DESCRIPTORS_TABLE_H_
ssize_t write_descriptor_table(int fd, struct descriptors_table *descriptors_table, const struct superblock *superblock)
Write descriptors_table to memory.
void destruct_descriptors_table(struct descriptors_table *descriptors_table, const struct superblock *superblock)
Destructor of superblock.
struct __attribute__((__packed__)) descriptors_table
Struct for represent DT Contains all information about descriptor table.
Contains superblock struct and its methods.
int free_descriptor(struct descriptors_table *descriptors_table, uint16_t fd, const struct superblock *superblock)
Release descriptor for inode_id.
ssize_t read_descriptors_table(int fd, struct descriptors_table *descriptors_table, const struct superblock *superblock)
Read descriptors_table from memory.
void init_descriptors_table(struct descriptors_table *descriptors_table, const struct superblock *superblock)
Constructor of descriptors_table Init descriptors table with metadata from superblock.
uint16_t sizeof_descriptors_table(const struct superblock *superblock)
Sizeof descriptors_table.
int reserve_descriptor(struct descriptors_table *descriptors_table, uint16_t inode_id, const struct superblock *superblock)
Occupy descriptor for inode_id.