+ * \brief Create and return a handle number for the given node and mode
+ */
+int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode )
+{
+ int i;
+
+ ENTER("pNode pMount xMode", Node, Mount, Mode);
+
+ i = 0;
+ i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;
+ i |= (Mode & VFS_OPENFLAG_READ) ? VFS_PERM_READ : 0;
+ i |= (Mode & VFS_OPENFLAG_WRITE) ? VFS_PERM_WRITE : 0;
+
+ LOG("i = 0b%b", i);
+
+ // Permissions Check
+ if( !VFS_CheckACL(Node, i) ) {
+ if(Node->Close) Node->Close( Node );
+ Log_Log("VFS", "VFS_int_CreateHandle: Permissions Failed");
+ errno = EACCES;
+ LEAVE_RET('i', -1);
+ }
+
+ i = VFS_AllocHandle( !!(Mode & VFS_OPENFLAG_USER), Node, Mode );
+ if( i < 0 ) {
+ Log_Notice("VFS", "VFS_int_CreateHandle: Out of handles");
+ errno = ENFILE;
+ LEAVE_RET('i', -1);
+ }
+
+ VFS_GetHandle(i)->Mount = Mount;
+
+ LEAVE_RET('x', i);
+}
+
+/**
+ * \fn int VFS_Open(const char *Path, Uint Mode)