Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mount #1

Merged
merged 3 commits into from
Oct 12, 2023
Merged

Support mount #1

merged 3 commits into from
Oct 12, 2023

Conversation

mohanson
Copy link
Collaborator

No description provided.

@@ -460,6 +461,18 @@ static JSValue syscall_current_memory(JSContext *ctx, JSValueConst this_value, i
return JS_NewUint32(ctx, (uint32_t)size);
}

static JSValue mount(JSContext *ctx, JSValueConst this_value, int argc, JSValueConst *argv) {
JSValue buf = syscall_load_cell_data(ctx, this_value, argc, argv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check buf is valid.

@@ -501,6 +514,8 @@ int js_init_module_ckb(JSContext *ctx) {
JS_NewCFunction(ctx, syscall_get_memory_limit, "get_memory_limit", 0));
JS_SetPropertyStr(ctx, ckb, "current_memory",
JS_NewCFunction(ctx, syscall_current_memory, "current_memory", 0));
JS_SetPropertyStr(ctx, ckb, "mount",
JS_NewCFunction(ctx, mount, "mount", 3));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mount has only 2 arguments.

quickjs/qjs.c Outdated
@@ -304,18 +318,23 @@ int main(int argc, const char **argv) {
switch (type) {
case RunJsWithCode:
err = eval_buf(ctx, argv[1], strlen(argv[1]), "<cmdline>", 0);
js_std_loop(ctx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When error occurs, no need to continue.

@@ -0,0 +1,11 @@
/* example of JS module */

ckb.mount(2, 3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ckb consts. e.g. ckb.SOURCE_INPUT.

@XuJiandong
Copy link
Collaborator

XuJiandong commented Oct 12, 2023

Don't forget updating the document in docs/syscalls.md.

@XuJiandong XuJiandong merged commit d3d06ca into nervosnetwork:main Oct 12, 2023
2 checks passed
@mohanson mohanson deleted the mount branch December 13, 2024 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants