7 extern tVFS_Mount *gRootMount;
10 int VFS_MkDir(char *Path);
11 int VFS_MkNod(char *Path, Uint Flags);
15 * \fn int VFS_MkDir(char *Path)
16 * \brief Create a new node
17 * \param Path Path of directory to create
19 int VFS_MkDir(char *Path)
21 return VFS_MkNod(Path, VFS_FFLAG_DIRECTORY);
25 * \fn int VFS_MkNod(char *Path, Uint Flags)
26 * \brief Create a new node in a directory
27 * \param Path Path of new node
28 * \param Flags Flags to apply to the node
30 int VFS_MkNod(char *Path, Uint Flags)
33 int pos=0, oldpos = 0;
37 Debug_Enter("VFS_MkNod", "sPath xFlags", Path, Flags);
39 absPath = VFS_GetAbsPath(Path);
41 while( (pos = strpos8(&absPath[pos+1], '/')) != -1 ) oldpos = pos;
42 absPath[oldpos] = '\0'; // Mutilate path
43 name = &absPath[oldpos+1];
46 if(absPath[0] == '\0')
47 parent = VFS_ParsePath("/", NULL);
49 parent = VFS_ParsePath(absPath, NULL);
51 if(!parent) return -1; // Error Check
54 if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
55 if(parent->Close) parent->Close( parent );
57 Debug_Leave("VFS_MkNod", 'i', -1);
61 Debug_Log("VFS_MkNod", "parent = %p\n", parent);
63 if(parent->MkNod == NULL) {
64 Warning("VFS_MkNod - Directory has no MkNod method");
65 Debug_Leave("VFS_MkNod", 'i', -1);
70 ret = parent->MkNod(parent, name, Flags);
72 // Free allocated string
76 if(parent->Close) parent->Close( parent );
79 if(ret == 0) return -1;
81 Debug_Leave("VFS_MkNod", 'i', 0);
86 * \fn int VFS_Symlink(char *Name, char *Link)
87 * \brief Creates a symlink called \a Name to \a Link
88 * \param Name Name of symbolic link
89 * \param Link Destination of symbolic link
91 int VFS_Symlink(char *Name, char *Link)
97 //LogF("vfs_symlink: (name='%s', link='%s')\n", name, link);
99 // Get absolue path name
100 Link = VFS_GetAbsPath( Link );
102 Warning("Path '%s' is badly formed", Link);
106 // Get true path and node
107 destNode = VFS_ParsePath( Link, &realLink );
110 // Check if destination exists
112 Warning("File '%s' does not exist, symlink not created", Link);
116 // Derefence the destination
117 if(destNode->Close) destNode->Close(destNode);
120 if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) {
121 Warning("Unable to create link node '%s'", Name);
122 return -2; // Make link node
125 // Write link address
126 fp = VFS_Open(Name, VFS_OPENFLAG_WRITE|VFS_OPENFLAG_NOLINK);
127 VFS_Write(fp, strlen(realLink), realLink);