mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
linux: Fix newfstatat() syscall
This commit is contained in:
parent
beca151fa6
commit
fa31ade889
@ -2887,12 +2887,9 @@ static int linux_openat(SysFrm *, int dirfd, const char *pathname, int flags, mo
|
|||||||
return -linux_ENOSYS;
|
return -linux_ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Undocumented? */
|
|
||||||
static long linux_newfstatat(SysFrm *, int dirfd, const char *pathname,
|
static long linux_newfstatat(SysFrm *, int dirfd, const char *pathname,
|
||||||
struct linux_kstat *statbuf, int flag)
|
struct linux_kstat *statbuf, int flag)
|
||||||
{
|
{
|
||||||
/* FIXME: This function is not working at all? */
|
|
||||||
|
|
||||||
PCB *pcb = thisProcess;
|
PCB *pcb = thisProcess;
|
||||||
vfs::FileDescriptorTable *fdt = pcb->FileDescriptors;
|
vfs::FileDescriptorTable *fdt = pcb->FileDescriptors;
|
||||||
Memory::VirtualMemoryArea *vma = pcb->vma;
|
Memory::VirtualMemoryArea *vma = pcb->vma;
|
||||||
@ -2907,32 +2904,45 @@ static long linux_newfstatat(SysFrm *, int dirfd, const char *pathname,
|
|||||||
|
|
||||||
debug("%s %#lx %#lx", pPathname, pathname, statbuf);
|
debug("%s %#lx %#lx", pPathname, pathname, statbuf);
|
||||||
|
|
||||||
if (dirfd == linux_AT_FDCWD && !fs->PathIsRelative(pPathname))
|
if (fs->PathIsAbsolute(pPathname))
|
||||||
{
|
{
|
||||||
FileNode *absoluteNode = fs->GetByPath(pPathname, pcb->CWD);
|
|
||||||
if (!absoluteNode)
|
|
||||||
return -linux_ENOENT;
|
|
||||||
|
|
||||||
const char *absPath = new char[strlen(absoluteNode->Path.c_str()) + 1];
|
|
||||||
strcpy((char *)absPath, absoluteNode->Path.c_str());
|
|
||||||
struct kstat nstat = KStatToStat(*pStatbuf);
|
struct kstat nstat = KStatToStat(*pStatbuf);
|
||||||
int ret = fdt->usr_stat(absPath, &nstat);
|
int ret = fdt->usr_stat(pPathname, &nstat);
|
||||||
*pStatbuf = StatToKStat(nstat);
|
*pStatbuf = StatToKStat(nstat);
|
||||||
delete[] absPath;
|
|
||||||
return ConvertErrnoToLinux(ret);
|
return ConvertErrnoToLinux(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (dirfd)
|
||||||
|
{
|
||||||
|
case linux_AT_FDCWD:
|
||||||
|
{
|
||||||
|
FileNode *node = fs->GetByPath(pPathname, pcb->CWD);
|
||||||
|
if (!node)
|
||||||
|
return -linux_ENOENT;
|
||||||
|
|
||||||
|
struct kstat nstat = {};
|
||||||
|
int ret = fdt->usr_stat(node->GetPath().c_str(), &nstat);
|
||||||
|
*pStatbuf = StatToKStat(nstat);
|
||||||
|
return ConvertErrnoToLinux(ret);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
auto it = fdt->FileMap.find(dirfd);
|
auto it = fdt->FileMap.find(dirfd);
|
||||||
if (it == fdt->FileMap.end())
|
if (it == fdt->FileMap.end())
|
||||||
ReturnLogError(-linux_EBADF, "Invalid fd %d", dirfd);
|
ReturnLogError(-linux_EBADF, "Invalid fd %d", dirfd);
|
||||||
|
|
||||||
vfs::FileDescriptorTable::Fildes &fildes = it->second;
|
vfs::FileDescriptorTable::Fildes &fildes = it->second;
|
||||||
|
FileNode *node = fs->GetByPath(pPathname, fildes.Node);
|
||||||
|
if (!node)
|
||||||
|
return -linux_ENOENT;
|
||||||
|
|
||||||
struct kstat nstat = KStatToStat(*pStatbuf);
|
struct kstat nstat = {};
|
||||||
int ret = fdt->usr_stat(pPathname, &nstat);
|
int ret = fdt->usr_stat(node->GetPath().c_str(), &nstat);
|
||||||
*pStatbuf = StatToKStat(nstat);
|
*pStatbuf = StatToKStat(nstat);
|
||||||
return ConvertErrnoToLinux(ret);
|
return ConvertErrnoToLinux(ret);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int linux_pipe2(SysFrm *sf, int pipefd[2], int flags)
|
static int linux_pipe2(SysFrm *sf, int pipefd[2], int flags)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user