From 3f7c0d4ad21c3b0824472789c8809a8c0abf7b89 Mon Sep 17 00:00:00 2001 From: Divyendu Singh Date: Wed, 1 Nov 2023 09:18:45 +0000 Subject: [PATCH] chore: console.log to console.info --- packages/fuse-client/index.ts | 6 +++--- packages/fuse-client/syscalls/access.ts | 2 +- packages/fuse-client/syscalls/chmod.ts | 2 +- packages/fuse-client/syscalls/chown.ts | 2 +- packages/fuse-client/syscalls/create.ts | 2 +- packages/fuse-client/syscalls/destroy.ts | 2 +- packages/fuse-client/syscalls/fgetattr.ts | 2 +- packages/fuse-client/syscalls/flush.ts | 2 +- packages/fuse-client/syscalls/fsync.ts | 2 +- packages/fuse-client/syscalls/fsyncdir.ts | 2 +- packages/fuse-client/syscalls/ftruncate.ts | 2 +- packages/fuse-client/syscalls/getxattr.ts | 2 +- packages/fuse-client/syscalls/listxattr.ts | 2 +- packages/fuse-client/syscalls/mkdir.ts | 2 +- packages/fuse-client/syscalls/mknod.ts | 2 +- packages/fuse-client/syscalls/read.ts | 2 +- packages/fuse-client/syscalls/readdir.ts | 2 +- packages/fuse-client/syscalls/release.ts | 2 +- packages/fuse-client/syscalls/releasedir.ts | 2 +- packages/fuse-client/syscalls/removexattr.ts | 2 +- packages/fuse-client/syscalls/rename.ts | 3 +-- packages/fuse-client/syscalls/rmdir.ts | 2 +- packages/fuse-client/syscalls/setxattr.ts | 2 +- packages/fuse-client/syscalls/statfs.ts | 2 +- packages/fuse-client/syscalls/truncate.ts | 2 +- packages/fuse-client/syscalls/unlink.ts | 2 +- packages/fuse-client/syscalls/utimens.ts | 2 +- packages/fuse-client/syscalls/write.ts | 2 +- packages/sqlite-backend/WriteBuffer.ts | 3 +++ packages/sqlite-backend/{ => prisma}/baseline.sql | 13 ++++++++++++- packages/zoid-fs-client/index.ts | 2 +- 31 files changed, 46 insertions(+), 33 deletions(-) rename packages/sqlite-backend/{ => prisma}/baseline.sql (59%) diff --git a/packages/fuse-client/index.ts b/packages/fuse-client/index.ts index c610a2b..40777d1 100644 --- a/packages/fuse-client/index.ts +++ b/packages/fuse-client/index.ts @@ -97,7 +97,7 @@ export class FuseClient { this.unmountFS(mountPath); throw err; } - console.log("filesystem mounted on " + mountPath); + console.info("filesystem mounted on " + mountPath); } ); } @@ -105,12 +105,12 @@ export class FuseClient { unmountFS(mountPath: string) { fuse.unmount(mountPath, (err) => { if (err) { - console.log( + console.info( "filesystem at " + mountPath + " not unmounted", err.toString() ); } else { - console.log("filesystem at " + mountPath + " unmounted"); + console.info("filesystem at " + mountPath + " unmounted"); } }); } diff --git a/packages/fuse-client/syscalls/access.ts b/packages/fuse-client/syscalls/access.ts index 3ebe634..5664b51 100644 --- a/packages/fuse-client/syscalls/access.ts +++ b/packages/fuse-client/syscalls/access.ts @@ -5,7 +5,7 @@ export const access: (backend: SQLiteBackend) => MountOptions["access"] = ( backend ) => { return async (path, mode, cb) => { - console.log("access(%s, %d)", path, mode); + console.info("access(%s, %d)", path, mode); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/chmod.ts b/packages/fuse-client/syscalls/chmod.ts index d950d26..05817cb 100644 --- a/packages/fuse-client/syscalls/chmod.ts +++ b/packages/fuse-client/syscalls/chmod.ts @@ -7,7 +7,7 @@ export const chmod: (backend: SQLiteBackend) => MountOptions["chmod"] = ( backend ) => { return async (path, mode, cb) => { - console.log("chmod(%s, %d)", path, mode); + console.info("chmod(%s, %d)", path, mode); const r = await backend.updateMode(path, mode); match(r) .with({ status: "ok" }, () => { diff --git a/packages/fuse-client/syscalls/chown.ts b/packages/fuse-client/syscalls/chown.ts index 6498b22..8be1ae3 100644 --- a/packages/fuse-client/syscalls/chown.ts +++ b/packages/fuse-client/syscalls/chown.ts @@ -5,7 +5,7 @@ export const chown: (backend: SQLiteBackend) => MountOptions["chown"] = ( backend ) => { return async (path, uid, gid, cb) => { - console.log("chown(%s, %d, %d)", path, uid, gid); + console.info("chown(%s, %d, %d)", path, uid, gid); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/create.ts b/packages/fuse-client/syscalls/create.ts index eeec4ff..438c6aa 100644 --- a/packages/fuse-client/syscalls/create.ts +++ b/packages/fuse-client/syscalls/create.ts @@ -5,7 +5,7 @@ export const create: (backend: SQLiteBackend) => MountOptions["create"] = ( backend ) => { return async (path, mode, cb) => { - console.log("create(%s, %d)", path, mode); + console.info("create(%s, %d)", path, mode); //@ts-expect-error fix types const context = fuse.context(); diff --git a/packages/fuse-client/syscalls/destroy.ts b/packages/fuse-client/syscalls/destroy.ts index ea4e321..f7ef79c 100644 --- a/packages/fuse-client/syscalls/destroy.ts +++ b/packages/fuse-client/syscalls/destroy.ts @@ -5,7 +5,7 @@ export const destroy: (backend: SQLiteBackend) => MountOptions["destroy"] = ( backend ) => { return async (cb) => { - console.log("destroy"); + console.info("destroy"); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/fgetattr.ts b/packages/fuse-client/syscalls/fgetattr.ts index d6cf732..4fd474b 100644 --- a/packages/fuse-client/syscalls/fgetattr.ts +++ b/packages/fuse-client/syscalls/fgetattr.ts @@ -6,7 +6,7 @@ export const fgetattr: (backend: SQLiteBackend) => MountOptions["fgetattr"] = ( backend ) => { return async (path, fd, cb) => { - console.log("fgetattr(%s, %d)", path, fd); + console.info("fgetattr -> getattr(%s, %d)", path, fd); //@ts-expect-error fix types // TODO: implement fgetattr properly getattr(backend)?.(path, cb); diff --git a/packages/fuse-client/syscalls/flush.ts b/packages/fuse-client/syscalls/flush.ts index a802015..6ac273f 100644 --- a/packages/fuse-client/syscalls/flush.ts +++ b/packages/fuse-client/syscalls/flush.ts @@ -5,7 +5,7 @@ export const flush: (backend: SQLiteBackend) => MountOptions["flush"] = ( backend ) => { return async (path, fd, cb) => { - console.log("flush(%s, %d)", path, fd); + console.info("flush(%s, %d)", path, fd); await backend.flush(path); cb(0); }; diff --git a/packages/fuse-client/syscalls/fsync.ts b/packages/fuse-client/syscalls/fsync.ts index e79d2e0..d6ccbbc 100644 --- a/packages/fuse-client/syscalls/fsync.ts +++ b/packages/fuse-client/syscalls/fsync.ts @@ -6,7 +6,7 @@ export const fsync: (backend: SQLiteBackend) => MountOptions["fsync"] = ( backend ) => { return async (path, fd, datasync, cb) => { - console.log("fsync(%s, %d, %d)", path, fd, datasync); + console.info("fsync -> flush(%s, %d, %d)", path, fd, datasync); // @ts-expect-error TODO: implement fsync properly // We do buffered writes and flush flushes the buffer! // A program may not call flush but fsync without relenquishing fd (like SQLite) diff --git a/packages/fuse-client/syscalls/fsyncdir.ts b/packages/fuse-client/syscalls/fsyncdir.ts index a5c7810..0fa442e 100644 --- a/packages/fuse-client/syscalls/fsyncdir.ts +++ b/packages/fuse-client/syscalls/fsyncdir.ts @@ -5,7 +5,7 @@ export const fsyncdir: (backend: SQLiteBackend) => MountOptions["fsyncdir"] = ( backend ) => { return async (path, fd, datasync, cb) => { - console.log("fsyncdir(%s, %d, %d)", path, fd, datasync); + console.info("fsyncdir(%s, %d, %d)", path, fd, datasync); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/ftruncate.ts b/packages/fuse-client/syscalls/ftruncate.ts index 1696524..cb50abb 100644 --- a/packages/fuse-client/syscalls/ftruncate.ts +++ b/packages/fuse-client/syscalls/ftruncate.ts @@ -6,7 +6,7 @@ export const ftruncate: ( backend: SQLiteBackend ) => MountOptions["ftruncate"] = (backend) => { return async (path, fd, size, cb) => { - console.log("ftruncate(%s, %d, %d)", path, fd, size); + console.info("ftruncate -> truncate(%s, %d, %d)", path, fd, size); //@ts-expect-error fix types // TODO: implement ftruncate properly truncate(backend)(path, size, cb); diff --git a/packages/fuse-client/syscalls/getxattr.ts b/packages/fuse-client/syscalls/getxattr.ts index 9141ee7..7eb6694 100644 --- a/packages/fuse-client/syscalls/getxattr.ts +++ b/packages/fuse-client/syscalls/getxattr.ts @@ -5,7 +5,7 @@ export const getxattr: (backend: SQLiteBackend) => MountOptions["getxattr"] = ( backend ) => { return async (path, name, buffer, length, offset, cb) => { - console.log( + console.info( "getxattr(%s, %s, %o, %d, %d)", path, name, diff --git a/packages/fuse-client/syscalls/listxattr.ts b/packages/fuse-client/syscalls/listxattr.ts index 57cf88c..01e7097 100644 --- a/packages/fuse-client/syscalls/listxattr.ts +++ b/packages/fuse-client/syscalls/listxattr.ts @@ -5,7 +5,7 @@ export const listxattr: ( backend: SQLiteBackend ) => MountOptions["listxattr"] = (backend) => { return async (path, buffer, length, cb) => { - console.log("listxattr(%s, %d, %d)", path, buffer, length); + console.info("listxattr(%s, %d, %d)", path, buffer, length); cb(0, 0); }; }; diff --git a/packages/fuse-client/syscalls/mkdir.ts b/packages/fuse-client/syscalls/mkdir.ts index d8f6a75..43440d7 100644 --- a/packages/fuse-client/syscalls/mkdir.ts +++ b/packages/fuse-client/syscalls/mkdir.ts @@ -5,7 +5,7 @@ export const mkdir: (backend: SQLiteBackend) => MountOptions["mkdir"] = ( backend ) => { return async (filepath, mode, cb) => { - console.log("mkdir(%s, %s)", filepath, mode); + console.info("mkdir(%s, %s)", filepath, mode); const filename = path.parse(filepath).base; if (filename.length > 255) { diff --git a/packages/fuse-client/syscalls/mknod.ts b/packages/fuse-client/syscalls/mknod.ts index fa3048a..b03285a 100644 --- a/packages/fuse-client/syscalls/mknod.ts +++ b/packages/fuse-client/syscalls/mknod.ts @@ -6,7 +6,7 @@ export const mknod: (backend: SQLiteBackend) => MountOptions["mknod"] = ( backend ) => { return async (path, mode, dev, cb) => { - console.log("mknod(%s, %d, %d)", path, mode, dev); + console.info("mknod -> create(%s, %d, %d)", path, mode, dev); //@ts-expect-error fix types // TODO: implement mknod properly create(backend)(path, mode, cb); diff --git a/packages/fuse-client/syscalls/read.ts b/packages/fuse-client/syscalls/read.ts index c5ea0d5..8995c23 100644 --- a/packages/fuse-client/syscalls/read.ts +++ b/packages/fuse-client/syscalls/read.ts @@ -6,7 +6,7 @@ export const read: (backend: SQLiteBackend) => MountOptions["read"] = ( backend ) => { return async (path, fd, buf, len, pos, cb) => { - console.log("read(%s, %d, %d, %d)", path, fd, len, pos); + console.info("read(%s, %d, %d, %d)", path, fd, len, pos); const r = await backend.getFileChunks(fd, pos, len); await match(r) .with({ status: "ok" }, async (r) => { diff --git a/packages/fuse-client/syscalls/readdir.ts b/packages/fuse-client/syscalls/readdir.ts index 9d41689..f840c4c 100644 --- a/packages/fuse-client/syscalls/readdir.ts +++ b/packages/fuse-client/syscalls/readdir.ts @@ -5,7 +5,7 @@ export const readdir: (backend: SQLiteBackend) => MountOptions["readdir"] = ( backend ) => { return async (path, cb) => { - console.log("readdir(%s)", path); + console.info("readdir(%s)", path); // TODO: figure out how are these directories in output of ls -la const dotDirs = [".", ".."]; diff --git a/packages/fuse-client/syscalls/release.ts b/packages/fuse-client/syscalls/release.ts index 5516938..883a447 100644 --- a/packages/fuse-client/syscalls/release.ts +++ b/packages/fuse-client/syscalls/release.ts @@ -5,7 +5,7 @@ export const release: (backend: SQLiteBackend) => MountOptions["release"] = ( backend ) => { return async (path, fd, cb) => { - console.log("release(%s, %d)", path, fd); + console.info("release(%s, %d)", path, fd); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/releasedir.ts b/packages/fuse-client/syscalls/releasedir.ts index 98aa815..4e3d9fe 100644 --- a/packages/fuse-client/syscalls/releasedir.ts +++ b/packages/fuse-client/syscalls/releasedir.ts @@ -5,7 +5,7 @@ export const releasedir: ( backend: SQLiteBackend ) => MountOptions["releasedir"] = (backend) => { return async (path, fd, cb) => { - console.log("releasedir(%s, %d)", path, fd); + console.info("releasedir(%s, %d)", path, fd); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/removexattr.ts b/packages/fuse-client/syscalls/removexattr.ts index 69060de..ae4daeb 100644 --- a/packages/fuse-client/syscalls/removexattr.ts +++ b/packages/fuse-client/syscalls/removexattr.ts @@ -5,7 +5,7 @@ export const removexattr: ( backend: SQLiteBackend ) => MountOptions["removexattr"] = (backend) => { return async (path, name, cb) => { - console.log("removexattr(%s, %s)", path, name); + console.info("removexattr(%s, %s)", path, name); cb(0); }; }; diff --git a/packages/fuse-client/syscalls/rename.ts b/packages/fuse-client/syscalls/rename.ts index 31314ac..2b4a2e9 100644 --- a/packages/fuse-client/syscalls/rename.ts +++ b/packages/fuse-client/syscalls/rename.ts @@ -5,10 +5,9 @@ export const rename: (backend: SQLiteBackend) => MountOptions["rename"] = ( backend ) => { return async (srcPath, destPath, cb) => { - console.log("rename(%s, %s)", srcPath, destPath); + console.info("rename(%s, %s)", srcPath, destPath); const r = await backend.renameFile(srcPath, destPath); if (r.status === "ok") { - console.log("rename(%s, %s)", srcPath, destPath); cb(0); } else { // TODO: can move fail, if yes, when? diff --git a/packages/fuse-client/syscalls/rmdir.ts b/packages/fuse-client/syscalls/rmdir.ts index dea31ef..f9e3d3e 100644 --- a/packages/fuse-client/syscalls/rmdir.ts +++ b/packages/fuse-client/syscalls/rmdir.ts @@ -5,7 +5,7 @@ export const rmdir: (backend: SQLiteBackend) => MountOptions["rmdir"] = ( backend ) => { return async (path, cb) => { - console.log("rmdir(%s)", path); + console.info("rmdir(%s)", path); const r = await backend.deleteFile(path); match(r) .with({ status: "ok" }, (r) => { diff --git a/packages/fuse-client/syscalls/setxattr.ts b/packages/fuse-client/syscalls/setxattr.ts index a76334f..3b07903 100644 --- a/packages/fuse-client/syscalls/setxattr.ts +++ b/packages/fuse-client/syscalls/setxattr.ts @@ -5,7 +5,7 @@ export const setxattr: (backend: SQLiteBackend) => MountOptions["setxattr"] = ( backend ) => { return async (path, name, buffer, length, offset, flags, cb) => { - console.log( + console.info( "setxattr(%s, %s, %s, %d, %d, %d)", path, name, diff --git a/packages/fuse-client/syscalls/statfs.ts b/packages/fuse-client/syscalls/statfs.ts index ad308b9..6191198 100644 --- a/packages/fuse-client/syscalls/statfs.ts +++ b/packages/fuse-client/syscalls/statfs.ts @@ -5,7 +5,7 @@ export const statfs: (backend: SQLiteBackend) => MountOptions["statfs"] = ( backend ) => { return (path, cb) => { - console.log("statfs(%s)", path); + console.info("statfs(%s)", path); // TODO: fill actual values, these are just placeholders cb(0, { bsize: 1000000, // Block size diff --git a/packages/fuse-client/syscalls/truncate.ts b/packages/fuse-client/syscalls/truncate.ts index fff3f10..5f8f9f8 100644 --- a/packages/fuse-client/syscalls/truncate.ts +++ b/packages/fuse-client/syscalls/truncate.ts @@ -6,7 +6,7 @@ export const truncate: (backend: SQLiteBackend) => MountOptions["truncate"] = ( backend ) => { return async (path, size, cb) => { - console.log("truncate(%s, %d)", path, size); + console.info("truncate(%s, %d)", path, size); const r = await backend.truncateFile(path, size); await match(r) .with({ status: "ok" }, async (r) => { diff --git a/packages/fuse-client/syscalls/unlink.ts b/packages/fuse-client/syscalls/unlink.ts index b8b6f65..07985ef 100644 --- a/packages/fuse-client/syscalls/unlink.ts +++ b/packages/fuse-client/syscalls/unlink.ts @@ -5,7 +5,7 @@ export const unlink: (backend: SQLiteBackend) => MountOptions["unlink"] = ( backend ) => { return async (path, cb) => { - console.log("unlink(%s)", path); + console.info("unlink(%s)", path); const r = await backend.deleteFile(path); if (r.status === "ok") { cb(0); diff --git a/packages/fuse-client/syscalls/utimens.ts b/packages/fuse-client/syscalls/utimens.ts index 14109ef..1a8664e 100644 --- a/packages/fuse-client/syscalls/utimens.ts +++ b/packages/fuse-client/syscalls/utimens.ts @@ -5,7 +5,7 @@ export const utimens: (backend: SQLiteBackend) => MountOptions["utimens"] = ( backend ) => { return async (path, atime, mtime, cb) => { - console.log("utimens(%s, %s, %s)", path, atime, mtime); + console.info("utimens(%s, %s, %s)", path, atime, mtime); try { await backend.updateTimes(path, atime, mtime); } catch (e) { diff --git a/packages/fuse-client/syscalls/write.ts b/packages/fuse-client/syscalls/write.ts index 6da4f67..f6ed0a2 100644 --- a/packages/fuse-client/syscalls/write.ts +++ b/packages/fuse-client/syscalls/write.ts @@ -5,7 +5,7 @@ export const write: (backend: SQLiteBackend) => MountOptions["write"] = ( backend ) => { return async (path, fd, buf, len, pos, cb) => { - console.log("write(%s, %d, %d, %d)", path, fd, len, pos); + console.info("write(%s, %d, %d, %d)", path, fd, len, pos); const chunk = Buffer.from(buf, pos, len); // TODO: This may throw (because of flush!, what should happen then?) await backend.write(path, { content: chunk, offset: pos, size: len }); diff --git a/packages/sqlite-backend/WriteBuffer.ts b/packages/sqlite-backend/WriteBuffer.ts index ba9e858..d62eb17 100644 --- a/packages/sqlite-backend/WriteBuffer.ts +++ b/packages/sqlite-backend/WriteBuffer.ts @@ -8,6 +8,9 @@ export class WriteBuffer { async write(item: T): Promise { this.buffer.push(item); if (this.buffer.length >= this.size) { + console.info( + `WriteBuffer.write: Flushing because buffer size exceeded the set limit of ${this.size}` + ); await this.flush(); } // TODO: implement a time based flush, like, if there are no writes for 100ms diff --git a/packages/sqlite-backend/baseline.sql b/packages/sqlite-backend/prisma/baseline.sql similarity index 59% rename from packages/sqlite-backend/baseline.sql rename to packages/sqlite-backend/prisma/baseline.sql index 4817ae6..26e3f35 100644 --- a/packages/sqlite-backend/baseline.sql +++ b/packages/sqlite-backend/prisma/baseline.sql @@ -1,4 +1,5 @@ -- CreateTable +DROP TABLE IF EXISTS "File"; CREATE TABLE "File" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "type" TEXT NOT NULL, @@ -7,7 +8,6 @@ CREATE TABLE "File" ( "name" TEXT NOT NULL, "dir" TEXT NOT NULL, "path" TEXT NOT NULL, - "content" BLOB NOT NULL, "uid" INTEGER NOT NULL, "gid" INTEGER NOT NULL, "atime" DATETIME NOT NULL, @@ -15,6 +15,17 @@ CREATE TABLE "File" ( "ctime" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); +DROP TABLE IF EXISTS "Content"; +-- CreateTable +CREATE TABLE "Content" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "content" BLOB NOT NULL, + "offset" INTEGER NOT NULL, + "size" INTEGER NOT NULL, + "fileId" INTEGER NOT NULL, + CONSTRAINT "Content_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + -- CreateIndex CREATE UNIQUE INDEX "File_path_key" ON "File"("path"); diff --git a/packages/zoid-fs-client/index.ts b/packages/zoid-fs-client/index.ts index 994c392..6e984e5 100644 --- a/packages/zoid-fs-client/index.ts +++ b/packages/zoid-fs-client/index.ts @@ -36,7 +36,7 @@ const backend = await match(backendArg) const fuseClient = new FuseClient(backend); setTimeout(async () => { - console.log("mounting: fuse mount points"); + console.info("mounting: fuse mount points"); fuseClient.mountFS(mountPathArg); }, 1000);