Changeset 866

Show
Ignore:
Timestamp:
09/01/08 18:29:41 (3 years ago)
Author:
mwhitworth
Message:

Move icfs functions to info.c

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/fs/infofs/infofs.c

    r851 r866  
    2121} 
    2222 
     23int IcFsFollowLink(struct VNode** ret, struct VNode* vNode) 
     24{ 
     25        char buf[2048]; 
     26        struct KeFsEntry* entry; 
     27        int err; 
     28         
     29        entry=(struct KeFsEntry*)(vNode->id); 
     30         
     31        entry->followLink(buf, 2048); 
     32         
     33        err=NameToVNode(ret, buf, FILE_FORCE_OPEN); 
     34         
     35        return err; 
     36} 
     37 
    2338struct VNodeOps infoFsVOps= 
    2439{ 
    2540        .lookup=InfoLookup, 
     41        .followLink = IcFsFollowLink, 
    2642}; 
    2743 
    28 int InfoReadInt(struct File* file, struct IcFsEntry* iEnt, char* data, DWORD size) 
    29 { 
    30         int copied; 
    31          
    32         copied=MIN(size-file->position, sizeof(int)-file->position); 
    33          
    34         memcpy(data, iEnt->iVal+file->position, copied); 
    35          
    36         file->position+=copied; 
    37          
    38         return copied; 
    39 } 
    40  
    41 int InfoReadStr(struct File* file, struct IcFsEntry* iEnt, char* data, DWORD size) 
    42 { 
    43         int copied; 
    44          
    45         copied=MIN(size-file->position, strlen(iEnt->sVal)-file->position); 
    46          
    47         memcpy(data, iEnt->sVal+file->position, copied); 
    48          
    49         file->position+=copied; 
    50          
    51         return copied; 
    52 } 
    53  
    54 int InfoRead(struct File* file, char* data, DWORD size) 
     44int IcFsRead(struct File* file, char* data, DWORD size) 
    5545{ 
    5646        struct KeFsEntry* entry=(struct KeFsEntry*)(file->vNode->id); 
    5747        struct IcFsEntry* iEnt=(struct IcFsEntry*)(entry->file); 
    5848         
    59         switch (iEnt->type) 
    60         { 
    61                 case ICFS_TYPE_INT: 
    62                         return InfoReadInt(file, iEnt, data, size); 
    63                          
    64                 case ICFS_TYPE_STR: 
    65                         return InfoReadStr(file, iEnt, data, size); 
    66                          
    67                 default: 
    68                         KePrint("TODO: %d\n", iEnt->type); 
    69         } 
    70          
    71         return 0; 
     49        return IcRead(&file->position, iEnt, data, size); 
    7250} 
    7351 
    74 int InfoReadDir(struct File* file, void* dirEntries) 
     52int IcFsReadDir(struct File* file, void* dirEntries) 
    7553{ 
    7654        return KeFsReadDir(file, FillDir, dirEntries); 
     
    7957struct FileOps infoFsFileOps= 
    8058{ 
    81         .read = InfoRead, 
    82         .readDir=InfoReadDir, 
     59        .read = IcFsRead, 
     60        .readDir=IcFsReadDir, 
    8361}; 
    8462 
    85 int InfoReadVNode(struct VNode* vNode) 
     63void IcFsReadVNode(struct VNode* vNode) 
    8664{ 
    8765        struct KeFsEntry* entry=(struct KeFsEntry*)(vNode->id); 
     
    8967         
    9068        vNode->mode=entry->type; 
    91         vNode->vNodeOps=&infoFsVOps; 
    92         vNode->fileOps=&infoFsFileOps; 
    9369         
    9470        if (vNode->mode & VFS_ATTR_DIR) 
    9571                vNode->size=KeFsDirSize(&entry->dir); 
    96         else{ 
     72        else if (vNode->mode & VFS_ATTR_FILE) 
     73        { 
    9774                /* Fill in size. */ 
    9875                iEnt=entry->file; 
     
    10885                                break; 
    10986                                 
     87                        case ICFS_TYPE_BYTE: 
     88                                vNode->size=iEnt->size; 
     89                                break; 
     90                                 
    11091                        default: 
    11192                                KePrint("TODO: %d\n", iEnt->type); 
    11293                } 
    11394        } 
     95} 
     96 
     97int InfoReadVNode(struct VNode* vNode) 
     98{ 
     99        IcFsReadVNode(vNode); 
     100         
     101        vNode->vNodeOps=&infoFsVOps; 
     102        vNode->fileOps=&infoFsFileOps; 
     103         
     104        vNode->mode &= ~VFS_ATTR_WRITE; /* Info entries are read-only. */ 
    114105         
    115106        return 0;