mirror of
https://github.com/falk-werner/webfuse
synced 2025-06-13 12:54:15 +00:00
adds filesystem name/id to request parameters
This commit is contained in:
parent
d33f0f36cc
commit
2775d42647
18
README.md
18
README.md
@ -140,7 +140,7 @@ Notfications are used to inform a receiver about something. Unlike requests, not
|
||||
|
||||
Retrieve information about a filesystem entry by name.
|
||||
|
||||
webfuse daemon: {"method": "lookup", "params": [<parent>, <name>], "id": <id>}
|
||||
webfuse daemon: {"method": "lookup", "params": [<filesystem>, <parent>, <name>], "id": <id>}
|
||||
fs provider: {"result": {
|
||||
"inode": <inode>,
|
||||
"mode" : <mode>,
|
||||
@ -153,6 +153,7 @@ Retrieve information about a filesystem entry by name.
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | --------------- | ------------------------------------------- |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| parent | integer | inode of parent directory (1 = root) |
|
||||
| name | string | name of the filesystem object to look up |
|
||||
| inode | integer | inode of the filesystem object |
|
||||
@ -167,7 +168,7 @@ Retrieve information about a filesystem entry by name.
|
||||
|
||||
Get file attributes.
|
||||
|
||||
webfuse daemon: {"method": "getattr", "params": [<inode>], "id": <id>}
|
||||
webfuse daemon: {"method": "getattr", "params": [<filesystem>, <inode>], "id": <id>}
|
||||
fs provider: {"result": {
|
||||
"mode" : <mode>,
|
||||
"type" : <type>,
|
||||
@ -179,6 +180,7 @@ Get file attributes.
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | --------------- | ------------------------------------------- |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| inode | integer | inode of the filesystem object |
|
||||
| mode | integer | unix file mode |
|
||||
| type | "file" or "dir" | type of filesystem object |
|
||||
@ -193,7 +195,7 @@ Read directory contents.
|
||||
Result is an array of name-inode pairs for each entry. The generic entries
|
||||
"." and ".." should also be provided.
|
||||
|
||||
webfuse daemon: {"method": "readdir", "params": [<dir_inode>], "id": <id>}
|
||||
webfuse daemon: {"method": "readdir", "params": [<filesystem>, <dir_inode>], "id": <id>}
|
||||
fs provider: {"result": [
|
||||
{"name": <name>, "inode": <inode>},
|
||||
...
|
||||
@ -201,6 +203,7 @@ Result is an array of name-inode pairs for each entry. The generic entries
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | --------------- | ------------------------------ |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| dir_inode | integer | inode of the directory to read |
|
||||
| name | integer | name of the entry |
|
||||
| inode | integer | inode of the entry |
|
||||
@ -209,11 +212,12 @@ Result is an array of name-inode pairs for each entry. The generic entries
|
||||
|
||||
Open a file.
|
||||
|
||||
webfuse daemon: {"method": "readdir", "params": [<inode>, <flags>], "id": <id>}
|
||||
webfuse daemon: {"method": "readdir", "params": [<filesystem>, <inode>, <flags>], "id": <id>}
|
||||
fs provider: {"result": {"handle": <handle>}, "id": <id>}
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | ----------| ----------------------------- |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| inode | integer | inode of the file |
|
||||
| flags | integer | access mode flags (see below) |
|
||||
| handle | integer | handle of the file |
|
||||
@ -236,10 +240,11 @@ Open a file.
|
||||
Informs filesystem provider, that a file is closed.
|
||||
Since `close` is a notification, it cannot fail.
|
||||
|
||||
webfuse daemon: {"method": "close", "params": [<inode>, <handle>, <flags>], "id": <id>}
|
||||
webfuse daemon: {"method": "close", "params": [<filesystem>, <inode>, <handle>, <flags>], "id": <id>}
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | ----------| ---------------------------- |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| inode | integer | inode of the file |
|
||||
| handle | integer | handle of the file |
|
||||
| flags | integer | access mode flags (see open) |
|
||||
@ -248,7 +253,7 @@ Since `close` is a notification, it cannot fail.
|
||||
|
||||
Read from an open file.
|
||||
|
||||
webfuse daemon: {"method": "close", "params": [<inode>, <handle>, <offset>, <length>], "id": <id>}
|
||||
webfuse daemon: {"method": "close", "params": [<filesystem>, <inode>, <handle>, <offset>, <length>], "id": <id>}
|
||||
fs provider: {"result": {
|
||||
"data": <data>,
|
||||
"format": <format>,
|
||||
@ -257,6 +262,7 @@ Read from an open file.
|
||||
|
||||
| Item | Data type | Description |
|
||||
| ----------- | ----------| ----------------------------- |
|
||||
| filesystem | string | name of the filesystem |
|
||||
| inode | integer | inode of the file |
|
||||
| handle | integer | handle of the file |
|
||||
| offset | integer | Offet to start read operation |
|
||||
|
@ -35,7 +35,7 @@ export class Client {
|
||||
}
|
||||
|
||||
addProvider(name, provider) {
|
||||
this._provider = provider;
|
||||
this._provider[name] = provider;
|
||||
const request = {
|
||||
"method": "add_filesystem",
|
||||
"params": [name],
|
||||
@ -125,28 +125,43 @@ export class Client {
|
||||
}
|
||||
}
|
||||
|
||||
async _lookup([parent, name]) {
|
||||
return this._provider.lookup(parent, name);
|
||||
_getProvider(name) {
|
||||
if (this._provider.hasOwnProperty(name)) {
|
||||
return this._provider[name];
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown provider');
|
||||
}
|
||||
}
|
||||
|
||||
async _getattr([inode]) {
|
||||
return this._provider.getattr(inode);
|
||||
async _lookup([providerName, parent, name]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
return provider.lookup(parent, name);
|
||||
}
|
||||
|
||||
async _readdir([inode]) {
|
||||
return this._provider.readdir(inode);
|
||||
async _getattr([providerName, inode]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
return provider.getattr(inode);
|
||||
}
|
||||
|
||||
async _open([inode, mode]) {
|
||||
return this._provider.open(inode, mode);
|
||||
async _readdir([providerName, inode]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
return provider.readdir(inode);
|
||||
}
|
||||
|
||||
_close([inode, handle, mode]) {
|
||||
this._provider.close(inode, handle, mode);
|
||||
async _open([providerName, inode, mode]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
return provider.open(inode, mode);
|
||||
}
|
||||
|
||||
async _read([inode, handle, offset, length]) {
|
||||
const data = await this._provider.read(inode, handle, offset, length);
|
||||
_close([providerName, inode, handle, mode]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
provider.close(inode, handle, mode);
|
||||
}
|
||||
|
||||
async _read([providerName, inode, handle, offset, length]) {
|
||||
const provider = this._getProvider(providerName);
|
||||
const data = await provider.read(inode, handle, offset, length);
|
||||
|
||||
if ("string" === typeof(data)) {
|
||||
return {
|
||||
|
@ -18,7 +18,7 @@ void wf_impl_operation_close(
|
||||
if (NULL != rpc)
|
||||
{
|
||||
int handle = (int) (file_info->fh & INT_MAX);
|
||||
wf_impl_jsonrpc_proxy_notify(rpc, "close", "iii", inode, handle, file_info->flags);
|
||||
wf_impl_jsonrpc_proxy_notify(rpc, "close", "siii", user_data->name, inode, handle, file_info->flags);
|
||||
}
|
||||
|
||||
fuse_reply_err(request, 0);
|
||||
|
@ -91,7 +91,7 @@ void wf_impl_operation_getattr (
|
||||
getattr_context->gid = context->gid;
|
||||
getattr_context->timeout = user_data->timeout;
|
||||
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "i", inode);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "si", user_data->name, inode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ void wf_impl_operation_lookup (
|
||||
lookup_context->gid = context->gid;
|
||||
lookup_context->timeout = user_data->timeout;
|
||||
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "is", (int) (parent & INT_MAX), name);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "sis", user_data->name, (int) (parent & INT_MAX), name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ void wf_impl_operation_open(
|
||||
|
||||
if (NULL != rpc)
|
||||
{
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "ii", inode, file_info->flags);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "sii", user_data->name, inode, file_info->flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ void wf_impl_operation_read(
|
||||
{
|
||||
int const length = (size <= WF_MAX_READ_LENGTH) ? (int) size : WF_MAX_READ_LENGTH;
|
||||
int handle = (file_info->fh & INT_MAX);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "iiii", inode, handle, (int) offset, length);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "siiii", user_data->name, inode, handle, (int) offset, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ void wf_impl_operation_readdir (
|
||||
readdir_context->size = size;
|
||||
readdir_context->offset = offset;
|
||||
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "i", inode);
|
||||
wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "si", user_data->name, inode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user