@@ -192,7 +192,12 @@ libwasmtime_run_module (void *cookie, char *const argv[], wasm_engine_t *engine,
192
192
void (* wasmtime_store_delete ) (wasmtime_store_t * store );
193
193
void (* wasmtime_error_message ) (const wasmtime_error_t * error , wasm_name_t * message );
194
194
void (* wasmtime_error_delete ) (wasmtime_error_t * error );
195
- bool (* wasi_config_preopen_dir ) (wasi_config_t * config , const char * path , const char * guest_path );
195
+ bool (* wasi_config_preopen_dir ) (
196
+ wasi_config_t * config ,
197
+ const char * path ,
198
+ const char * guest_path ,
199
+ wasi_dir_perms dir_perms ,
200
+ wasi_file_perms file_perms );
196
201
197
202
wasm_engine_delete = dlsym (cookie , "wasm_engine_delete" );
198
203
wasm_byte_vec_delete = dlsym (cookie , "wasm_byte_vec_delete" );
@@ -270,7 +275,12 @@ libwasmtime_run_module (void *cookie, char *const argv[], wasm_engine_t *engine,
270
275
wasi_config_inherit_stdin (wasi_config );
271
276
wasi_config_inherit_stdout (wasi_config );
272
277
wasi_config_inherit_stderr (wasi_config );
273
- wasi_config_preopen_dir (wasi_config , "." , "." );
278
+ wasi_config_preopen_dir (
279
+ wasi_config ,
280
+ "." ,
281
+ "." ,
282
+ WASMTIME_WASI_DIR_PERMS_READ | WASMTIME_WASI_DIR_PERMS_WRITE ,
283
+ WASMTIME_WASI_FILE_PERMS_READ | WASMTIME_WASI_FILE_PERMS_WRITE );
274
284
wasm_trap_t * trap = NULL ;
275
285
err = wasmtime_context_set_wasi (context , wasi_config );
276
286
if (err != NULL )
@@ -369,6 +379,12 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
369
379
void (* wasmtime_component_linker_delete ) (wasmtime_component_linker_t * linker );
370
380
void (* wasmtime_error_message ) (const wasmtime_error_t * error , wasm_name_t * message );
371
381
void (* wasmtime_error_delete ) (wasmtime_error_t * error );
382
+ bool (* wasi_config_preopen_dir ) (
383
+ wasi_config_t * config ,
384
+ const char * path ,
385
+ const char * guest_path ,
386
+ wasi_dir_perms dir_perms ,
387
+ wasi_file_perms file_perms );
372
388
373
389
wasm_engine_delete = dlsym (cookie , "wasm_engine_delete" );
374
390
wasm_byte_vec_delete = dlsym (cookie , "wasm_byte_vec_delete" );
@@ -394,6 +410,7 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
394
410
wasmtime_component_linker_delete = dlsym (cookie , "wasmtime_component_linker_delete" );
395
411
wasmtime_error_message = dlsym (cookie , "wasmtime_error_message" );
396
412
wasmtime_error_delete = dlsym (cookie , "wasmtime_error_delete" );
413
+ wasi_config_preopen_dir = dlsym (cookie , "wasi_config_preopen_dir" );
397
414
398
415
if (wasm_engine_delete == NULL || wasm_byte_vec_delete == NULL || wasmtime_store_new == NULL
399
416
|| wasmtime_store_delete == NULL || wasmtime_store_context == NULL || wasmtime_component_new == NULL
@@ -403,7 +420,7 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
403
420
|| wasmtime_component_linker_instantiate == NULL || wasmtime_component_instance_get_export_index == NULL
404
421
|| wasmtime_component_instance_get_func == NULL || wasmtime_component_func_call == NULL || wasmtime_component_export_index_delete == NULL
405
422
|| wasmtime_component_delete == NULL || wasmtime_component_linker_delete == NULL || wasmtime_error_message == NULL
406
- || wasmtime_error_delete == NULL )
423
+ || wasmtime_error_delete == NULL || wasi_config_preopen_dir == NULL )
407
424
error (EXIT_FAILURE , 0 , "could not find symbol in `libwasmtime.so`" );
408
425
409
426
// Set up wasmtime context
@@ -432,6 +449,12 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
432
449
wasmtime_wasip2_config_inherit_stdin (wasi_config );
433
450
wasmtime_wasip2_config_inherit_stdout (wasi_config );
434
451
wasmtime_wasip2_config_inherit_stderr (wasi_config );
452
+ wasi_config_preopen_dir (
453
+ (wasi_config_t * ) wasi_config ,
454
+ "." ,
455
+ "." ,
456
+ WASMTIME_WASI_DIR_PERMS_READ | WASMTIME_WASI_DIR_PERMS_WRITE ,
457
+ WASMTIME_WASI_FILE_PERMS_READ | WASMTIME_WASI_FILE_PERMS_WRITE );
435
458
436
459
for (arg = argv ; * arg != NULL ; ++ arg )
437
460
wasmtime_wasip2_config_arg (wasi_config , * arg , strlen (* arg ));
0 commit comments