diff --git a/lsfs_disk_controller.h b/lsfs_disk_controller.h index d5b844c..c7ebd6a 100644 --- a/lsfs_disk_controller.h +++ b/lsfs_disk_controller.h @@ -34,7 +34,7 @@ int create_file_system(char* disk_name, char* hdd_or_partition, uint64_t filesys int lsfs_disk_create_entry(const char* path, Table_Entry_Kind entry_kind); Directory_Table* lsfs_find_directory(const char* path, bool drop_filename); int lsfs_disk_getattr(lsfs_file* find_file, const char *path); -int lsfs_disk_delete_file(lsfs_file_id file_id); +int lsfs_disk_delete_file(lsfs_file *file); int get_free_sectors_table(); int get_free_sectors(int num_sectors_needed, lsfs_sector_offset* output_array); int lsfs_disk_read_data_from_file(lsfs_file* file, int buffer_size, void* buffer_for_data); @@ -368,15 +368,12 @@ int lsfs_disk_rename_file(lsfs_file* file, const char* new_filename) { return 0; } -int lsfs_disk_delete_file(lsfs_file_id file_id) { - mif* mif_record = calloc(1, SECTOR_SIZE); - read_data_from_disk(file_id, 1, mif_record); - - - // TODO Delete/free all data sectors. - // Delete/free the mif record sector. - - free(mif_record); +int lsfs_disk_delete_file(lsfs_file *file) { + Table_Entry *zero_buffer = calloc(1, (DEFAULT_ENTRY_SIZE * SECTOR_SIZE)); + //read_data_from_disk(file_id, 1, mif_record); + write_data_to_disk(file->table_entry_sector_index, DEFAULT_TABLE_SIZE, zero_buffer); + + free(zero_buffer); return 1; } diff --git a/lsfs_fuse b/lsfs_fuse index e6a53dd..db7d14c 100755 Binary files a/lsfs_fuse and b/lsfs_fuse differ diff --git a/lsfs_fuse.c b/lsfs_fuse.c index c87672d..908c4a5 100644 --- a/lsfs_fuse.c +++ b/lsfs_fuse.c @@ -59,7 +59,11 @@ int lsfs_rmdir(const char *path) { int lsfs_unlink(const char *path) { - // remove / delete a file + lsfs_file *found_file = calloc(1, sizeof(lsfs_file)); + + lsfs_disk_getattr(found_file, path); + lsfs_disk_delete_file(found_file); + free(found_file); return 0; } @@ -126,21 +130,13 @@ int lsfs_getattr( const char *path, struct stat *stbuf ) { return res; } -int lsfs_write(const char *path, const char *content, size_t content_length, off_t offset_to_next_entry, struct fuse_file_info *file_info) { - //(void) offset_to_next_entry; - //(void) file_info; - int res; - //printf("WRITE: offset id: %d\n", offset_to_next_entry); - // printf("read: (path=%s)\n", path); - - //time_t current_time; - //time ( ¤t_time ); - - res = lsfs_disk_write_data_to_file(((lsfs_file*) file_info->fh), content_length, (void*) content, offset_to_next_entry); +int lsfs_write(const char *path, const char *content, size_t content_length, off_t offset_to_next_entry, struct fuse_file_info *file_info) +{ + int res = lsfs_disk_write_data_to_file( + ((lsfs_file*) file_info->fh), + content_length, + (void*) content, offset_to_next_entry); - //((lsfs_file*) file_info->fh)->size += res; - //((lsfs_file*) file_info->fh)->access_time = current_time; - //((lsfs_file*) file_info->fh)->modification_time = current_time; return res; } diff --git a/lsfs_fuse.o b/lsfs_fuse.o index 66369a8..18cf29a 100644 Binary files a/lsfs_fuse.o and b/lsfs_fuse.o differ