+ tVFS_SelectThread *thread_info;
+ tVFS_SelectList **list;
+ int *flag, wanted, maxAllowed;
+
+ ENTER("pNode iType pTimeout", Node, Type, Timeout);
+
+ if( VFS_int_Select_GetType(Type, Node, &list, &flag, &wanted, &maxAllowed) ) {
+ LEAVE('i', -1);
+ return -1;
+ }
+
+ thread_info = malloc(sizeof(tVFS_SelectThread));
+ if(!thread_info) return -1;
+
+ Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_SelectNode()", Name);
+
+ LOG("list=%p, flag=%p, wanted=%i, maxAllowed=%i", list, flag, wanted, maxAllowed);
+
+ // Alloc if needed
+ if( !*list ) {
+ *list = calloc(1, sizeof(tVFS_SelectList));
+ }
+
+ VFS_int_Select_AddThread(*list, thread_info, maxAllowed);
+ if( *flag == wanted )
+ {
+ VFS_int_Select_RemThread(*list, thread_info);
+ free(thread_info);
+ LEAVE('i', 1);
+ return 1;
+ }
+
+ if( !Timeout || *Timeout > 0 )
+ {
+ LOG("Semaphore_Wait()");
+ // TODO: Actual timeout
+ Semaphore_Wait(&thread_info->SleepHandle, 1);
+ }
+
+ LOG("VFS_int_Select_RemThread()");
+ VFS_int_Select_RemThread(*list, thread_info);
+
+ free(thread_info);
+
+ LEAVE('i', *flag == wanted);
+ return *flag == wanted;
+}
+
+int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel)
+{
+ tVFS_SelectThread *thread_info;