From e4f0d7962b085a7b4dab8b1160aace8262ea79fe Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Mon, 23 Apr 2018 14:42:32 +0300 Subject: [PATCH] Check kos_fuse_init() return value, exit if it fails. --- kocdecl.asm | 3 ++- kocdecl.h | 3 ++- kofu.c | 4 +++- kofuse.c | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kocdecl.asm b/kocdecl.asm index 6020c0a..e90555d 100644 --- a/kocdecl.asm +++ b/kocdecl.asm @@ -69,6 +69,7 @@ kos_fuse_init: mov ecx, msg_not_xfs_partition mov edx, msg_not_xfs_partition.size int 0x80 + xor eax, eax @@: mov [fs_struct], eax @@ -262,7 +263,7 @@ include_debug_strings partition_offset dd 2048*512 alloc_pos dd alloc_base sf70_params rd 6 -msg_not_xfs_partition db 'not xfs partition',0x0a ; TODO: return codes, report in C +msg_not_xfs_partition db 'not XFS partition',0x0a ; TODO: return codes, report in C msg_not_xfs_partition.size = $ - msg_not_xfs_partition IncludeIGlobals diff --git a/kocdecl.h b/kocdecl.h index 2ca2432..c2b6b3a 100644 --- a/kocdecl.h +++ b/kocdecl.h @@ -2,6 +2,7 @@ #define KOS_H_INCLUDED #include +#include struct bdfe { uint32_t attr; @@ -22,7 +23,7 @@ struct bdfe { #define KF_LABEL 0x08 #define KF_FOLDER 0x10 -void kos_fuse_init(int fd); +bool kos_fuse_init(int fd); uint8_t *kos_fuse_readdir(const char *path, off_t offset); void *kos_fuse_getattr(const char *path); long *kos_fuse_read(const char *path, char *buf, size_t size, off_t offset); diff --git a/kofu.c b/kofu.c index 507af9b..7f6f0d4 100644 --- a/kofu.c +++ b/kofu.c @@ -22,7 +22,9 @@ int main(int argc, char **argv) { char cmd_buf[4096]; int fd = open(argv[1], O_RDONLY); - kos_fuse_init(fd); + if (!kos_fuse_init(fd)) { + exit(1); + } //msg_few_args db 'usage: xfskos image [offset]',0x0a //msg_file_not_found db 'file not found: ' diff --git a/kofuse.c b/kofuse.c index d858db7..29d0c65 100644 --- a/kofuse.c +++ b/kofuse.c @@ -61,6 +61,7 @@ static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler, static int hello_open(const char *path, struct fuse_file_info *fi) { // if (strcmp(path+1, "blah") != 0) // return -ENOENT; + (void) path; if ((fi->flags & O_ACCMODE) != O_RDONLY) return -EACCES;