2 Commits
Author SHA1 Message Date
ChaosMaker 031f8f7726 Merge branch 'master' of ssh://git.gornodox.dev:2222/ChaosMaker/termos
Merge new filesystem to master
2026-11-17 20:49:09 +01:00
ChaosMaker d642ee6258 Update README.md 2026-09-12 02:02:30 +02:00
5 changed files with 28 additions and 36 deletions
+1 -2
View File
@@ -25,8 +25,7 @@ It doesnt implement a website friendly interface on its own. Thats one of the de
[ref2]: https://pnpm.io/installation
```bash
wget https://git.gornodox.dev/ChaosMaker/termos/archive/unstable-async.zip
unzip -d termos unstable-async.zip
git clone https://git.gornodox.dev/ChaosMaker/termos.git
cd termos
npm install
```
-2
View File
@@ -6,14 +6,12 @@ import { descriptor as echo } from "./commands/echo";
import { descriptor as ls } from "./commands/ls";
import { descriptor as pwd } from "./commands/pwd";
import { descriptor as testasync } from "./commands/testasync";
import { descriptor as touch } from "./commands/touch";
const reg = new Map<string, CommandDescriptor>();
//reg.set(descriptor.name, descriptor <- imported const from command implementation file);
reg.set(echo.name, echo);
reg.set(cd.name, cd);
reg.set(testasync.name, testasync);
reg.set(touch.name, touch);
reg.set(ls.name, ls);
reg.set(cat.name, cat);
reg.set(pwd.name, pwd);
+2 -4
View File
@@ -219,10 +219,8 @@ async function main(io: CommandIO, state: ShellState, args: string[]): Promise<C
entries.push({ ptr: session.cwd, path: "." });
} else {
for (const path of paths) {
let ptr;
try {
ptr = resolvePath(state, path);
} catch {
const ptr = resolvePath(state, path);
if (!state.filesystem.exists(ptr)) {
return {
state,
result: createErrorResult(
+24 -24
View File
@@ -1,44 +1,44 @@
import type { CommandDescriptor, CommandOutput } from "@core/command";
import type { CommandIO } from "@core/command_io";
import { NodeType } from "@core/filesystem/node";
import { createErrorResult, createSuccessResult, type ResultSuccess } from "@core/result";
import { createSuccessResult, type ResultSuccess } from "@core/result";
import { getCurrentSession } from "@core/session_manager";
import type { ShellState } from "@core/shell_state";
import type { ShellError } from "@core/util/errors";
import { resolvePath } from "@core/util/path_resolver";
import { Blob } from "node:buffer";
export const COMMAND_NAME = "touch";
//Need to implement escape sequences
async function main(io: CommandIO, state: ShellState, args: string[]): Promise<CommandOutput<ShellError>> {
const session = getCurrentSession(state);
for (const arg of args) {
try {
resolvePath(state, arg);
} catch {
const inode = resolvePath(state, arg);
const session = getCurrentSession(state);
let newState;
if (inode === -1) {
const index = arg.lastIndexOf("/");
let parentPath;
if (index === -1) {
parentPath = "./";
} else {
parentPath = arg.slice(0, index);
}
const fileName = arg.slice(index + 1);
const parentPath = index === -1 ? "./" : arg.slice(0, index + 1);
const pptr = resolvePath(state, parentPath);
const parent = resolvePath(state, parentPath);
state.filesystem.createNode(pptr, fileName, {
type: NodeType.File,
mode: 0o644,
owner: session.user.uid,
group: session.user.gid,
content: new Blob(),
size: 0,
});
continue;
newState = state.filesystem.createNode(
parent,
fileName,
TreeNodeType.File,
0o644,
session.user.uid,
session.user.gid,
);
} else {
}
return {
state,
result: createErrorResult("AlreadyExists", "The file already exists", {}),
} satisfies CommandOutput<ShellError>;
}
const result: ResultSuccess = createSuccessResult(COMMAND_NAME);
return {
+1 -4
View File
@@ -10,7 +10,6 @@ import { NodeType, type DirectoryNode, type FileNode, type Node, type SymlinkNod
export function deserializeFileSystem(json: string): { dstore: IDataStore; mstore: IMetaStore; config: VDiskConfig }[] {
const raw = JSON.parse(json);
let index = 0;
// prettier-ignore
function parseNode(tree: any, parent: number, store: MemDataStore, map: Map<number, Node>): void { // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -32,8 +31,6 @@ export function deserializeFileSystem(json: string): { dstore: IDataStore; mstor
return;
}
if(tree.inode > index) index = tree.inode;
switch(tree.type) {
case "directory": {
const children: Map<string, number> = new Map();
@@ -124,7 +121,7 @@ export function deserializeFileSystem(json: string): { dstore: IDataStore; mstor
const config: VDiskConfig = {
id: dev.id,
label: `disk-${dev.id}`,
index,
index: 0,
readonly: false,
size: 1024 * 1024 * 1024 * 8, //8 GiB
base: map,