X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fvfs%2Fopen.c;h=f0b5734a4ec13696d5e590b64314c0842e090fd8;hb=7b64f5e7f00e445a5637e9e3289a1332a14d28e5;hp=2bfb261232058562ed881b2be1cde57c7ea3cac2;hpb=015f48988e0ff398409d71dfc692005ab439490a;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/vfs/open.c b/KernelLand/Kernel/vfs/open.c index 2bfb2612..f0b5734a 100644 --- a/KernelLand/Kernel/vfs/open.c +++ b/KernelLand/Kernel/vfs/open.c @@ -296,7 +296,7 @@ restart_parse: pathEle[nextSlash] = 0; // Check permissions on root of filesystem - if( !VFS_CheckACL(curNode, VFS_PERM_EXECUTE) ) { + if( !VFS_CheckACL(curNode, VFS_PERM_EXEC) ) { LOG("Permissions failure on '%s'", Path); errno = EPERM; goto _error; @@ -474,7 +474,7 @@ int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode ) ENTER("pNode pMount xMode", Node, Mount, Mode); i = 0; - i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0; + i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXEC : 0; i |= (Mode & VFS_OPENFLAG_READ) ? VFS_PERM_READ : 0; i |= (Mode & VFS_OPENFLAG_WRITE) ? VFS_PERM_WRITE : 0; @@ -557,7 +557,7 @@ int VFS_OpenEx(const char *Path, Uint Flags, Uint Mode) } // Check ACLs on the parent - if( !VFS_CheckACL(pnode, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) { + if( !VFS_CheckACL(pnode, VFS_PERM_EXEC|VFS_PERM_WRITE) ) { errno = EACCES; goto _pnode_err; } @@ -706,7 +706,8 @@ int VFS_OpenInode(Uint32 Mount, Uint64 Inode, int Mode) // 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); } @@ -722,6 +723,30 @@ int VFS_OpenInode(Uint32 Mount, Uint64 Inode, int Mode) 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 @@ -774,6 +799,8 @@ int VFS_DuplicateFD(int SrcFD, int DstFD) 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; } @@ -784,7 +811,10 @@ int VFS_DuplicateFD(int SrcFD, int 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;