mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-12-11 18:12:53 +00:00
Merge 50d92d36f2 into 081c3445ef
This commit is contained in:
commit
c77e785b5a
|
|
@ -120,13 +120,15 @@ zephyr_fs_alloc_obj(bool is_dir, const char *path, int *index)
|
||||||
ptr = &desc_array[i];
|
ptr = &desc_array[i];
|
||||||
ptr->used = true;
|
ptr->used = true;
|
||||||
ptr->is_dir = is_dir;
|
ptr->is_dir = is_dir;
|
||||||
ptr->path = bh_strdup(path);
|
|
||||||
ptr->dir_index = 0;
|
ptr->dir_index = 0;
|
||||||
|
size_t path_len = strlen(path) + 1;
|
||||||
|
ptr->path = BH_MALLOC(path_len);
|
||||||
if (ptr->path == NULL) {
|
if (ptr->path == NULL) {
|
||||||
ptr->used = false;
|
ptr->used = false;
|
||||||
k_mutex_unlock(&desc_array_mutex);
|
k_mutex_unlock(&desc_array_mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
strcpy(ptr->path, path);
|
||||||
*index = i + 3;
|
*index = i + 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -850,11 +852,17 @@ os_renameat(os_file_handle old_handle, const char *old_path,
|
||||||
for (int i = 0; i < CONFIG_WASI_MAX_OPEN_FILES; i++) {
|
for (int i = 0; i < CONFIG_WASI_MAX_OPEN_FILES; i++) {
|
||||||
struct zephyr_fs_desc *ptr = &desc_array[i];
|
struct zephyr_fs_desc *ptr = &desc_array[i];
|
||||||
if (ptr->used && ptr->path && strcmp(ptr->path, abs_old_path) == 0) {
|
if (ptr->used && ptr->path && strcmp(ptr->path, abs_old_path) == 0) {
|
||||||
char *new_path_copy = bh_strdup(new_path);
|
size_t new_path_len = strlen(abs_new_path) + 1;
|
||||||
|
char *new_path_copy = BH_MALLOC(new_path_len);
|
||||||
if (new_path_copy != NULL) {
|
if (new_path_copy != NULL) {
|
||||||
|
strcpy(new_path_copy, abs_new_path);
|
||||||
BH_FREE(ptr->path);
|
BH_FREE(ptr->path);
|
||||||
ptr->path = new_path_copy;
|
ptr->path = new_path_copy;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
k_mutex_unlock(&desc_array_mutex);
|
||||||
|
return __WASI_ENOMEM;
|
||||||
|
}
|
||||||
break; // Only one descriptor should match
|
break; // Only one descriptor should match
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1195,4 +1203,4 @@ bool
|
||||||
os_is_stderr_handle(os_file_handle handle)
|
os_is_stderr_handle(os_file_handle handle)
|
||||||
{
|
{
|
||||||
return (handle == (os_file_handle)stderr);
|
return (handle == (os_file_handle)stderr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user