diff --git a/src/lib/assets/fs/fs.json b/src/lib/assets/fs/fs.json index ce83f50..b46f04a 100644 --- a/src/lib/assets/fs/fs.json +++ b/src/lib/assets/fs/fs.json @@ -51,7 +51,8 @@ "ATime": "2025-11-28T11:23:51.467+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": null }, "2": { "Inode": 2, @@ -86,7 +87,8 @@ "ATime": "2025-11-28T11:59:00.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "3": { "Inode": 3, @@ -121,7 +123,8 @@ "ATime": "2025-11-28T11:59:02.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "4": { "Inode": 4, @@ -156,7 +159,8 @@ "ATime": "2025-11-28T11:59:04.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "5": { "Inode": 5, @@ -191,7 +195,8 @@ "ATime": "2025-11-28T11:59:05.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "6": { "Inode": 6, @@ -226,7 +231,8 @@ "ATime": "2025-11-28T11:59:06.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "7": { "Inode": 7, @@ -261,7 +267,8 @@ "ATime": "2025-11-28T11:59:07.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "8": { "Inode": 8, @@ -296,7 +303,8 @@ "ATime": "2025-11-28T11:59:08.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "9": { "Inode": 9, @@ -331,7 +339,8 @@ "ATime": "2025-11-28T11:59:08.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "10": { "Inode": 10, @@ -366,7 +375,8 @@ "ATime": "2025-11-28T11:59:10.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "11": { "Inode": 11, @@ -401,7 +411,8 @@ "ATime": "2025-11-28T11:59:11.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "12": { "Inode": 12, @@ -438,7 +449,8 @@ "ATime": "2025-11-28T11:59:11.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "13": { "Inode": 13, @@ -495,7 +507,8 @@ "ATime": "2025-11-28T11:59:12.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 12 }, "14": { "Inode": 14, @@ -503,7 +516,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "fd336aa4-042c-4ccb-92e3-36be47be3cbd", + "Content": "90bd40fe-ff53-41e4-8498-f37902b9a6ca", "Target": null, "Permission": [ { @@ -530,7 +543,8 @@ "ATime": "2025-11-28T11:59:21.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "15": { "Inode": 15, @@ -565,7 +579,8 @@ "ATime": "2025-11-28T11:59:24.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "16": { "Inode": 16, @@ -573,7 +588,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "7fae2a72-899d-4f0a-ac52-017a889a3772", + "Content": "42b7fe6b-3c38-4a45-9fa7-3f0253b93fa8", "Target": null, "Permission": [ { @@ -600,7 +615,8 @@ "ATime": "2025-11-28T11:59:25.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "17": { "Inode": 17, @@ -635,7 +651,8 @@ "ATime": "2025-11-28T11:59:27.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "18": { "Inode": 18, @@ -643,7 +660,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "f5e72260-946c-4526-8278-93fd123e1351", + "Content": "563f011c-1b79-4e19-a23a-ae5d82726b85", "Target": null, "Permission": [ { @@ -670,7 +687,8 @@ "ATime": "2025-11-28T11:59:27.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "19": { "Inode": 19, @@ -705,7 +723,8 @@ "ATime": "2025-11-28T11:59:30.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "20": { "Inode": 20, @@ -740,7 +759,8 @@ "ATime": "2025-11-28T11:59:31.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "21": { "Inode": 21, @@ -775,7 +795,8 @@ "ATime": "2025-11-28T11:59:32.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "22": { "Inode": 22, @@ -810,7 +831,8 @@ "ATime": "2025-11-28T11:59:33.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "23": { "Inode": 23, @@ -818,7 +840,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "28fac328-68ad-4832-b9af-d8e0848fc10c", + "Content": "e5a592ad-7e71-4db2-9e3b-bde19f98e9ff", "Target": null, "Permission": [ { @@ -845,7 +867,8 @@ "ATime": "2025-11-28T11:59:33.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "24": { "Inode": 24, @@ -880,7 +903,8 @@ "ATime": "2025-11-28T11:59:35.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "25": { "Inode": 25, @@ -915,7 +939,8 @@ "ATime": "2025-11-28T11:59:36.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "26": { "Inode": 26, @@ -923,7 +948,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "0151d0eb-7bac-4b21-8d80-be4a59bfcb7a", + "Content": "663086d7-d96b-421c-9fd1-45e09ba892e9", "Target": null, "Permission": [ { @@ -950,7 +975,8 @@ "ATime": "2025-11-28T11:59:37.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "27": { "Inode": 27, @@ -985,7 +1011,8 @@ "ATime": "2025-11-28T11:59:39.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "28": { "Inode": 28, @@ -1020,7 +1047,8 @@ "ATime": "2025-11-28T11:59:40.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "29": { "Inode": 29, @@ -1058,7 +1086,8 @@ "ATime": "2025-11-28T11:59:41.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "30": { "Inode": 30, @@ -1097,7 +1126,8 @@ "ATime": "2025-11-28T11:59:42.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 29 }, "31": { "Inode": 31, @@ -1134,7 +1164,8 @@ "ATime": "2025-11-28T11:59:43.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 30 }, "32": { "Inode": 32, @@ -1142,7 +1173,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "f81ac129-72be-4b84-a359-0b1d87fe8e6e", + "Content": "84c0b742-78e8-4cf4-b269-7632ec9f52cb", "Target": null, "Permission": [ { @@ -1169,7 +1200,8 @@ "ATime": "2025-11-28T11:59:43.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 31 }, "33": { "Inode": 33, @@ -1206,7 +1238,8 @@ "ATime": "2025-11-28T11:59:45.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 30 }, "34": { "Inode": 34, @@ -1214,7 +1247,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "acf81ad0-1a21-48cf-a24e-7e5172e9e41f", + "Content": "d1eb218b-41a5-4c22-851e-21058eaa13f3", "Target": null, "Permission": [ { @@ -1241,7 +1274,8 @@ "ATime": "2025-11-28T11:59:45.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 33 }, "35": { "Inode": 35, @@ -1278,7 +1312,8 @@ "ATime": "2025-11-28T11:59:47.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 30 }, "36": { "Inode": 36, @@ -1286,7 +1321,7 @@ "Type": 32768, "Size": 1, "Children": null, - "Content": "5bb1d2c8-044e-4d45-a60b-61810a62842a", + "Content": "6a2cb265-0b6e-4613-9f43-d379ea6fae6d", "Target": null, "Permission": [ { @@ -1313,7 +1348,8 @@ "ATime": "2025-11-28T11:59:47.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 35 }, "37": { "Inode": 37, @@ -1348,7 +1384,8 @@ "ATime": "2025-11-28T11:59:49.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 29 }, "38": { "Inode": 38, @@ -1383,7 +1420,8 @@ "ATime": "2025-11-28T11:59:50.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "39": { "Inode": 39, @@ -1418,7 +1456,8 @@ "ATime": "2025-11-28T11:59:51.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "40": { "Inode": 40, @@ -1453,7 +1492,8 @@ "ATime": "2025-11-28T11:59:52.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "41": { "Inode": 41, @@ -1490,7 +1530,8 @@ "ATime": "2025-11-28T11:59:53.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "42": { "Inode": 42, @@ -1498,7 +1539,7 @@ "Type": 32768, "Size": 171, "Children": null, - "Content": "7e4699bd-98a2-4a30-87b8-83d3f187a725", + "Content": "d8cf8d18-9575-4c95-9a41-ccd129188603", "Target": null, "Permission": [ { @@ -1525,7 +1566,8 @@ "ATime": "2025-11-28T11:59:53.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 41 }, "43": { "Inode": 43, @@ -1560,7 +1602,8 @@ "ATime": "2025-11-28T11:59:55.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 13 }, "44": { "Inode": 44, @@ -1595,7 +1638,8 @@ "ATime": "2025-11-28T11:43:17.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "45": { "Inode": 45, @@ -1630,7 +1674,8 @@ "ATime": "2025-11-28T11:43:18.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "46": { "Inode": 46, @@ -1665,7 +1710,8 @@ "ATime": "2025-11-28T11:43:19.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "47": { "Inode": 47, @@ -1700,7 +1746,8 @@ "ATime": "2025-11-28T11:43:20.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "48": { "Inode": 48, @@ -1735,7 +1782,8 @@ "ATime": "2025-11-28T11:43:21.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "49": { "Inode": 49, @@ -1770,7 +1818,8 @@ "ATime": "2025-11-28T11:43:22.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 }, "50": { "Inode": 50, @@ -1805,6 +1854,7 @@ "ATime": "2025-11-28T11:43:23.496+01:00" }, "Interactible": false, - "Func": null + "Func": null, + "Parent": 1 } } \ No newline at end of file diff --git a/src/lib/assets/fs/signature b/src/lib/assets/fs/signature index adcd589..11e1443 100644 --- a/src/lib/assets/fs/signature +++ b/src/lib/assets/fs/signature @@ -1 +1 @@ -a76385a5-03d6-409b-b06f-8641a904cf85 \ No newline at end of file +32aac83d-ce2b-4def-977c-dcdcb6f514ee \ No newline at end of file diff --git a/src/lib/stores/bash/bash.ts b/src/lib/stores/bash/bash.ts index 148b434..d0d25ee 100644 --- a/src/lib/stores/bash/bash.ts +++ b/src/lib/stores/bash/bash.ts @@ -129,9 +129,9 @@ export class Bash { } } - private appendNewResult(path: string[], output: any, cmd: string) { + private appendNewResult(workingDir: number, output: any, cmd: string) { const data: PrintData = { - path: this.vfs.formatPath(this.vfs.pathArrayToString(path)), + path: this.vfs.formatPath(this.vfs.getPathByInode(workingDir)), output: output, cmd: cmd }; diff --git a/src/lib/stores/bash/commands/ls.ts b/src/lib/stores/bash/commands/ls.ts index 1ad2197..7c9368c 100644 --- a/src/lib/stores/bash/commands/ls.ts +++ b/src/lib/stores/bash/commands/ls.ts @@ -143,7 +143,7 @@ function result_ls(this: Bash, data: any, args: CommandArgs): HTMLElement { if (nodes.length > 1) { const nodePath: string = - node.name === '/' ? '/:' : `${this.getFs()._getPathToNode(node).join('/').slice(1)}:`; + node.name === '/' ? '/:' : `${this.getFs().getPathByInode(node.inode).slice(1)}:`; rows.unshift(nodePath); rows.push('\n'); } diff --git a/src/lib/stores/bash/fs.ts b/src/lib/stores/bash/fs.ts index 6b96749..e301f72 100644 --- a/src/lib/stores/bash/fs.ts +++ b/src/lib/stores/bash/fs.ts @@ -98,6 +98,7 @@ export class VirtualFS { } private _findChildNodeByName(node: TreeNode, name: string): number { + console.log(name, node); for(const childINode of node.children) { const child = this.FsTable.get(childINode); if(child && child.name === name) { @@ -111,6 +112,10 @@ export class VirtualFS { return typeof path === 'string' && path.startsWith('/'); }; + getPathByInode(inode: number): string { + return this._iNodeToPathString(inode); + } + formatPath(path: string): string { const prefix = this._iNodeToPathString(this.home); if (path.startsWith(prefix)) { @@ -146,7 +151,7 @@ export class VirtualFS { return node; } - private _getPathToNode(node: TreeNode): string[] { + /* private _getPathToNode(node: TreeNode): string[] { const path: string[] = []; let current = node; path.push(node.name); @@ -157,5 +162,5 @@ export class VirtualFS { } return path; - } + } */ } diff --git a/src/lib/stores/terminal/init.svelte.ts b/src/lib/stores/terminal/init.svelte.ts index a81ae9a..74e0cad 100644 --- a/src/lib/stores/terminal/init.svelte.ts +++ b/src/lib/stores/terminal/init.svelte.ts @@ -10,19 +10,19 @@ export function isInitializing(): boolean { function jsonToNodeTable(data: any, parent?: number): Map { const FsTable: Map = new Map; - const keyList = Object.keys(data); + const entryList = Object.entries(data); - for(const key in keyList) { - const object = data[key]; + for(let i = 0; i < entryList.length; i++) { + const object: any = entryList[i][1]; const node: TreeNode = { inode: object.Inode, name: object.Name, type: object.Type, interactible: object.Interactible, func: object.Func, - children: [], + children: object.Children, content: object.Content, - link: object.Link || [], + link: object.Link, permission: { user: { r: object.Permission[0]?.Read, @@ -52,7 +52,6 @@ function jsonToNodeTable(data: any, parent?: number): Map { FsTable.set(object.Inode, node); } - console.log(FsTable); return FsTable; } diff --git a/src/lib/stores/terminal/terminal.ts b/src/lib/stores/terminal/terminal.ts index 2a8bd2a..900c18d 100644 --- a/src/lib/stores/terminal/terminal.ts +++ b/src/lib/stores/terminal/terminal.ts @@ -99,12 +99,13 @@ export class Terminal { getCwd(): string { const fs: VirtualFS = this.bash.getFs(); - return fs.formatPath(fs.pathArrayToString(this.bash.getCwd())); + return fs.formatPath(fs.getPathByInode(this.bash.getCwd())); } - userLogin(username: string, passwd: string): ExitCode { + //TODO: Later reimplement the backend helper methods + /* userLogin(username: string, passwd: string): ExitCode { return this.bash.userLogin(username, passwd); - } + } */ PrintOutput(data: PrintData) { this.callbacks.print?.(data); diff --git a/src/modules/Terminal.svelte b/src/modules/Terminal.svelte index ade926c..426a503 100644 --- a/src/modules/Terminal.svelte +++ b/src/modules/Terminal.svelte @@ -64,7 +64,7 @@ terminal = await initTerminal(testUser, callbackInit); updateTerminal(); } catch (error) { - console.error('onMount trycatch failed'); + console.error('onMount trycatch failed', error); } });