Skip to content

Commit a09e465

Browse files
author
di
committed
[FS] opening file failure now reported properly
1 parent ac003fc commit a09e465

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

kernel/filesystem/fat32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ FS_RESULT FAT32FS::open_file(const char* path, file* descriptor){
256256
uint32_t count = count_FAT(mbs->first_cluster_of_root_directory);
257257
sizedptr buf_ptr = walk_directory(count, mbs->first_cluster_of_root_directory, path, read_entry_handler);
258258
void *buf = (void*)buf_ptr.ptr;
259-
if (!buf) return FS_RESULT_NOTFOUND;
259+
if (!buf || !buf_ptr.size) return FS_RESULT_NOTFOUND;
260260
descriptor->id = fid;
261261
descriptor->size = buf_ptr.size;
262262
mfile = (module_file*)kalloc(fs_page, sizeof(module_file), ALIGN_64B, MEM_PRIV_KERNEL);

kernel/filesystem/filesystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ FS_RESULT open_file_global(const char* path, file* descriptor, system_module **m
154154
//TODO: exclusive write. Keep track of permissions for opening, if writing is already taken, don't grant. Could allow non-exclusive write as well with manual cursor seek
155155
FS_RESULT open_file(const char* path, file* descriptor){
156156
system_module *mod = 0;
157-
open_file_global(path, descriptor, &mod);
157+
FS_RESULT result = open_file_global(path, descriptor, &mod);
158+
if (result != FS_RESULT_SUCCESS) return result;
158159
open_file_descriptors *of = (open_file_descriptors*)kalloc(page, sizeof(open_file_descriptors), ALIGN_16B, MEM_PRIV_KERNEL);
159160
of->mfile_id = descriptor->id;
160161
of->file_id = reserve_fd_id();

shared/files/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ typedef enum SEEK_TYPE {
1818
} SEEK_TYPE;
1919

2020
typedef enum FS_RESULT {
21+
FS_RESULT_DRIVER_ERROR,
2122
FS_RESULT_SUCCESS,
2223
FS_RESULT_NOTFOUND,
23-
FS_RESULT_DRIVER_ERROR,
2424
} FS_RESULT;

0 commit comments

Comments
 (0)