-
Notifications
You must be signed in to change notification settings - Fork 420
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
Change path max stack allocation to heap #10127
base: master
Are you sure you want to change the base?
Changes from all commits
2a83842
533b10e
07b11f0
20e3aca
d1ed141
abe248e
dcc406a
5f30717
84f8d0f
bdf20a9
80e54aa
8bf1be4
ffa0f80
b4e2ef9
903e27d
10887ae
ca52631
a1af73b
77945e8
5530e3f
683f4e2
d7ac06a
c268306
422a782
27e63b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,9 @@ | |
|
||
#include "vfs_daemon.h" | ||
|
||
#include <ucs/sys/string.h> | ||
#include <ucs/debug/log_def.h> | ||
#include <ucs/debug/memtrack_int.h> | ||
#include <sys/wait.h> | ||
#include <limits.h> | ||
#include <stdlib.h> | ||
|
@@ -151,10 +153,17 @@ static const char *vfs_get_process_name(int pid, char *buf, size_t max_length) | |
|
||
int vfs_mount(int pid) | ||
{ | ||
char mountpoint[PATH_MAX]; | ||
char mountopts[1024]; | ||
char name[NAME_MAX]; | ||
char *mountpoint; | ||
int fuse_fd, ret; | ||
ucs_status_t status; | ||
|
||
status = ucs_string_alloc_path_buffer(&mountpoint, "mountpoint"); | ||
if (status != UCS_OK) { | ||
ret = -ENOMEM; | ||
goto out; | ||
} | ||
|
||
/* Add common mount options: | ||
* - File system name (source) : process name and pid | ||
|
@@ -168,58 +177,75 @@ int vfs_mount(int pid) | |
vfs_get_process_name(pid, name, sizeof(name)), | ||
(strlen(g_opts.mount_opts) > 0) ? "," : "", g_opts.mount_opts); | ||
if (ret >= sizeof(mountopts)) { | ||
return -ENOMEM; | ||
ret = -ENOMEM; | ||
goto out_free_mountpoint; | ||
} | ||
|
||
/* Create the mount point directory, and ignore "already exists" error */ | ||
vfs_get_mountpoint(pid, mountpoint, sizeof(mountpoint)); | ||
vfs_get_mountpoint(pid, mountpoint, PATH_MAX); | ||
ret = mkdir(mountpoint, S_IRWXU); | ||
if ((ret < 0) && (errno != EEXIST)) { | ||
ret = -errno; | ||
vfs_error("failed to create directory '%s': %m", mountpoint); | ||
return ret; | ||
goto out_free_mountpoint; | ||
} | ||
|
||
/* Mount a new FUSE filesystem in the mount point directory */ | ||
vfs_log("mounting directory '%s' with options '%s'", mountpoint, mountopts); | ||
fuse_fd = fuse_open_channel(mountpoint, mountopts); | ||
if (fuse_fd < 0) { | ||
ret = fuse_fd; | ||
vfs_error("fuse_open_channel(%s,opts=%s) failed: %m", mountpoint, | ||
mountopts); | ||
return fuse_fd; | ||
goto out_free_mountpoint; | ||
} | ||
|
||
vfs_log("mounted directory '%s' with fd %d", mountpoint, fuse_fd); | ||
return fuse_fd; | ||
ret = fuse_fd; | ||
|
||
out_free_mountpoint: | ||
ucs_free(mountpoint); | ||
out: | ||
return ret; | ||
} | ||
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need goto? |
||
} | ||
|
||
return 0; | ||
out_free_mountpoint: | ||
ucs_free(mountpoint); | ||
out: | ||
return ret; | ||
} | ||
|
||
static int vfs_unlink_socket(int silent_notexist) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1614,15 +1614,21 @@ void ucs_config_parse_config_file(const char *dir_path, const char *file_name, | |
.section_info = {.name = "", | ||
.skip = 0} | ||
}; | ||
char file_path[MAXPATHLEN]; | ||
char *file_path; | ||
int parse_result; | ||
FILE* file; | ||
ucs_status_t status; | ||
|
||
status = ucs_string_alloc_path_buffer(&file_path, "file_path"); | ||
if (status != UCS_OK) { | ||
goto out; | ||
} | ||
|
||
ucs_snprintf_safe(file_path, MAXPATHLEN, "%s/%s", dir_path, file_name); | ||
file = fopen(file_path, "r"); | ||
if (file == NULL) { | ||
ucs_debug("failed to open config file %s: %m", file_path); | ||
return; | ||
goto out_free_file_path; | ||
} | ||
|
||
parse_result = ini_parse_file(file, ucs_config_parse_config_file_line, | ||
|
@@ -1633,6 +1639,11 @@ void ucs_config_parse_config_file(const char *dir_path, const char *file_name, | |
|
||
ucs_debug("parsed config file %s", file_path); | ||
fclose(file); | ||
|
||
out_free_file_path: | ||
ucs_free(file_path); | ||
out: | ||
return; | ||
} | ||
|
||
static ucs_status_t | ||
|
@@ -1750,8 +1761,14 @@ static ucs_status_t ucs_config_parser_get_sub_prefix(const char *env_prefix, | |
|
||
void ucs_config_parse_config_files() | ||
{ | ||
char *path; | ||
const char *path_p; | ||
char path[PATH_MAX]; | ||
ucs_status_t status; | ||
|
||
status = ucs_string_alloc_path_buffer(&path, "path"); | ||
if (status != UCS_OK) { | ||
goto out; | ||
} | ||
|
||
/* System-wide configuration file */ | ||
ucs_config_parse_config_file(UCX_CONFIG_DIR, UCX_CONFIG_FILE_NAME, 1); | ||
|
@@ -1778,6 +1795,11 @@ void ucs_config_parse_config_files() | |
|
||
/* Current working dir */ | ||
ucs_config_parse_config_file(".", UCX_CONFIG_FILE_NAME, 1); | ||
|
||
out_free_path: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused label (pls check other places too)? |
||
ucs_free(path); | ||
out: | ||
return; | ||
} | ||
|
||
ucs_status_t | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,10 +433,10 @@ void ucs_memtrack_init() | |
return; | ||
} | ||
|
||
ucs_memtrack_vfs_init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that change related to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I changed allocation at VFS to heap and it revealed this issue - an invalid count in the memtrack (tests were failing) |
||
|
||
ucs_debug("memtrack enabled"); | ||
ucs_memtrack_context.enabled = 1; | ||
|
||
ucs_memtrack_vfs_init(); | ||
} | ||
|
||
void ucs_memtrack_cleanup() | ||
|
@@ -447,12 +447,11 @@ void ucs_memtrack_cleanup() | |
return; | ||
} | ||
|
||
ucs_vfs_obj_remove(&ucs_memtrack_context); | ||
|
||
ucs_memtrack_generate_report(); | ||
|
||
/* disable before releasing the stats node */ | ||
/* disable before releasing the vfs object and the stats node */ | ||
ucs_memtrack_context.enabled = 0; | ||
ucs_vfs_obj_remove(&ucs_memtrack_context); | ||
UCS_STATS_NODE_FREE(ucs_memtrack_context.stats); | ||
|
||
/* cleanup entries */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.