Fixed bug in dup(2).
This commit is contained in:
parent
fccad5e31c
commit
708643d0f2
|
@ -1,80 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
|
|
||||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
|
||||||
|
|
||||||
This file is part of Sortix.
|
|
||||||
|
|
||||||
Sortix is free software: you can redistribute it and/or modify it under the
|
|
||||||
terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation, either version 3 of the License, or (at your option) any later
|
|
||||||
version.
|
|
||||||
|
|
||||||
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
|
||||||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
filesystem.cpp
|
|
||||||
Abstracts away a file system device.
|
|
||||||
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "device.h"
|
|
||||||
#include "thread.h"
|
|
||||||
#include "process.h"
|
|
||||||
#include "filesystem.h"
|
|
||||||
|
|
||||||
namespace Sortix
|
|
||||||
{
|
|
||||||
bool DevFileSystem::LegalNodeName(const char* name)
|
|
||||||
{
|
|
||||||
if ( *name == '\0' ) { return false; }
|
|
||||||
while ( *name != '\0' )
|
|
||||||
{
|
|
||||||
if ( *name == '/' ) { return false; }
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DevFileSystem::Open(const char* path, nat openFlags, nat mode, Mount::SysCallback* callbackInfo, Thread* thread)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
nat requestMode = flags & O_LOWERFLAGS;
|
|
||||||
|
|
||||||
MXFSNode* node;
|
|
||||||
|
|
||||||
if ( flags & O_CREAT )
|
|
||||||
{
|
|
||||||
if ( flags & O_DIRECTORY ) { return CreateDirectory(path, flags, permissions, type); }
|
|
||||||
else { return CreateFile(path, flags, permissions, type); }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
node = Search(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( node == NULL ) { return NULL; }
|
|
||||||
|
|
||||||
if ( node->IsDir() )
|
|
||||||
{
|
|
||||||
if ( requestMode == O_SEARCH || requestMode == O_RDONLY )
|
|
||||||
{
|
|
||||||
// TODO: Make a directory device.
|
|
||||||
Error::Set(Error::NOTIMPLEMENTED);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Error::Set(Error::ISDIR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -131,7 +131,6 @@ namespace Sortix
|
||||||
Process* process = CurrentProcess();
|
Process* process = CurrentProcess();
|
||||||
Device* dev = process->descriptors.Get(fd);
|
Device* dev = process->descriptors.Get(fd);
|
||||||
if ( !dev ) { return -1; /* TODO: EBADF */ }
|
if ( !dev ) { return -1; /* TODO: EBADF */ }
|
||||||
process->descriptors.Free(fd);
|
|
||||||
return process->descriptors.Allocate(dev);
|
return process->descriptors.Allocate(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue