// Does the filesystem support this?
if( !mnt->Filesystem->GetNodeFromINode ) {
- LOG("Filesystem does not support inode accesses");
+ Log_Notice("VFS", "Filesystem '%s' does not support inode accesses",
+ mnt->Filesystem->Name);
errno = ENOENT;
LEAVE_RET('i', -1);
}
LEAVE_RET('x', VFS_int_CreateHandle(node, mnt, Mode));
}
+int VFS_Reopen(int FD, const char *Path, int Flags)
+{
+ tVFS_Handle *h = VFS_GetHandle(FD);
+ if(!h) {
+ errno = EBADF;
+ return -1;
+ }
+
+ int newf = VFS_Open(Path, Flags);
+ if( newf == -1 ) {
+ return -1;
+ }
+
+ _CloseNode(h->Node);
+ _DereferenceMount(h->Mount, "Reopen");
+ memcpy(h, VFS_GetHandle(newf), sizeof(*h));
+ _ReferenceNode(h->Node);
+ _ReferenceMount(h->Mount, "Reopen");
+
+ VFS_Close(newf);
+
+ return FD;
+}
+
/**
* \fn void VFS_Close(int FD)
* \brief Closes an open file handle
return -1;
VFS_SetHandle(DstFD, src->Node, src->Mode);
}
+ _ReferenceMount(src->Mount, "DuplicateFD");
+ _ReferenceNode(src->Node);
memcpy(VFS_GetHandle(DstFD), src, sizeof(tVFS_Handle));
return DstFD;
}
int VFS_SetFDFlags(int FD, int Mask, int Value)
{
tVFS_Handle *h = VFS_GetHandle(FD);
- if(!FD) return -1;
+ if(!h) {
+ errno = EBADF;
+ return -1;
+ }
int ret = h->Mode;
Value &= Mask;