Previously vfscore_mount_volume would pass a const path to
vfscore_ukopt_mkmp, which expects a mutable path, and indeed does modify
it in-place during execution. This is wrong and rightfully triggers a
compiler warning.
This change fixes this by having mkmp allocate a temporary writable path.
Checkpatch-Ignore: STRCPY
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1636
#endif /* CONFIG_LIBUKCPIO */
/* Handle `mkmp` Unikraft Mount Option */
-static int vfscore_ukopt_mkmp(char *path)
+static int vfscore_ukopt_mkmp(const char *path_arg)
{
+ char path[strlen(path_arg) + 1];
char *pos, *prev_pos;
int rc;
- UK_ASSERT(path);
- UK_ASSERT(path[0] == '/');
+ UK_ASSERT(path_arg[0] == '/');
- if (path[1] == '\0') {
+ if (path_arg[1] == '\0') {
uk_pr_debug(" mkmp: Called on '/', nothing to pre-create\n");
return 0;
}
+ strcpy(path, path_arg);
uk_pr_debug(" mkmp: Ensure mount path \"%s\" exists\n", path);
pos = path;