mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fixed error codes in sortix/fs/initfs.
This commit is contained in:
parent
f45cf8327a
commit
245e8bf0e3
1 changed files with 8 additions and 8 deletions
|
@ -205,22 +205,22 @@ namespace Sortix
|
||||||
Device* DevInitFS::Open(const char* path, int flags, mode_t mode)
|
Device* DevInitFS::Open(const char* path, int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
size_t buffersize;
|
size_t buffersize;
|
||||||
|
int lowerflags = flags & O_LOWERFLAGS;
|
||||||
|
|
||||||
if ( (flags & O_LOWERFLAGS) == O_SEARCH )
|
if ( !path[0] || (path[0] == '/' && !path[1]) )
|
||||||
{
|
{
|
||||||
if ( path[0] == 0 || (path[0] == '/' && path[1] == 0) ) { return new DevInitFSDir; }
|
if ( lowerflags != O_SEARCH ) { Error::Set(EISDIR); return NULL; }
|
||||||
const byte* buffer = InitRD::Open(path, &buffersize);
|
return new DevInitFSDir();
|
||||||
Error::Set(buffer ? ENOTDIR : ENOENT);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *path++ != '/' ) { return NULL; }
|
if ( *path++ != '/' ) { Error::Set(ENOENT); return NULL; }
|
||||||
|
|
||||||
if ( (flags & O_LOWERFLAGS) != O_RDONLY ) { Error::Set(EROFS); return NULL; }
|
|
||||||
|
|
||||||
const byte* buffer = InitRD::Open(path, &buffersize);
|
const byte* buffer = InitRD::Open(path, &buffersize);
|
||||||
if ( !buffer ) { Error::Set(ENOENT); return NULL; }
|
if ( !buffer ) { Error::Set(ENOENT); return NULL; }
|
||||||
|
|
||||||
|
if ( lowerflags == O_SEARCH ) { Error::Set(ENOTDIR); return NULL; }
|
||||||
|
if ( lowerflags != O_RDONLY ) { Error::Set(EROFS); return NULL; }
|
||||||
|
|
||||||
char* newpath = String::Clone(path);
|
char* newpath = String::Clone(path);
|
||||||
if ( !newpath ) { Error::Set(ENOSPC); return NULL; }
|
if ( !newpath ) { Error::Set(ENOSPC); return NULL; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue