1536d1a0f2c21a6c5a02c3db7e1387c8a7b2222f
[tpg/acess2.git] / Kernel / vfs / open.c
1 /*
2  * Acess2 VFS
3  * - Open, Close and ChDir
4  */
5 #define DEBUG   0
6 #include <acess.h>
7 #include "vfs.h"
8 #include "vfs_int.h"
9 #include "vfs_ext.h"
10 #include <threads.h>
11
12 // === CONSTANTS ===
13 #define OPEN_MOUNT_ROOT 1
14 #define MAX_PATH_SLASHES        256
15 #define MAX_NESTED_LINKS        4
16 #define MAX_PATH_LEN    255
17
18 // === IMPORTS ===
19 extern tVFS_Mount       *gVFS_RootMount;
20 extern int      VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode);
21 extern tVFS_Node        *VFS_MemFile_Create(const char *Path);
22
23 // === PROTOTYPES ===
24  int    VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode );
25
26 // === CODE ===
27 /**
28  * \fn char *VFS_GetAbsPath(const char *Path)
29  * \brief Create an absolute path from a relative one
30  */
31 char *VFS_GetAbsPath(const char *Path)
32 {
33         char    *ret;
34          int    pathLen = strlen(Path);
35         char    *pathComps[MAX_PATH_SLASHES];
36         char    *tmpStr;
37         int             iPos = 0;
38         int             iPos2 = 0;
39         const char      *chroot = *Threads_GetChroot();
40          int    chrootLen;
41         const char      *cwd = *Threads_GetCWD();
42          int    cwdLen;
43         
44         ENTER("sPath", Path);
45         
46         // Memory File
47         if(Path[0] == '$') {
48                 ret = malloc(strlen(Path)+1);
49                 if(!ret) {
50                         Log_Warning("VFS", "VFS_GetAbsPath: malloc() returned NULL");
51                         return NULL;
52                 }
53                 strcpy(ret, Path);
54                 LEAVE('p', ret);
55                 return ret;
56         }
57         
58         // - Fetch ChRoot
59         if( chroot == NULL )
60                 chroot = "";
61         chrootLen = strlen(chroot);
62         
63         // Check if the path is already absolute
64         if(Path[0] == '/') {
65                 ret = malloc(chrootLen + pathLen + 1);
66                 if(!ret) {
67                         Log_Warning("VFS", "VFS_GetAbsPath: malloc() returned NULL");
68                         return NULL;
69                 }
70                 strcpy(ret + chrootLen, Path);
71         }
72         else {
73                 if(cwd == NULL) {
74                         cwd = "/";
75                         cwdLen = 1;
76                 }
77                 else {
78                         cwdLen = strlen(cwd);
79                 }
80                 // Prepend the current directory
81                 ret = malloc(chrootLen + cwdLen + 1 + pathLen + 1 );
82                 strcpy(ret+chrootLen, cwd);
83                 ret[cwdLen] = '/';
84                 strcpy(ret+chrootLen+cwdLen+1, Path);
85                 //Log("ret = '%s'", ret);
86         }
87         
88         // Parse Path
89         pathComps[iPos++] = tmpStr = ret+chrootLen+1;
90         while(*tmpStr)
91         {
92                 if(*tmpStr++ == '/')
93                 {
94                         pathComps[iPos++] = tmpStr;
95                         if(iPos == MAX_PATH_SLASHES) {
96                                 LOG("Path '%s' has too many elements", Path);
97                                 free(ret);
98                                 LEAVE('n');
99                                 return NULL;
100                         }
101                 }
102         }
103         pathComps[iPos] = NULL;
104         
105         // Cleanup
106         iPos2 = iPos = 0;
107         while(pathComps[iPos])
108         {
109                 tmpStr = pathComps[iPos];
110                 // Always Increment iPos
111                 iPos++;
112                 // ..
113                 if(tmpStr[0] == '.' && tmpStr[1] == '.' && (tmpStr[2] == '/' || tmpStr[2] == '\0') )
114                 {
115                         if(iPos2 != 0)
116                                 iPos2 --;
117                         continue;
118                 }
119                 // .
120                 if(tmpStr[0] == '.' && (tmpStr[1] == '/' || tmpStr[1] == '\0') )
121                 {
122                         continue;
123                 }
124                 // Empty
125                 if(tmpStr[0] == '/' || tmpStr[0] == '\0')
126                 {
127                         continue;
128                 }
129                 
130                 // Set New Position
131                 pathComps[iPos2] = tmpStr;
132                 iPos2++;
133         }
134         pathComps[iPos2] = NULL;
135         
136         // Build New Path
137         iPos2 = chrootLen + 1;  iPos = 0;
138         ret[0] = '/';
139         while(pathComps[iPos])
140         {
141                 tmpStr = pathComps[iPos];
142                 while(*tmpStr && *tmpStr != '/')
143                 {
144                         ret[iPos2++] = *tmpStr;
145                         tmpStr++;
146                 }
147                 ret[iPos2++] = '/';
148                 iPos++;
149         }
150         if(iPos2 > 1)
151                 ret[iPos2-1] = 0;
152         else
153                 ret[iPos2] = 0;
154
155         // Prepend the chroot
156         if(chrootLen)
157                 memcpy( ret, chroot, chrootLen );
158         
159         LEAVE('s', ret);
160 //      Log_Debug("VFS", "VFS_GetAbsPath: RETURN '%s'", ret);
161         return ret;
162 }
163
164 /**
165  * \fn char *VFS_ParsePath(const char *Path, char **TruePath)
166  * \brief Parses a path, resolving sysmlinks and applying permissions
167  */
168 tVFS_Node *VFS_ParsePath(const char *Path, char **TruePath, tVFS_Mount **MountPoint)
169 {
170         tVFS_Mount      *mnt, *longestMount;
171          int    cmp, retLength = 0;
172          int    ofs, nextSlash;
173          int    iNestedLinks = 0;
174         tVFS_Node       *curNode, *tmpNode;
175         char    *tmp;
176         char    path_buffer[MAX_PATH_LEN+1];
177         
178         ENTER("sPath pTruePath", Path, TruePath);
179         
180         // HACK: Memory File
181         if(Threads_GetUID() == 0 && Path[0] == '$') {
182                 if(TruePath) {
183                         *TruePath = malloc(strlen(Path)+1);
184                         strcpy(*TruePath, Path);
185                 }
186                 curNode = VFS_MemFile_Create(Path);
187                 if(MountPoint) {
188                         *MountPoint = NULL;
189                 }
190                 LEAVE('p', curNode);
191                 return curNode;
192         }
193
194 restart_parse:  
195         // For root we always fast return
196         if(Path[0] == '/' && Path[1] == '\0') {
197                 if(TruePath) {
198                         *TruePath = malloc( gVFS_RootMount->MountPointLen+1 );
199                         strcpy(*TruePath, gVFS_RootMount->MountPoint);
200                 }
201                 if(MountPoint)  *MountPoint = gVFS_RootMount;
202                 LEAVE('p', gVFS_RootMount->RootNode);
203                 return gVFS_RootMount->RootNode;
204         }
205         
206         // Check if there is anything mounted
207         if(!gVFS_Mounts) {
208                 Log_Error("VFS", "VFS_ParsePath - No filesystems mounted");
209                 return NULL;
210         }
211         
212         // Find Mountpoint
213         longestMount = gVFS_RootMount;
214         for(mnt = gVFS_Mounts; mnt; mnt = mnt->Next)
215         {
216                 // Quick Check
217                 if( Path[mnt->MountPointLen] != '/' && Path[mnt->MountPointLen] != '\0')
218                         continue;
219                 // Length Check - If the length is smaller than the longest match sofar
220                 if(mnt->MountPointLen < longestMount->MountPointLen)    continue;
221                 // String Compare
222                 cmp = strcmp(Path, mnt->MountPoint);
223                 
224                 #if OPEN_MOUNT_ROOT
225                 // Fast Break - Request Mount Root
226                 if(cmp == 0) {
227                         if(TruePath) {
228                                 *TruePath = malloc( mnt->MountPointLen+1 );
229                                 strcpy(*TruePath, mnt->MountPoint);
230                         }
231                         if(MountPoint)
232                                 *MountPoint = mnt;
233                         LEAVE('p', mnt->RootNode);
234                         return mnt->RootNode;
235                 }
236                 #endif
237                 // Not a match, continue
238                 if(cmp != '/')  continue;
239                 longestMount = mnt;
240         }
241         
242         // Save to shorter variable
243         mnt = longestMount;
244         
245         LOG("mnt = {MountPoint:\"%s\"}", mnt->MountPoint);
246         
247         // Initialise String
248         if(TruePath)
249         {
250                 // Assumes that the resultant path (here) will not be > strlen(Path) + 1
251                 *TruePath = malloc( strlen(Path) + 1 );
252                 strcpy(*TruePath, mnt->MountPoint);
253                 retLength = mnt->MountPointLen;
254         }
255         
256         curNode = mnt->RootNode;
257         curNode->ReferenceCount ++;     
258         // Parse Path
259         ofs = mnt->MountPointLen+1;
260         for(; (nextSlash = strpos(&Path[ofs], '/')) != -1; ofs += nextSlash + 1)
261         {
262                 char    pathEle[nextSlash+1];
263                 
264                 // Empty String
265                 if(nextSlash == 0)      continue;
266                 
267                 memcpy(pathEle, &Path[ofs], nextSlash);
268                 pathEle[nextSlash] = 0;
269         
270                 // Check permissions on root of filesystem
271                 if( !VFS_CheckACL(curNode, VFS_PERM_EXECUTE) ) {
272                         //Log("Permissions fail on '%s'", Path);
273                         goto _error;
274                 }
275                 
276                 // Check if the node has a FindDir method
277                 if( !curNode->Type->FindDir )
278                 {
279                         //Log("FindDir fail on '%s'", Path);
280                         goto _error;
281                 }
282                 LOG("FindDir{=%p}(%p, '%s')", curNode->Type->FindDir, curNode, pathEle);
283                 // Get Child Node
284                 tmpNode = curNode->Type->FindDir(curNode, pathEle);
285                 LOG("tmpNode = %p", tmpNode);
286                 _CloseNode( curNode );
287                 curNode = tmpNode;
288                 
289                 // Error Check
290                 if(!curNode) {
291                         LOG("Node '%s' not found in dir '%s'", pathEle, Path);
292                         goto _error;
293                 }
294                 
295                 // Handle Symbolic Links
296                 if(curNode->Flags & VFS_FFLAG_SYMLINK) {
297                         if(TruePath) {
298                                 free(*TruePath);
299                                 *TruePath = NULL;
300                         }
301                         if(!curNode->Type || !curNode->Type->Read) {
302                                 Log_Warning("VFS", "VFS_ParsePath - Read of symlink node %p'%s' is NULL",
303                                         curNode, Path);
304                                 goto _error;
305                         }
306                         
307                         if(iNestedLinks > MAX_NESTED_LINKS) {
308                                 Log_Notice("VFS", "VFS_ParsePath - Nested link limit exceeded");
309                                 goto _error;
310                         }
311                         
312                         // Parse Symlink Path
313                         // - Just update the path variable and restart the function
314                         // > Count nested symlinks and limit to some value (counteracts loops)
315                         {
316                                  int    remlen = strlen(Path) - (ofs + nextSlash);
317                                 if( curNode->Size + remlen > MAX_PATH_LEN ) {
318                                         Log_Warning("VFS", "VFS_ParsePath - Symlinked path too long");
319                                         goto _error;
320                                 }
321                                 curNode->Type->Read( curNode, 0, curNode->Size, path_buffer );
322                                 path_buffer[ curNode->Size ] = '\0';
323                                 LOG("path_buffer = '%s'", path_buffer);
324                                 strcat(path_buffer, Path + ofs+nextSlash);
325                                 
326                                 Path = path_buffer;
327 //                              Log_Debug("VFS", "VFS_ParsePath: Symlink translated to '%s'", Path);
328                                 iNestedLinks ++;
329                         }
330
331                         // EVIL: Goto :)
332                         LOG("Symlink -> '%s', restart", Path);
333                         goto restart_parse;
334                 }
335                 
336                 // Handle Non-Directories
337                 if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) )
338                 {
339                         Log_Warning("VFS", "VFS_ParsePath - Path segment is not a directory");
340                         goto _error;
341                 }
342                 
343                 // Check if path needs extending
344                 if(!TruePath)   continue;
345                 
346                 // Increase buffer space
347                 tmp = realloc( *TruePath, retLength + strlen(pathEle) + 1 + 1 );
348                 // Check if allocation succeeded
349                 if(!tmp) {
350                         Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
351                         goto _error;
352                 }
353                 *TruePath = tmp;
354                 // Append to path
355                 (*TruePath)[retLength] = '/';
356                 strcpy(*TruePath+retLength+1, pathEle);
357                 
358                 LOG("*TruePath = '%s'", *TruePath);
359                 
360                 // - Extend Path
361                 retLength += nextSlash + 1;
362         }
363
364         // Check final finddir call     
365         if( !curNode->Type || !curNode->Type->FindDir ) {
366                 Log_Warning("VFS", "VFS_ParsePath - FindDir doesn't exist for element of '%s'", Path);
367                 goto _error;
368         }
369         
370         // Get last node
371         LOG("FindDir(%p, '%s')", curNode, &Path[ofs]);
372         tmpNode = curNode->Type->FindDir(curNode, &Path[ofs]);
373         LOG("tmpNode = %p", tmpNode);
374         // Check if file was found
375         if(!tmpNode) {
376                 LOG("Node '%s' not found in dir '%s'", &Path[ofs], Path);
377                 goto _error;
378         }
379         _CloseNode( curNode );
380         
381         if(TruePath)
382         {
383                 // Increase buffer space
384                 tmp = realloc(*TruePath, retLength + strlen(&Path[ofs]) + 1 + 1);
385                 // Check if allocation succeeded
386                 if(!tmp) {
387                         Log_Warning("VFS", "VFS_ParsePath -  Unable to reallocate true path buffer");
388                         goto _error;
389                 }
390                 *TruePath = tmp;
391                 // Append to path
392                 (*TruePath)[retLength] = '/';
393                 strcpy(*TruePath + retLength + 1, &Path[ofs]);
394                 // - Extend Path
395                 //retLength += strlen(tmpNode->Name) + 1;
396         }
397
398         if( MountPoint ) {
399                 *MountPoint = mnt;
400         }
401         
402         LEAVE('p', tmpNode);
403         return tmpNode;
404
405 _error:
406         _CloseNode( curNode );
407         
408         if(TruePath && *TruePath) {
409                 free(*TruePath);
410                 *TruePath = NULL;
411         }
412         LEAVE('n');
413         return NULL;
414 }
415
416 /**
417  * \brief Create and return a handle number for the given node and mode
418  */
419 int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode )
420 {
421          int    i;
422         
423         ENTER("pNode pMount xMode", Node, Mount, Mode);
424
425         i = 0;
426         i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;
427         i |= (Mode & VFS_OPENFLAG_READ) ? VFS_PERM_READ : 0;
428         i |= (Mode & VFS_OPENFLAG_WRITE) ? VFS_PERM_WRITE : 0;
429         
430         LOG("i = 0b%b", i);
431         
432         // Permissions Check
433         if( !VFS_CheckACL(Node, i) ) {
434                 _CloseNode( Node );
435                 Log_Log("VFS", "VFS_int_CreateHandle: Permissions Failed");
436                 errno = EACCES;
437                 LEAVE_RET('i', -1);
438         }
439         
440         i = VFS_AllocHandle( !!(Mode & VFS_OPENFLAG_USER), Node, Mode );
441         if( i < 0 ) {
442                 Log_Notice("VFS", "VFS_int_CreateHandle: Out of handles");
443                 errno = ENFILE;
444                 LEAVE_RET('i', -1);
445         }
446
447         VFS_GetHandle(i)->Mount = Mount;
448
449         LEAVE_RET('x', i);
450 }
451
452 /**
453  * \fn int VFS_Open(const char *Path, Uint Mode)
454  * \brief Open a file
455  */
456 int VFS_Open(const char *Path, Uint Flags)
457 {
458         return VFS_OpenEx(Path, Flags, 0);
459 }
460
461 int VFS_OpenEx(const char *Path, Uint Flags, Uint Mode)
462 {
463         tVFS_Node       *node;
464         tVFS_Mount      *mnt;
465         char    *absPath;
466         
467         ENTER("sPath xFlags oMode", Path, Flags);
468         
469         // Get absolute path
470         absPath = VFS_GetAbsPath(Path);
471         if(absPath == NULL) {
472                 Log_Warning("VFS", "VFS_Open: Path expansion failed '%s'", Path);
473                 LEAVE_RET('i', -1);
474         }
475         LOG("absPath = \"%s\"", absPath);
476         
477         // Parse path and get mount point
478         node = VFS_ParsePath(absPath, NULL, &mnt);
479         
480         // Create file if requested and it doesn't exist
481         if( !node && (Flags & VFS_OPENFLAG_CREATE) )
482         {
483                 // TODO: Translate `Mode` into ACL and node flags
484                 // Get parent, create node
485                 VFS_MkNod(absPath, 0);
486                 node = VFS_ParsePath(absPath, NULL, &mnt);
487         }
488         
489         // Free generated path
490         free(absPath);
491         
492         // Check for error
493         if(!node)
494         {
495                 LOG("Cannot find node");
496                 errno = ENOENT;
497                 LEAVE_RET('i', -1);
498         }
499         
500         // Check for symlinks
501         if( !(Flags & VFS_OPENFLAG_NOLINK) && (node->Flags & VFS_FFLAG_SYMLINK) )
502         {
503                 char    tmppath[node->Size+1];
504                 if( node->Size > MAX_PATH_LEN ) {
505                         Log_Warning("VFS", "VFS_Open - Symlink is too long (%i)", node->Size);
506                         LEAVE_RET('i', -1);
507                 }
508                 if( !node->Type || !node->Type->Read ) {
509                         Log_Warning("VFS", "VFS_Open - No read method on symlink");
510                         LEAVE_RET('i', -1);
511                 }
512                 // Read symlink's path
513                 node->Type->Read( node, 0, node->Size, tmppath );
514                 tmppath[ node->Size ] = '\0';
515                 _CloseNode( node );
516                 // Open the target
517                 node = VFS_ParsePath(tmppath, NULL, &mnt);
518                 if(!node) {
519                         LOG("Cannot find symlink target node (%s)", tmppath);
520                         errno = ENOENT;
521                         LEAVE_RET('i', -1);
522                 }
523         }
524
525         LEAVE_RET('x', VFS_int_CreateHandle(node, mnt, Flags));
526 }
527
528
529 /**
530  * \brief Open a file from an open directory
531  */
532 int VFS_OpenChild(int FD, const char *Name, Uint Mode)
533 {
534         tVFS_Handle     *h;
535         tVFS_Node       *node;
536         
537         ENTER("xFD sName xMode", FD, Name, Mode);
538
539         // Get handle
540         h = VFS_GetHandle(FD);
541         if(h == NULL) {
542                 Log_Warning("VFS", "VFS_OpenChild - Invalid file handle 0x%x", FD);
543                 errno = EINVAL;
544                 LEAVE_RET('i', -1);
545         }
546         
547         // Check for directory
548         if( !(h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
549                 Log_Warning("VFS", "VFS_OpenChild - Passed handle is not a directory");
550                 errno = ENOTDIR;
551                 LEAVE_RET('i', -1);
552         }
553
554         // Sanity check
555         if( !h->Node->Type || !h->Node->Type->FindDir ) {
556                 Log_Error("VFS", "VFS_OpenChild - Node does not have a type/is missing FindDir");
557                 errno = ENOTDIR;
558                 LEAVE_RET('i', -1);
559         }
560         
561         // Find Child
562         node = h->Node->Type->FindDir(h->Node, Name);
563         if(!node) {
564                 errno = ENOENT;
565                 LEAVE_RET('i', -1);
566         }
567
568         LEAVE_RET('x', VFS_int_CreateHandle(node, h->Mount, Mode));
569 }
570
571 int VFS_OpenInode(Uint32 Mount, Uint64 Inode, int Mode)
572 {
573         tVFS_Mount      *mnt;
574         tVFS_Node       *node;
575
576         ENTER("iMount XInode xMode", Mount, Inode, Mode);
577         
578         // Get mount point
579         mnt = VFS_GetMountByIdent(Mount);
580         if( !mnt ) {
581                 LOG("Mount point ident invalid");
582                 errno = ENOENT;
583                 LEAVE_RET('i', -1);
584         }
585         
586         // Does the filesystem support this?
587         if( !mnt->Filesystem->GetNodeFromINode ) {
588                 LOG("Filesystem does not support inode accesses");
589                 errno = ENOENT;
590                 LEAVE_RET('i', -1);
591         }
592
593         // Get node
594         node = mnt->Filesystem->GetNodeFromINode(mnt->RootNode, Inode);
595         if( !node ) {
596                 LOG("Unable to find inode");
597                 errno = ENOENT;
598                 LEAVE_RET('i', -1);
599         }
600         
601         LEAVE_RET('x', VFS_int_CreateHandle(node, mnt, Mode));
602 }
603
604 /**
605  * \fn void VFS_Close(int FD)
606  * \brief Closes an open file handle
607  */
608 void VFS_Close(int FD)
609 {
610         tVFS_Handle     *h;
611         
612         // Get handle
613         h = VFS_GetHandle(FD);
614         if(h == NULL) {
615                 Log_Warning("VFS", "Invalid file handle passed to VFS_Close, 0x%x", FD);
616                 return;
617         }
618         
619         #if VALIDATE_VFS_FUNCTIPONS
620         if(h->Node->Close && !MM_GetPhysAddr(h->Node->Close)) {
621                 Log_Warning("VFS", "Node %p's ->Close method is invalid (%p)",
622                         h->Node, h->Node->Close);
623                 return ;
624         }
625         #endif
626         
627         _CloseNode(h->Node);
628         
629         h->Node = NULL;
630 }
631
632 /**
633  * \brief Change current working directory
634  */
635 int VFS_ChDir(const char *Dest)
636 {
637         char    *buf;
638          int    fd;
639         tVFS_Handle     *h;
640         
641         // Create Absolute
642         buf = VFS_GetAbsPath(Dest);
643         if(buf == NULL) {
644                 Log_Notice("VFS", "VFS_ChDir: Path expansion failed");
645                 return -1;
646         }
647         
648         // Check if path exists
649         fd = VFS_Open(buf, VFS_OPENFLAG_EXEC);
650         if(fd == -1) {
651                 Log_Notice("VFS", "VFS_ChDir: Path is invalid");
652                 return -1;
653         }
654         
655         // Get node so we can check for directory
656         h = VFS_GetHandle(fd);
657         if( !(h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
658                 Log("VFS_ChDir: Path is not a directory");
659                 VFS_Close(fd);
660                 return -1;
661         }
662         
663         // Close file
664         VFS_Close(fd);
665         
666         {
667                 char    **cwdptr = Threads_GetCWD();
668                 // Free old working directory
669                 if( *cwdptr )   free( *cwdptr );
670                 // Set new
671                 *cwdptr = buf;
672         }
673         
674         Log("Updated CWD to '%s'", buf);
675         
676         return 1;
677 }
678
679 /**
680  * \fn int VFS_ChRoot(char *New)
681  * \brief Change current root directory
682  */
683 int VFS_ChRoot(const char *New)
684 {
685         char    *buf;
686          int    fd;
687         tVFS_Handle     *h;
688         
689         if(New[0] == '/' && New[1] == '\0')
690                 return 1;       // What a useless thing to ask!
691         
692         // Create Absolute
693         buf = VFS_GetAbsPath(New);
694         if(buf == NULL) {
695                 LOG("Path expansion failed");
696                 return -1;
697         }
698         
699         // Check if path exists
700         fd = VFS_Open(buf, VFS_OPENFLAG_EXEC);
701         if(fd == -1) {
702                 LOG("Path is invalid");
703                 return -1;
704         }
705         
706         // Get node so we can check for directory
707         h = VFS_GetHandle(fd);
708         if( !(h->Node->Flags & VFS_FFLAG_DIRECTORY) ) {
709                 LOG("Path is not a directory");
710                 VFS_Close(fd);
711                 return -1;
712         }
713         
714         // Close file
715         VFS_Close(fd);
716
717         // Update       
718         {
719                 char    **chroot_ptr = Threads_GetChroot();
720                 if( *chroot_ptr )       free( *chroot_ptr );
721                 *chroot_ptr = buf;
722         }
723         
724         LOG("Updated Root to '%s'", buf);
725         
726         return 1;
727 }
728
729 // === EXPORTS ===
730 EXPORT(VFS_Open);
731 EXPORT(VFS_Close);

UCC git Repository :: git.ucc.asn.au