Streamline code
This commit is contained in:
parent
8272aa245b
commit
c32f7e22ec
3 changed files with 16 additions and 18 deletions
14
inode.h
14
inode.h
|
@ -1,11 +1,7 @@
|
|||
#ifndef INODE_H_
|
||||
#define INODE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "emmafs.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef struct Inode Inode;
|
||||
|
@ -67,9 +63,9 @@ struct Inode {
|
|||
struct trebly_indirect_data_block* file_trebly_indirect_data_block;
|
||||
};
|
||||
|
||||
Inode* create_inode(char name[64], uint8_t user_permissions, uint8_t group_permissions, uint16_t owner, uint16_t group, block* data_block);
|
||||
Inode* find_inode(char filename[], struct inode_table* itable);
|
||||
bool inode_exists(struct inode_table* itable, char filename[]);
|
||||
void delete_inode(struct inode_table* itable, char filename[]);
|
||||
Inode* create_empty_inode(char name[64], uint8_t user_permissions, uint8_t group_permissions, uint16_t owner, uint16_t group, struct data_block* data_block);
|
||||
Inode* find_inode(char filename[64], struct inode_table* itable);
|
||||
bool inode_exists(struct inode_table* itable, char filename[64]);
|
||||
void delete_inode(struct inode_table* itable, char filename[64]);
|
||||
|
||||
#endif // INODE_H_
|
||||
|
|
11
util.c
11
util.c
|
@ -4,21 +4,22 @@
|
|||
#include <math.h>
|
||||
|
||||
// DEPRECATED(?) This code will likely never be used. I have to handle it differently.
|
||||
int find_number_of_inodes(uint64_t fs_size) {
|
||||
int find_number_of_inodes(size_t fs_size) {
|
||||
int number_of_inodes = fs_size / BITS_PER_INODE;
|
||||
return number_of_inodes;
|
||||
}
|
||||
|
||||
// NOTE: formerly part of inode. Now transferred to util because it's both used in Inodes and the Superblock. The superblock does include inode.h, but this makes the code ordering easier to understand.
|
||||
tm* get_local_time() {
|
||||
return localtime(¤t_time);
|
||||
}
|
||||
// FIXME: Make this actually return a timestamp and not an integer. Stupid Emma.
|
||||
//tmp get_local_time() {
|
||||
// return localtime(¤t_time);
|
||||
//}
|
||||
|
||||
// TODO Implement file struct so this function can be implemented
|
||||
// uint16_t calc_needed_blocks(struct *file )
|
||||
|
||||
// returns in bytes.
|
||||
uint32_t get_file_size(uint16_t block_count) {
|
||||
size_t get_file_size(uint16_t block_count) {
|
||||
return BLOCKSIZE * block_count;
|
||||
}
|
||||
|
||||
|
|
9
util.h
9
util.h
|
@ -1,8 +1,7 @@
|
|||
#ifndef BLOCK_H_
|
||||
#define BLOCK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "emmafs.h"
|
||||
|
||||
|
||||
#define BLOCKSIZE 4096
|
||||
|
@ -66,9 +65,11 @@ struct tm *local_time;
|
|||
time_t current_time;
|
||||
|
||||
// Provide fs size in bytes
|
||||
int find_number_of_inodes(uint64_t fs_size);
|
||||
int find_number_of_inodes(size_t fs_size);
|
||||
tm* get_local_time();
|
||||
uint32_t get_file_size(uint16_t block_count);
|
||||
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.
|
||||
uint16_t bytes_to_kb(uint32_t bytes);
|
||||
uint16_t kb_to_mb(uint16_t kb);
|
||||
uint16_t mb_to_gb(uint16_t mb);
|
||||
|
|
Loading…
Reference in a new issue