| | 8 | |
| | 9 | DWORD ConfigGetRootId(); |
| | 10 | int IcFsRead(struct File* file, BYTE* data, DWORD size); |
| | 11 | int IcFsReadDir(struct File* file, void* dirEntries); |
| | 12 | int IcFsFollowLink(struct VNode** ret, struct VNode* vNode); |
| | 13 | |
| | 14 | int ConfigLookup(struct VNode** retVal,struct VNode* dir,char* name,int nameLength) |
| | 15 | { |
| | 16 | struct KeFsEntry* entry; |
| | 17 | |
| | 18 | entry=KeFsLookup(dir, name, nameLength); |
| | 19 | |
| | 20 | if (!entry) |
| | 21 | return -ENOENT; |
| | 22 | |
| | 23 | *retVal=VNodeGet(dir->superBlock, (DWORD)entry); |
| | 24 | |
| | 25 | return 0; |
| | 26 | } |
| | 27 | |
| | 28 | int ConfigWriteInt(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(iEnt->iVal+file->position, data, copied); |
| | 35 | |
| | 36 | file->position+=copied; |
| | 37 | |
| | 38 | return copied; |
| | 39 | } |
| | 40 | |
| | 41 | int ConfigWrite(struct File* file, BYTE* data, DWORD size) |
| | 42 | { |
| | 43 | struct KeFsEntry* entry=(struct KeFsEntry*)(file->vNode->id); |
| | 44 | struct IcFsEntry* iEnt=(struct IcFsEntry*)(entry->file); |
| | 45 | |
| | 46 | switch (iEnt->type) |
| | 47 | { |
| | 48 | case ICFS_TYPE_INT: |
| | 49 | return ConfigWriteInt(file, iEnt, data, size); |
| | 50 | |
| | 51 | // case ICFS_TYPE_STR: |
| | 52 | // return InfoReadStr(file, iEnt, data, size); |
| | 53 | |
| | 54 | default: |
| | 55 | KePrint("TODO: %d\n", iEnt->type); |
| | 56 | } |
| | 57 | |
| | 58 | return 0; |
| | 59 | } |
| | 60 | |
| | 61 | struct VNodeOps configFsVOps= |
| | 62 | { |
| | 63 | .lookup=ConfigLookup, |
| | 64 | .followLink=IcFsFollowLink, |
| | 65 | }; |
| | 66 | |
| | 67 | struct FileOps configFsFileOps= |
| | 68 | { |
| | 69 | .read = IcFsRead, |
| | 70 | .readDir=IcFsReadDir, |
| | 71 | .write = ConfigWrite |
| | 72 | }; |
| | 73 | |
| | 74 | int ConfigReadVNode(struct VNode* vNode) |
| | 75 | { |
| | 76 | struct KeFsEntry* entry=(struct KeFsEntry*)(vNode->id); |
| | 77 | |
| | 78 | IcFsReadVNode(vNode); |
| | 79 | |
| | 80 | vNode->vNodeOps=&configFsVOps; |
| | 81 | vNode->fileOps=&configFsFileOps; |
| | 82 | |
| | 83 | return 0; |
| | 84 | } |
| | 85 | |
| | 86 | struct SuperBlockOps configFsSbOps= |
| | 87 | { |
| | 88 | .readVNode = ConfigReadVNode, |
| | 89 | }; |