diff --git a/stage23/fs/file.s2.c b/stage23/fs/file.s2.c index 7e70b065..3f6841f9 100644 --- a/stage23/fs/file.s2.c +++ b/stage23/fs/file.s2.c @@ -114,7 +114,7 @@ struct file_handle *fopen(struct volume *part, const char *filename) { ret->fd = (void *)fd; ret->read = (void *)ntfs_read; - //ret->close = (void *)ntfs_close; + ret->close = (void *)ntfs_close; ret->size = fd->size_bytes; return ret; diff --git a/stage23/fs/ntfs.h b/stage23/fs/ntfs.h index 70ba46d7..46ab9d48 100644 --- a/stage23/fs/ntfs.h +++ b/stage23/fs/ntfs.h @@ -54,7 +54,8 @@ struct ntfs_file_handle { int ntfs_check_signature(struct volume *part); -int ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *path); +bool ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *path); int ntfs_read(struct ntfs_file_handle *file, void *buf, uint64_t loc, uint64_t count); +void ntfs_close(struct ntfs_file_handle *file); #endif \ No newline at end of file diff --git a/stage23/fs/ntfs.s2.c b/stage23/fs/ntfs.s2.c index 733604a6..31fcefeb 100644 --- a/stage23/fs/ntfs.s2.c +++ b/stage23/fs/ntfs.s2.c @@ -514,7 +514,7 @@ static bool ntfs_find_file_in_directory(struct ntfs_file_handle *handle, const c return false; } -int ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *path) { +bool ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *path) { // save the part ret->part = part; @@ -553,7 +553,7 @@ int ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *pat // find the file in the directory entry = NULL; if (!ntfs_find_file_in_directory(ret, current_path, &entry)) - return 1; + return false; size_t filename_len = entry->name_length; @@ -582,7 +582,7 @@ int ntfs_open(struct ntfs_file_handle *ret, struct volume *part, const char *pat // save the run list memcpy(ret->run_list, (uint8_t *)attr + attr->run_offset, sizeof(ret->run_list)); - return 0; + return true; } else { // read the directory @@ -652,3 +652,7 @@ int ntfs_read(struct ntfs_file_handle *file, void *buf, uint64_t loc, uint64_t c // if we didn't read it all then we got a problem return count != 0; } + +void ntfs_close(struct ntfs_file_handle *file) { + pmm_free(file, sizeof(struct ntfs_file_handle)); +}