From a3f25d346f5b17bfbfbac13265812f3360e9fe45 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Thu, 28 Feb 2019 01:05:28 -0800 Subject: Add tabs/by-title. Fix symlink stuff to make it work? FUSE readlink needing to return 0 + getattr needing to return correct st_size was _not_ obvious, lol. --- extension/background.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'extension') diff --git a/extension/background.js b/extension/background.js index 0bf5808..0d3186b 100644 --- a/extension/background.js +++ b/extension/background.js @@ -74,6 +74,28 @@ const router = { * } * }, */ + "by-title": { + async readdir() { + const tabs = await queryTabs(); + return tabs.map(tab => sanitize(String(tab.title)) + "_" + String(tab.id)); + }, + "*": { + async getattr(path) { + const st_size = (await this.readlink(path)).length + 1; + return { + st_mode: unix.S_IFLNK | 0444, + st_nlink: 1, + // You _must_ return correct linkee path length from getattr! + st_size + }; + }, + async readlink(path) { + const parts = path.split("_"); + const id = parts[parts.length - 1]; + return "../by-id/" + id; + } + } + }, "by-id": { async readdir() { const tabs = await queryTabs(); @@ -190,6 +212,10 @@ async function read(path, fh, size, offset) { let route = findRoute(path); if (route.read) return route.read(path, fh, size, offset); } +async function readlink(path) { + let route = findRoute(path); + if (route.readlink) return route.readlink(path); +} async function release(path, fh) { let route = findRoute(path); @@ -248,6 +274,13 @@ async function onmessage(event) { op: 'release' }; + } else if (req.op === 'readlink') { + const buf = await readlink(req.path) + response = { + op: 'readlink', + buf + }; + } else if (req.op === 'opendir') { response = { op: 'opendir', -- cgit v1.2.3