mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-27 15:04:33 +00:00
Fix file creation and append functionality
This commit is contained in:
parent
e42759147e
commit
a09dfe274a
@ -194,6 +194,12 @@ namespace vfs
|
|||||||
debug("%s: File already exists, continuing...",
|
debug("%s: File already exists, continuing...",
|
||||||
AbsolutePath);
|
AbsolutePath);
|
||||||
}
|
}
|
||||||
|
else if (Flags & O_EXCL)
|
||||||
|
{
|
||||||
|
debug("%s: File already exists, returning EEXIST",
|
||||||
|
AbsolutePath);
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
{
|
{
|
||||||
error("Failed to create file %s: %d",
|
error("Failed to create file %s: %d",
|
||||||
@ -202,30 +208,11 @@ namespace vfs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags & O_EXCL)
|
|
||||||
{
|
|
||||||
RefNode *File = fs->Open(AbsolutePath,
|
|
||||||
pcb->CurrentWorkingDirectory);
|
|
||||||
|
|
||||||
if (!File)
|
|
||||||
{
|
|
||||||
error("Failed to open file %s",
|
|
||||||
AbsolutePath);
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
delete File;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags & O_TRUNC)
|
if (Flags & O_TRUNC)
|
||||||
{
|
{
|
||||||
fixme("O_TRUNC");
|
fixme("O_TRUNC");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags & O_APPEND)
|
|
||||||
{
|
|
||||||
fixme("O_APPEND");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags & O_CLOEXEC)
|
if (Flags & O_CLOEXEC)
|
||||||
{
|
{
|
||||||
fixme("O_CLOEXEC");
|
fixme("O_CLOEXEC");
|
||||||
@ -241,6 +228,12 @@ namespace vfs
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Flags & O_APPEND)
|
||||||
|
{
|
||||||
|
debug("Appending to file %s", AbsolutePath);
|
||||||
|
File->seek(0, SEEK_END);
|
||||||
|
}
|
||||||
|
|
||||||
Fildes fd = {.Descriptor = GetFreeFileDescriptor()};
|
Fildes fd = {.Descriptor = GetFreeFileDescriptor()};
|
||||||
|
|
||||||
if (fd.Descriptor < 0)
|
if (fd.Descriptor < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user