Show
Ignore:
Timestamp:
05/06/08 22:26:59 (7 months ago)
Author:
mwhitworth
Message:

Add comments.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/hybrid/fs/vfs/dir.c

    r412 r445  
    6060        } 
    6161         
     62        /* Can't create a directory on a read-only filesystem. */ 
    6263        if (dir->superBlock->flags & SB_RDONLY) 
    6364        { 
     
    6667        } 
    6768 
     69        /* Check if the mkDir function actually exists. */ 
    6870        if (!dir->vNodeOps || !dir->vNodeOps->mkDir) 
    6971        { 
     
    230232                return err; 
    231233 
     234        /* New root must be a directory */ 
    232235        if (!(dirNode->mode & VFS_ATTR_DIR)) 
    233236        { 
     
    236239        } 
    237240 
     241        /* Change the current directory (and root) to the new root vNode, 
     242         * because we can't be sure the current directory doesn't point to a 
     243         * location outside that accessible by the root directory. 
     244         */ 
    238245        VNodeRelease(current->cwd); 
    239246        VNodeRelease(current->root); 
     
    244251        return 0; 
    245252} 
     253 
     254/*********************************************************************** 
     255 * 
     256 * FUNCTION:    SysChangeRoot 
     257 * 
     258 * DESCRIPTION: Change the filesystem root for a particular process. 
     259 * 
     260 * PARAMETERS:  dirName - name of the directory that is the new root. 
     261 * 
     262 * RETURNS:             Usual error codes in error.h 
     263 * 
     264 ***********************************************************************/ 
    246265 
    247266int SysChangeRoot(char* dirName) 
     
    288307int FillDir(void* entries,char* name,int nameLen,DWORD vNum) 
    289308{ 
    290         struct FillDirInfo* curr=(struct FillDirInfo*)entries; 
     309        struct FillDirInfo* dirEntries=(struct FillDirInfo*)entries; 
    291310        int recordLen=ROUND_UP(offsetof(struct DirEntry,name)+nameLen+1); 
    292311 
     
    294313                return -EFAULT; 
    295314 
    296         curr->curr->vNodeNum=vNum; 
    297         curr->curr->length=recordLen; 
    298         curr->curr->offset=0; 
     315        /* Fill in the current directory entry. */ 
     316        dirEntries->curr->vNodeNum=vNum; 
     317        dirEntries->curr->length=recordLen; 
     318        dirEntries->curr->offset=0; 
    299319        memcpy(curr->curr->name,name,nameLen); 
    300320        curr->curr->name[nameLen]='\0'; 
     321 
     322        /* And update the GetDirEntries state. */ 
    301323        curr->count-=recordLen; 
    302324        curr->prev=curr->curr; 
     
    324346                return -EBADF; 
    325347 
     348        /* Must be able to write the directory entries to the given area of memory. */ 
    326349        if (VirtCheckArea(entries,count,VER_WRITE)) 
    327350                return -EFAULT; 
     
    346369        } 
    347370 
     371        /* Check if an error occured during ReadDir. If not, return the total byte-count of 
     372         * the ReadDir entries. 
     373         */ 
    348374        if (fDirInfo.error) 
    349375                return fDirInfo.error; 
     
    452478 
    453479        /* Change to current for the duration of the lookup (Exec* needs it). */ 
    454  
    455480        if (process != current) 
    456481        { 
     
    462487        } 
    463488 
     489        /* Look up the directory vNode. */ 
    464490        err=NameToVNode(&dirNode,dirName,FILE_READ | FILE_FORCE_OPEN); 
    465491         
     492        /* And change back. */ 
    466493        if (process != current) 
    467494        { 
     
    479506        } 
    480507 
     508        /* Update the directory path string. Used in SysGetCurrDir. */ 
    481509        AddStringPath(process,dirName); 
    482510 
     511        /* And finally, update the current directory vNode for the process. */ 
    483512        VNodeRelease(process->cwd); 
    484513        process->cwd=dirNode;