Resolve merge conflict
This commit is contained in:
		
						commit
						70ce80a440
					
				
					 3 changed files with 66 additions and 25 deletions
				
			
		
							
								
								
									
										41
									
								
								inode.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								inode.c
									
									
									
									
									
								
							| 
						 | 
					@ -1,9 +1,11 @@
 | 
				
			||||||
#include "inode.h"
 | 
					#include "inode.h"
 | 
				
			||||||
 | 
					#include "util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Inode* find_inode(char filename[], struct inode_table* itable) {
 | 
					Inode* find_inode(char filename[], struct inode_table* itable) {
 | 
				
			||||||
    for (uint32_t i = 0; i < itable->size; i++) {
 | 
					    for (uint32_t i = 0; i < itable->size; i++) {
 | 
				
			||||||
        if (strcmp(filename, itable->inodes[i]->name)) {
 | 
					        if (!strcmp(filename, itable->inodes[i].filename)) {
 | 
				
			||||||
            return itable->inodes[i];
 | 
					            Inode* ret = &itable->inodes[i];
 | 
				
			||||||
 | 
					            return ret;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
| 
						 | 
					@ -11,7 +13,7 @@ Inode* find_inode(char filename[], struct inode_table* itable) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool inode_exists(struct inode_table* itable, char filename[]) {
 | 
					bool inode_exists(struct inode_table* itable, char filename[]) {
 | 
				
			||||||
    for (uint32_t i = 0; i < itable->size; i++) {
 | 
					    for (uint32_t i = 0; i < itable->size; i++) {
 | 
				
			||||||
        if (strcmp(filename, itable->inodes[i]->name)) {
 | 
					        if (!strcmp(filename, itable->inodes[i].filename)) {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -23,3 +25,36 @@ void delete_inode(struct inode_table* itable, char filename[]) {
 | 
				
			||||||
    free(wanted_inode);
 | 
					    free(wanted_inode);
 | 
				
			||||||
    wanted_inode = NULL;
 | 
					    wanted_inode = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Inode* create_inode() {
 | 
				
			||||||
 | 
					    Inode* new_inode = (Inode*) malloc(sizeof(Inode));
 | 
				
			||||||
 | 
					    if (new_inode == NULL) {
 | 
				
			||||||
 | 
					        errno = ENOMEM;
 | 
				
			||||||
 | 
					        perror("Failed to allocate memory for inode");
 | 
				
			||||||
 | 
					        return new_inode;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    new_inode->filename = NULL;
 | 
				
			||||||
 | 
					    new_inode->filesize = 0;
 | 
				
			||||||
 | 
					    new_inode->owner = 0;
 | 
				
			||||||
 | 
					    new_inode->group = 0;
 | 
				
			||||||
 | 
					    new_inode->created = get_local_time();
 | 
				
			||||||
 | 
					    new_inode->last_modified = get_local_time();
 | 
				
			||||||
 | 
					    new_inode->block_count = 0;
 | 
				
			||||||
 | 
					    new_inode->first_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->second_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode-> third_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->fourth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->fifth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->sixth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->seventh_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->eighth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->nineth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->tenth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->eleventh_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->twelveth_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->file_indirect_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode->file_doubly_indirect_data_block = NULL;
 | 
				
			||||||
 | 
					    new_inode-> file_trebly_indirect_data_block = NULL;
 | 
				
			||||||
 | 
					    return new_inode;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										38
									
								
								inode.h
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								inode.h
									
									
									
									
									
								
							| 
						 | 
					@ -7,26 +7,16 @@
 | 
				
			||||||
typedef struct Inode Inode;
 | 
					typedef struct Inode Inode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum permissions {
 | 
					enum permissions {
 | 
				
			||||||
    R = 1,
 | 
					    READ = 1,
 | 
				
			||||||
    W = 2,
 | 
					    WRITE = 2,
 | 
				
			||||||
    X = 4
 | 
					    EXECUTE = 4
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NOTE: Add handling for the block bitmap for when a file is deleted and created. That's how you solve the issue of when a block is usable.
 | 
					// TODO: Add handling for the block bitmap for when a file is deleted and created. That's how you solve the issue of when a block is usable.
 | 
				
			||||||
 | 
					 | 
				
			||||||
struct inode_table {
 | 
					 | 
				
			||||||
    // the following keyword spam purely exist so I definitely see it with highlighting.
 | 
					 | 
				
			||||||
    // NOTE, TODO, FIXME, DEPRECATED, HACK, IMPORTANT: always initialize all values to be null when the inode table is created!!!!
 | 
					 | 
				
			||||||
    // TODO: Change currently hardcoded value to actually accurately describe the size of the filesystem, only for temporary purposes.
 | 
					 | 
				
			||||||
    Inode* inodes[640000];
 | 
					 | 
				
			||||||
    uint32_t size;
 | 
					 | 
				
			||||||
    uint32_t used_inodes;
 | 
					 | 
				
			||||||
    uint32_t free_inodes;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Inode {
 | 
					struct Inode {
 | 
				
			||||||
    // file information
 | 
					    // file information
 | 
				
			||||||
    char name[64];
 | 
					    char *filename;
 | 
				
			||||||
    uint32_t filesize;
 | 
					    uint32_t filesize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // ownership and permissions
 | 
					    // ownership and permissions
 | 
				
			||||||
| 
						 | 
					@ -63,9 +53,19 @@ struct Inode {
 | 
				
			||||||
    struct trebly_indirect_data_block* file_trebly_indirect_data_block;
 | 
					    struct trebly_indirect_data_block* file_trebly_indirect_data_block;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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);
 | 
					struct inode_table {
 | 
				
			||||||
Inode* find_inode(char filename[64], struct inode_table* itable);
 | 
					    // the following keyword spam purely exist so I definitely see it with highlighting.
 | 
				
			||||||
bool inode_exists(struct inode_table* itable, char filename[64]);
 | 
					    // NOTE, TODO, FIXME, DEPRECATED, HACK, IMPORTANT: always initialize all values to be null when the inode table is created!!!!
 | 
				
			||||||
void delete_inode(struct inode_table* itable, char filename[64]);
 | 
					    // TODO: Change currently hardcoded value to actually accurately describe the size of the filesystem, only for temporary purposes.
 | 
				
			||||||
 | 
					    Inode inodes[640000];
 | 
				
			||||||
 | 
					    uint32_t size;
 | 
				
			||||||
 | 
					    uint32_t used_inodes;
 | 
				
			||||||
 | 
					    uint32_t free_inodes;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Inode* create_inode();
 | 
				
			||||||
 | 
					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[]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // INODE_H_
 | 
					#endif // INODE_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										12
									
								
								util.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								util.h
									
									
									
									
									
								
							| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
#ifndef BLOCK_H_
 | 
					#ifndef UTIL_H_
 | 
				
			||||||
#define BLOCK_H_
 | 
					#define UTIL_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "emmafs.h"
 | 
					#include "emmafs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,15 +65,21 @@ struct tm *local_time;
 | 
				
			||||||
time_t current_time;
 | 
					time_t current_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Provide fs size in bytes
 | 
					// Provide fs size in bytes
 | 
				
			||||||
 | 
					<<<<<<< HEAD
 | 
				
			||||||
int find_number_of_inodes(size_t fs_size);
 | 
					int find_number_of_inodes(size_t fs_size);
 | 
				
			||||||
tm* get_local_time();
 | 
					tm* get_local_time();
 | 
				
			||||||
size_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.
 | 
					// DEPRECATED? Probably unneeded and will soon be removed. This should not be handled on the fs level.
 | 
				
			||||||
 | 
					=======
 | 
				
			||||||
 | 
					int find_number_of_inodes(uint64_t fs_size);
 | 
				
			||||||
 | 
					tm get_local_time();
 | 
				
			||||||
 | 
					uint32_t get_file_size(uint16_t block_count);
 | 
				
			||||||
 | 
					>>>>>>> 18f1037e030fa451566018dfcb8dbdb250787c70
 | 
				
			||||||
uint16_t bytes_to_kb(uint32_t bytes);
 | 
					uint16_t bytes_to_kb(uint32_t bytes);
 | 
				
			||||||
uint16_t kb_to_mb(uint16_t kb);
 | 
					uint16_t kb_to_mb(uint16_t kb);
 | 
				
			||||||
uint16_t mb_to_gb(uint16_t mb);
 | 
					uint16_t mb_to_gb(uint16_t mb);
 | 
				
			||||||
uint16_t gb_to_tb(uint16_t gb);
 | 
					uint16_t gb_to_tb(uint16_t gb);
 | 
				
			||||||
uint8_t tb_to_pb(uint16_t tb);
 | 
					uint8_t tb_to_pb(uint16_t tb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // BLOCK_H_
 | 
					#endif // UTIL_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue