From 6725972e1125ad1b52690302e994173aaa65d78f Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 20 Sep 2015 21:41:31 +0200 Subject: [PATCH] Fix LinkInodeInDir return value. The callers expected it to return an int different than 0 on failure. The link method returns different than 0 on failure. This actually worked by lucky coincidence. Change the return type to int and 0 on success, and -1 on failure per popular demand. Thanks to Meisaka Yukara for spotting this. --- kernel/descriptor.cpp | 14 +++++++------- kernel/include/sortix/kernel/descriptor.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/descriptor.cpp b/kernel/descriptor.cpp index 55a9b3db..6584c5f3 100644 --- a/kernel/descriptor.cpp +++ b/kernel/descriptor.cpp @@ -61,18 +61,18 @@ static const int OPEN_FLAGS = O_CREATE | O_DIRECTORY | O_EXCL | O_TRUNC | // Flags that only make sense for descriptors. static const int DESCRIPTOR_FLAGS = O_APPEND | O_NONBLOCK; -bool LinkInodeInDir(ioctx_t* ctx, - Ref dir, - const char* name, - Ref inode) +int LinkInodeInDir(ioctx_t* ctx, + Ref dir, + const char* name, + Ref inode) { Ref vnode(new Vnode(inode, Ref(), 0, 0)); if ( !vnode ) - return false; + return -1; Ref desc(new Descriptor(Ref(vnode), 0)); if ( !desc ) - return false; - return dir->link(ctx, name, desc) != 0; + return -1; + return dir->link(ctx, name, desc); } Ref OpenDirContainingPath(ioctx_t* ctx, diff --git a/kernel/include/sortix/kernel/descriptor.h b/kernel/include/sortix/kernel/descriptor.h index 96678092..0ae96ada 100644 --- a/kernel/include/sortix/kernel/descriptor.h +++ b/kernel/include/sortix/kernel/descriptor.h @@ -132,8 +132,8 @@ private: }; -bool LinkInodeInDir(ioctx_t* ctx, Ref dir, const char* name, - Ref inode); +int LinkInodeInDir(ioctx_t* ctx, Ref dir, const char* name, + Ref inode); Ref OpenDirContainingPath(ioctx_t* ctx, Ref from, const char* path, char** finalp);