emmafs/util.h

86 lines
2.8 KiB
C
Raw Permalink Normal View History

2024-10-25 16:43:50 +02:00
#ifndef UTIL_H_
#define UTIL_H_
2024-10-08 23:01:29 +02:00
2024-11-13 17:23:44 +01:00
#include "emmafs.h"
2024-10-19 19:52:24 +02:00
2024-10-08 23:01:29 +02:00
#define BLOCKSIZE 4096
2024-10-19 19:52:24 +02:00
// NOTE: This is about how many inode get reserved per bit at fs creation. TODO: Come up witha better name.
2024-10-08 23:01:29 +02:00
#define BITS_PER_INODE 16384
2024-10-19 19:52:24 +02:00
typedef struct tm tm;
2024-10-08 23:01:29 +02:00
struct data_block {
2024-10-08 23:01:29 +02:00
char data[BLOCKSIZE];
};
struct indirect_data_block {
struct data_block* first_data_block;
struct data_block* second_data_block;
struct data_block* third_data_block;
struct data_block* fourth_data_block;
struct data_block* fifth_data_block;
struct data_block* sixth_data_block;
struct data_block* seventh_data_block;
struct data_block* eighth_data_block;
struct data_block* nineth_data_block;
struct data_block* tenth_data_block;
struct data_block* eleventh_data_block;
struct data_block* twelveth_data_block;
};
struct doubly_indirect_data_block {
struct data_block* first_indirect_data_block;
struct data_block* second_indirect_data_block;
struct data_block* third_indirect_data_block;
struct data_block* fourth_indirect_data_block;
struct data_block* fifth_indirect_data_block;
struct data_block* sixth_indirect_data_block;
struct data_block* seventh_indirect_data_block;
struct data_block* eighth_indirect_data_block;
struct data_block* nineth_indirect_data_block;
struct data_block* tenth_indirect_data_block;
struct data_block* eleventh_indirect_data_block;
struct data_block* twelveth_indirect_data_block;
};
struct trebly_indirect_data_block {
struct data_block* first_doubly_indirect_data_block;
struct data_block* second_doubly_indirect_data_block;
struct data_block* third_doubly_indirect_data_block;
struct data_block* fourth_doubly_indirect_data_block;
struct data_block* fifth_doubly_indirect_data_block;
struct data_block* sixth_doubly_indirect_data_block;
struct data_block* seventh_doubly_indirect_data_block;
struct data_block* eighth_doubly_indirect_data_block;
struct data_block* nineth_doubly_indirect_data_block;
struct data_block* tenth_doubly_indirect_data_block;
struct data_block* eleventh_doubly_indirect_data_block;
struct data_block* twelveth_doubly_indirect_data_block;
};
2024-10-19 19:52:24 +02:00
struct tm *local_time;
// Global Variables
time_t current_time;
2024-10-08 23:01:29 +02:00
// Provide fs size in bytes
2024-11-13 17:34:19 +01:00
<<<<<<< HEAD
2024-11-13 17:23:44 +01:00
int find_number_of_inodes(size_t fs_size);
2024-10-19 19:52:24 +02:00
tm* get_local_time();
2024-11-13 17:23:44 +01:00
size_t get_file_size(uint16_t block_count);
// DEPRECATED? Probably unneeded and will soon be removed. This should not be handled on the fs level.
2024-11-13 17:34:19 +01:00
=======
2024-10-08 23:01:29 +02:00
int find_number_of_inodes(uint64_t fs_size);
2024-10-25 16:43:50 +02:00
tm get_local_time();
2024-10-19 19:52:24 +02:00
uint32_t get_file_size(uint16_t block_count);
2024-11-13 17:34:19 +01:00
>>>>>>> 18f1037e030fa451566018dfcb8dbdb250787c70
2024-10-19 19:52:24 +02:00
uint16_t bytes_to_kb(uint32_t bytes);
uint16_t kb_to_mb(uint16_t kb);
uint16_t mb_to_gb(uint16_t mb);
uint16_t gb_to_tb(uint16_t gb);
uint8_t tb_to_pb(uint16_t tb);
2024-10-08 23:01:29 +02:00
2024-10-25 16:43:50 +02:00
#endif // UTIL_H_