From: John Hodge Date: Wed, 2 Mar 2011 05:01:47 +0000 (+0800) Subject: *partial commit* - Added debut name to VFS_SelectNode X-Git-Tag: rel0.10~171 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f0bebb48a24fc123b179256d986ef1269ff4ecd9;p=tpg%2Facess2.git *partial commit* - Added debut name to VFS_SelectNode --- diff --git a/Kernel/drv/fifo.c b/Kernel/drv/fifo.c index 2af45103..b27c678d 100644 --- a/Kernel/drv/fifo.c +++ b/Kernel/drv/fifo.c @@ -224,7 +224,7 @@ Uint64 FIFO_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) #if 0 len = Semaphore_Wait( &pipe->Semaphore, remaining ); #else - VFS_SelectNode(Node, VFS_SELECT_READ, NULL); + VFS_SelectNode(Node, VFS_SELECT_READ, NULL, "FIFO_Read"); // Read buffer // TODO: Rethink this, it might not work on buffer overflow if(pipe->WritePos - pipe->ReadPos < remaining) @@ -295,7 +295,7 @@ Uint64 FIFO_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) #if 0 len = Semaphore_Signal( &pipe->Semaphore, remaining ); #else - VFS_SelectNode(Node, VFS_SELECT_WRITE, NULL); + VFS_SelectNode(Node, VFS_SELECT_WRITE, NULL, "FIFO_Write"); if(pipe->ReadPos - pipe->WritePos < remaining) len = pipe->ReadPos - pipe->WritePos; else diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index fc89b3a4..31e7a500 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -429,7 +429,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) { // Text Mode (UTF-8) case TERM_MODE_TEXT: - VFS_SelectNode(Node, VFS_SELECT_READ, NULL); + VFS_SelectNode(Node, VFS_SELECT_READ, NULL, "VT_Read (UTF-8)"); avail = term->InputWrite - term->InputRead; if(avail < 0) @@ -449,7 +449,7 @@ Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer) //case TERM_MODE_FB: // Other - UCS-4 default: - VFS_SelectNode(Node, VFS_SELECT_READ, NULL); + VFS_SelectNode(Node, VFS_SELECT_READ, NULL, "VT_Read (UCS-4)"); avail = term->InputWrite - term->InputRead; if(avail < 0) diff --git a/Kernel/include/vfs.h b/Kernel/include/vfs.h index 988a6112..cded047e 100644 --- a/Kernel/include/vfs.h +++ b/Kernel/include/vfs.h @@ -331,6 +331,20 @@ extern int VFS_AddDriver(tVFS_Driver *Info); * \param Name Name of filesystem driver to find */ extern tVFS_Driver *VFS_GetFSByName(const char *Name); + + +/** + * \brief Prepare a node for use + */ +extern void VFS_InitNode(tVFS_Node *Node); + +/** + * \brief Clean up a node, ready for deletion + * \note This should ALWAYS be called before a node is freed, as it + * cleans up VFS internal structures. + */ +extern void VFS_CleanupNode(tVFS_Node *Node); + /** * \fn tVFS_ACL *VFS_UnixToAcessACL(Uint Mode, Uint Owner, Uint Group) * \brief Transforms Unix Permssions into Acess ACLs @@ -355,10 +369,14 @@ enum eVFS_SelectTypes * \param Node Node to wait on * \param Type Type of wait * \param Timeout Time to wait (NULL for infinite wait) + * \param Name Name to show in debug output * \return Number of nodes that actioned (0 or 1) */ -extern int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout); +extern int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout, const char *Name); +/** + * \brief Change the full flag on a node + */ extern int VFS_MarkFull(tVFS_Node *Node, BOOL IsBufferFull); extern int VFS_MarkAvaliable(tVFS_Node *Node, BOOL IsDataAvaliable); extern int VFS_MarkError(tVFS_Node *Node, BOOL IsErrorState); diff --git a/Kernel/vfs/select.c b/Kernel/vfs/select.c index 3a0b292a..85c7d62f 100644 --- a/Kernel/vfs/select.c +++ b/Kernel/vfs/select.c @@ -54,7 +54,7 @@ void VFS_int_Select_SignalAll(tVFS_SelectList *List); // === GLOBALS === // === FUNCTIONS === -int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout) +int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout, const char *Name) { tVFS_SelectThread *thread_info; tVFS_SelectList **list; @@ -70,7 +70,7 @@ int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout) thread_info = malloc(sizeof(tVFS_SelectThread)); if(!thread_info) return -1; - Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_SelectNode()", ""); + Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_SelectNode()", Name); LOG("list=%p, flag=%p, wanted=%i, maxAllowed=%i", list, flag, wanted, maxAllowed); @@ -112,9 +112,12 @@ int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set thread_info = malloc(sizeof(tVFS_SelectThread)); if(!thread_info) return -1; - Semaphore_Init(&thread_info->SleepHandle, 0, -1, "VFS_Select()", ""); + ENTER("iMaxHandle pReadHandles pWriteHandles pErrHandles pTimeout bIsKernel", + MaxHandle, ReadHandles, WriteHandles, ErrHandles, Timeout, IsKernel); - // Notes: The idea is to make sure we onlt enter wait (on the semaphore) + Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_Select()", ""); + + // Notes: The idea is to make sure we only enter wait (on the semaphore) // if we are going to be woken up (either by an event at a later time, // or by an event that happened while or before we were registering). // Hence, register must happen _before_ we check the state flag @@ -126,6 +129,8 @@ int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set ret += VFS_int_Select_Register(thread_info, MaxHandle, WriteHandles, 1, IsKernel); ret += VFS_int_Select_Register(thread_info, MaxHandle, ErrHandles, 2, IsKernel); + LOG("Register ret = %i", ret); + // If there were events waiting, de-register and return if( ret ) { @@ -133,6 +138,7 @@ int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set ret += VFS_int_Select_Deregister(thread_info, MaxHandle, WriteHandles, 1, IsKernel); ret += VFS_int_Select_Deregister(thread_info, MaxHandle, ErrHandles, 2, IsKernel); free(thread_info); + LEAVE('i', ret); return ret; } @@ -150,6 +156,7 @@ int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set ret += VFS_int_Select_Deregister(thread_info, MaxHandle, WriteHandles, 1, IsKernel); ret += VFS_int_Select_Deregister(thread_info, MaxHandle, ErrHandles, 2, IsKernel); free(thread_info); + LEAVE('i', ret); return ret; } @@ -237,6 +244,7 @@ int VFS_int_Select_Register(tVFS_SelectThread *Thread, int MaxHandle, fd_set *Ha // Is the descriptor set if( !FD_ISSET(i, Handles) ) continue; + LOG("FD #%i", i); handle = VFS_GetHandle( i | (IsKernel?VFS_KERNEL_FLAG:0) ); // Is the handle valid? @@ -297,6 +305,7 @@ int VFS_int_Select_Deregister(tVFS_SelectThread *Thread, int MaxHandle, fd_set * // Is the descriptor set if( !FD_ISSET(i, Handles) ) continue; + LOG("FD #%i", i); handle = VFS_GetHandle( i | (IsKernel?VFS_KERNEL_FLAG:0) ); // Is the handle valid?