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.
This commit is contained in:
parent
275541383c
commit
6725972e11
|
@ -61,18 +61,18 @@ static const int OPEN_FLAGS = O_CREATE | O_DIRECTORY | O_EXCL | O_TRUNC |
|
||||||
// Flags that only make sense for descriptors.
|
// Flags that only make sense for descriptors.
|
||||||
static const int DESCRIPTOR_FLAGS = O_APPEND | O_NONBLOCK;
|
static const int DESCRIPTOR_FLAGS = O_APPEND | O_NONBLOCK;
|
||||||
|
|
||||||
bool LinkInodeInDir(ioctx_t* ctx,
|
int LinkInodeInDir(ioctx_t* ctx,
|
||||||
Ref<Descriptor> dir,
|
Ref<Descriptor> dir,
|
||||||
const char* name,
|
const char* name,
|
||||||
Ref<Inode> inode)
|
Ref<Inode> inode)
|
||||||
{
|
{
|
||||||
Ref<Vnode> vnode(new Vnode(inode, Ref<Vnode>(), 0, 0));
|
Ref<Vnode> vnode(new Vnode(inode, Ref<Vnode>(), 0, 0));
|
||||||
if ( !vnode )
|
if ( !vnode )
|
||||||
return false;
|
return -1;
|
||||||
Ref<Descriptor> desc(new Descriptor(Ref<Vnode>(vnode), 0));
|
Ref<Descriptor> desc(new Descriptor(Ref<Vnode>(vnode), 0));
|
||||||
if ( !desc )
|
if ( !desc )
|
||||||
return false;
|
return -1;
|
||||||
return dir->link(ctx, name, desc) != 0;
|
return dir->link(ctx, name, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Descriptor> OpenDirContainingPath(ioctx_t* ctx,
|
Ref<Descriptor> OpenDirContainingPath(ioctx_t* ctx,
|
||||||
|
|
|
@ -132,8 +132,8 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool LinkInodeInDir(ioctx_t* ctx, Ref<Descriptor> dir, const char* name,
|
int LinkInodeInDir(ioctx_t* ctx, Ref<Descriptor> dir, const char* name,
|
||||||
Ref<Inode> inode);
|
Ref<Inode> inode);
|
||||||
Ref<Descriptor> OpenDirContainingPath(ioctx_t* ctx, Ref<Descriptor> from,
|
Ref<Descriptor> OpenDirContainingPath(ioctx_t* ctx, Ref<Descriptor> from,
|
||||||
const char* path, char** finalp);
|
const char* path, char** finalp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue