int VFS_MkDir(const char *Path);
#endif
int VFS_MkNod(const char *Path, Uint Flags);
+// int VFS_Symlink(const char *Name, const char *Link);
// === CODE ===
/**
{
char *realLink;
int fp;
- tVFS_Node *destNode;
char *_link;
- //ENTER("sName sLink", Name, Link);
+ ENTER("sName sLink", Name, Link);
// Get absolue path name
_link = VFS_GetAbsPath( Link );
if(!_link) {
Log_Warning("VFS", "Path '%s' is badly formed", Link);
+ LEAVE('i', -1);
return -1;
}
+
+ LOG("_link = '%s'", _link);
- destNode = VFS_ParsePath( _link, &realLink, NULL );
+ #if 1
+ {
+ tVFS_Node *destNode = VFS_ParsePath( _link, &realLink, NULL );
#if 0
// Get true path and node
free(_link);
// Derefence the destination
if(destNode->Close) destNode->Close(destNode);
-
+ }
+ #else
+ realLink = _link;
+ #endif
+ LOG("realLink = '%s'", realLink);
+
// Make node
if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) {
Log_Warning("VFS", "Unable to create link node '%s'", Name);
+ LEAVE('i', -2);
return -2; // Make link node
}
free(realLink);
+ LEAVE('i', 1);
return 1;
}
// === CONSTANTS ===
#define MAX_FILES 64
+#define MAX_FILE_SIZE 1024
// === PROTOTYPES ===
tVFS_Node *Root_InitDevice(const char *Device, const char **Options);
Uint64 Root_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
{
tRamFS_File *file = Node->ImplPtr;
+ ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
- if(Offset > Node->Size) return 0;
- if(Length > Node->Size) return 0;
+ if(Offset > Node->Size) {
+ LEAVE('i', 0);
+ return 0;
+ }
+ if(Length > Node->Size) Length = Node->Size;
if(Offset+Length > Node->Size)
Length = Node->Size - Offset;
memcpy(Buffer, file->Data.Bytes+Offset, Length);
-
+ LOG("Buffer = '%.*s'", (int)Length, Buffer);
+
+ LEAVE('i', Length);
return Length;
}
Uint64 Root_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
{
tRamFS_File *file = Node->ImplPtr;
+
+ ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
+
+ if(Offset > Node->Size) {
+ LEAVE('i', -1);
+ return -1;
+ }
+
+ if(Offset + Length > MAX_FILE_SIZE)
+ {
+ Length = MAX_FILE_SIZE - Offset;
+ }
+
+ LOG("Buffer = '%.*s'", (int)Length, Buffer);
// Check if buffer needs to be expanded
if(Offset + Length > Node->Size)
void *tmp = realloc( file->Data.Bytes, Offset + Length );
if(tmp == NULL) {
Warning("Root_Write - Increasing buffer size failed");
+ LEAVE('i', -1);
return -1;
}
file->Data.Bytes = tmp;
Node->Size = Offset + Length;
- //LOG("Expanded buffer to %i bytes", Node->Size);
+ LOG("Expanded buffer to %i bytes", (int)Node->Size);
}
memcpy(file->Data.Bytes+Offset, Buffer, Length);
+ LOG("File - '%.*s'", Node->Size, file->Data.Bytes);
+ LEAVE('i', Length);
return Length;
}
}
curNode->Read( curNode, 0, curNode->Size, path_buffer );
path_buffer[ curNode->Size ] = '\0';
+ LOG("path_buffer = '%s'", path_buffer);
strcat(path_buffer, Path + ofs+nextSlash);
Path = path_buffer;
}
// EVIL: Goto :)
+ LOG("Symlink -> '%s', restart", Path);
goto restart_parse;
}
{
int i;
- ENTER("pNode pMount iMode", Node, Mount, Mode);
+ ENTER("pNode pMount xMode", Node, Mount, Mode);
i = 0;
i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;