3 * - Directory Management Functions
11 extern tVFS_Mount *gRootMount;
14 int VFS_MkDir(char *Path);
15 int VFS_MkNod(char *Path, Uint Flags);
19 * \fn int VFS_MkDir(char *Path)
20 * \brief Create a new node
21 * \param Path Path of directory to create
23 int VFS_MkDir(char *Path)
25 return VFS_MkNod(Path, VFS_FFLAG_DIRECTORY);
29 * \fn int VFS_MkNod(char *Path, Uint Flags)
30 * \brief Create a new node in a directory
31 * \param Path Path of new node
32 * \param Flags Flags to apply to the node
34 int VFS_MkNod(char *Path, Uint Flags)
37 int pos=0, oldpos = 0;
41 ENTER("sPath xFlags", Path, Flags);
43 absPath = VFS_GetAbsPath(Path);
45 while( (pos = strpos8(&absPath[pos+1], '/')) != -1 ) oldpos = pos;
46 absPath[oldpos] = '\0'; // Mutilate path
47 name = &absPath[oldpos+1];
50 if(absPath[0] == '\0')
51 parent = VFS_ParsePath("/", NULL);
53 parent = VFS_ParsePath(absPath, NULL);
55 if(!parent) return -1; // Error Check
58 if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
59 if(parent->Close) parent->Close( parent );
65 LOG("parent = %p\n", parent);
67 if(parent->MkNod == NULL) {
68 Warning("VFS_MkNod - Directory has no MkNod method");
74 ret = parent->MkNod(parent, name, Flags);
76 // Free allocated string
80 if(parent->Close) parent->Close( parent );
93 * \fn int VFS_Symlink(char *Name, char *Link)
94 * \brief Creates a symlink called \a Name to \a Link
95 * \param Name Name of symbolic link
96 * \param Link Destination of symbolic link
98 int VFS_Symlink(char *Name, char *Link)
104 //ENTER("sName sLink", Name, Link);
106 // Get absolue path name
107 Link = VFS_GetAbsPath( Link );
109 Warning("Path '%s' is badly formed", Link);
113 // Get true path and node
114 destNode = VFS_ParsePath( Link, &realLink );
117 // Check if destination exists
119 Warning("File '%s' does not exist, symlink not created", Link);
123 // Derefence the destination
124 if(destNode->Close) destNode->Close(destNode);
127 if( VFS_MkNod(Name, VFS_FFLAG_SYMLINK) != 0 ) {
128 Warning("Unable to create link node '%s'", Name);
129 return -2; // Make link node
132 // Write link address
133 fp = VFS_Open(Name, VFS_OPENFLAG_WRITE|VFS_OPENFLAG_NOLINK);
134 VFS_Write(fp, strlen(realLink), realLink);
143 * \fn int VFS_ReadDir(int FD, char *Dest)
144 * \brief Read from a directory
146 int VFS_ReadDir(int FD, char *Dest)
148 tVFS_Handle *h = VFS_GetHandle(FD);
151 //ENTER("ph pDest", h, Dest);
153 if(!h || h->Node->ReadDir == NULL) {
158 if(h->Node->Size != -1 && h->Position >= h->Node->Size) {
164 tmp = h->Node->ReadDir(h->Node, h->Position);
165 if((Uint)tmp < (Uint)VFS_MAXSKIP)
166 h->Position += (Uint)tmp;
169 } while(tmp != NULL && (Uint)tmp < (Uint)VFS_MAXSKIP);
171 //LOG("tmp = '%s'", tmp);