Skip to content

Commit

Permalink
TOOLS/VFS: convert stack allocation at vfs_unmount() to heap
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-shalev committed Sep 16, 2024
1 parent 422a782 commit 27e63b9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/tools/vfs/vfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,31 +211,41 @@ int vfs_mount(int pid)

int vfs_unmount(int pid)
{
char mountpoint[PATH_MAX];
char *mountpoint;
char *argv[5];
int ret;
ucs_status_t status;

status = ucs_string_alloc_path_buffer(&mountpoint, "mountpoint");
if (status != UCS_OK) {
ret = -ENOMEM;
goto out;
}

/* Unmount FUSE file system */
vfs_get_mountpoint(pid, mountpoint, sizeof(mountpoint));
vfs_get_mountpoint(pid, mountpoint, PATH_MAX);
argv[0] = "-u";
argv[1] = "-z";
argv[2] = "--";
argv[3] = mountpoint;
argv[4] = NULL;
ret = vfs_run_fusermount(argv);
if (ret < 0) {
return ret;
goto out_free_mountpoint;
}

/* Remove mount point directory */
vfs_log("removing directory '%s'", mountpoint);
ret = rmdir(mountpoint);
if (ret < 0) {
vfs_error("failed to remove directory '%s': %m", mountpoint);
return ret;
goto out_free_mountpoint;
}

return 0;
out_free_mountpoint:
ucs_free(mountpoint);
out:
return ret;
}

static int vfs_unlink_socket(int silent_notexist)
Expand Down

0 comments on commit 27e63b9

Please sign in to comment.