Changeset 866
- Timestamp:
- 09/01/08 18:29:41 (3 years ago)
- Files:
-
- 1 modified
-
Whitix/trunk/fs/infofs/infofs.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/fs/infofs/infofs.c
r851 r866 21 21 } 22 22 23 int 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 23 38 struct VNodeOps infoFsVOps= 24 39 { 25 40 .lookup=InfoLookup, 41 .followLink = IcFsFollowLink, 26 42 }; 27 43 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) 44 int IcFsRead(struct File* file, char* data, DWORD size) 55 45 { 56 46 struct KeFsEntry* entry=(struct KeFsEntry*)(file->vNode->id); 57 47 struct IcFsEntry* iEnt=(struct IcFsEntry*)(entry->file); 58 48 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); 72 50 } 73 51 74 int I nfoReadDir(struct File* file, void* dirEntries)52 int IcFsReadDir(struct File* file, void* dirEntries) 75 53 { 76 54 return KeFsReadDir(file, FillDir, dirEntries); … … 79 57 struct FileOps infoFsFileOps= 80 58 { 81 .read = I nfoRead,82 .readDir=I nfoReadDir,59 .read = IcFsRead, 60 .readDir=IcFsReadDir, 83 61 }; 84 62 85 int InfoReadVNode(struct VNode* vNode)63 void IcFsReadVNode(struct VNode* vNode) 86 64 { 87 65 struct KeFsEntry* entry=(struct KeFsEntry*)(vNode->id); … … 89 67 90 68 vNode->mode=entry->type; 91 vNode->vNodeOps=&infoFsVOps;92 vNode->fileOps=&infoFsFileOps;93 69 94 70 if (vNode->mode & VFS_ATTR_DIR) 95 71 vNode->size=KeFsDirSize(&entry->dir); 96 else{ 72 else if (vNode->mode & VFS_ATTR_FILE) 73 { 97 74 /* Fill in size. */ 98 75 iEnt=entry->file; … … 108 85 break; 109 86 87 case ICFS_TYPE_BYTE: 88 vNode->size=iEnt->size; 89 break; 90 110 91 default: 111 92 KePrint("TODO: %d\n", iEnt->type); 112 93 } 113 94 } 95 } 96 97 int 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. */ 114 105 115 106 return 0;
