From 35d522d38878c31005d2a4c0f4403c4baddf8099 Mon Sep 17 00:00:00 2001 From: Itay Almog Date: Fri, 21 Jan 2022 16:39:18 +0200 Subject: [PATCH] added required fixes to make ntfs work again --- stage23/fs/file.s2.c | 2 +- stage23/fs/ntfs.h | 3 ++- stage23/fs/ntfs.s2.c | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) 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)); +}