Ext
 All Files Functions
Functions
descriptors_table.h File Reference

Contains descriptors_table struct and its methods. More...

#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include "superblock.h"

Go to the source code of this file.

Functions

struct __attribute__ ((__packed__)) descriptors_table
 Struct for represent DT Contains all information about descriptor table.
 
void init_descriptors_table (struct descriptors_table *descriptors_table, const struct superblock *superblock)
 Constructor of descriptors_table Init descriptors table with metadata from superblock. More...
 
void destruct_descriptors_table (struct descriptors_table *descriptors_table, const struct superblock *superblock)
 Destructor of superblock. More...
 
ssize_t read_descriptors_table (int fd, struct descriptors_table *descriptors_table, const struct superblock *superblock)
 Read descriptors_table from memory. More...
 
ssize_t write_descriptor_table (int fd, struct descriptors_table *descriptors_table, const struct superblock *superblock)
 Write descriptors_table to memory. More...
 
int reserve_descriptor (struct descriptors_table *descriptors_table, uint16_t inode_id, const struct superblock *superblock)
 Occupy descriptor for inode_id. More...
 
int free_descriptor (struct descriptors_table *descriptors_table, uint16_t fd, const struct superblock *superblock)
 Release descriptor for inode_id. More...
 
uint16_t sizeof_descriptors_table (const struct superblock *superblock)
 Sizeof descriptors_table. More...
 

Detailed Description

Contains descriptors_table struct and its methods.

Author
yaishenka
Date
13.03.2021

Definition in file descriptors_table.h.

Function Documentation

void destruct_descriptors_table ( struct descriptors_table *  descriptors_table,
const struct superblock *  superblock 
)

Destructor of superblock.

Parameters
descriptors_table
superblock

Definition at line 23 of file descriptors_table.c.

int free_descriptor ( struct descriptors_table *  descriptors_table,
uint16_t  fd,
const struct superblock *  superblock 
)

Release descriptor for inode_id.

Parameters
descriptors_table
fdfd to release
superblock
Returns
d if all ok; -1 otherwise

Definition at line 126 of file descriptors_table.c.

void init_descriptors_table ( struct descriptors_table *  descriptors_table,
const struct superblock *  superblock 
)

Constructor of descriptors_table Init descriptors table with metadata from superblock.

Parameters
descriptors_table
superblock
Author
yaishenka
Date
12.03.2021

Definition at line 11 of file descriptors_table.c.

ssize_t read_descriptors_table ( int  fd,
struct descriptors_table *  descriptors_table,
const struct superblock *  superblock 
)

Read descriptors_table from memory.

Parameters
fdopened fd
descriptors_table
superblock
Returns
sizeof(descriptor_table) of reading is ok; -1 otherwise and destruct descriptors_table

Definition at line 30 of file descriptors_table.c.

int reserve_descriptor ( struct descriptors_table *  descriptors_table,
uint16_t  inode_id,
const struct superblock *  superblock 
)

Occupy descriptor for inode_id.

Parameters
descriptors_table
inode_id
superblock
Returns
fd if all ok; -1 otherwise

Definition at line 103 of file descriptors_table.c.

uint16_t sizeof_descriptors_table ( const struct superblock *  superblock)

Sizeof descriptors_table.

Parameters
superblock
Returns

Definition at line 141 of file descriptors_table.c.

ssize_t write_descriptor_table ( int  fd,
struct descriptors_table *  descriptors_table,
const struct superblock *  superblock 
)

Write descriptors_table to memory.

Parameters
fdopened fd
descriptors_table
superblock
Returns
sizeof(descriptor_table) of writing is ok; -1 otherwise

Definition at line 68 of file descriptors_table.c.