mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-12 23:03:04 +00:00
Do not use the absolute path
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
//! - async tokio communicator core, which receives requests and processes them.
|
||||
//! - Main loop and requests queues, which routes requests from backends to the core
|
||||
//! - the per-backend glue code, which submits requests
|
||||
#![warn(unused)]
|
||||
|
||||
mod backend_comms;
|
||||
|
||||
|
||||
@@ -178,32 +178,6 @@ assign_request_id(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the absolute path to the given path.
|
||||
*/
|
||||
static inline char * get_absolute_path(const char *path)
|
||||
{
|
||||
char *abs_path = bounce_buf();
|
||||
char cwd[PATH_MAX];
|
||||
int size = 0;
|
||||
|
||||
if (path[0] == '/') {
|
||||
strncpy(abs_path, path, strlen(path));
|
||||
return abs_path;
|
||||
}
|
||||
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
|
||||
size = snprintf(NULL, 0, "%s/%s", cwd, path);
|
||||
|
||||
if (size < 0 || size >= PATH_MAX) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(abs_path, size + 1, "%s/%s", cwd, path);
|
||||
return abs_path;
|
||||
}
|
||||
|
||||
/**** Initialization functions. These run in postmaster ****/
|
||||
|
||||
void
|
||||
@@ -1041,13 +1015,15 @@ communicator_new_read_slru_segment(
|
||||
}
|
||||
};
|
||||
int nblocks = -1;
|
||||
char *abs_path = bounce_buf();
|
||||
|
||||
if (path == NULL) {
|
||||
elog(ERROR, "read_slru_segment called with NULL path");
|
||||
return -1;
|
||||
}
|
||||
|
||||
request.read_slru_segment.destination_file_path.ptr = (uint8_t *) get_absolute_path(path);
|
||||
strlcpy(abs_path, path, Min(PATH_MAX, strlen(path) + 1));
|
||||
request.read_slru_segment.destination_file_path.ptr = (uint8_t *) abs_path;
|
||||
|
||||
elog(DEBUG5, "readslrusegment called for kind=%u, segno=%u, file_path=\"%s\"",
|
||||
kind, segno, request.read_slru_segment.destination_file_path.ptr);
|
||||
|
||||
Reference in New Issue
Block a user