MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / private_log_file_open

Function private_log_file_open

src/daemon/ipc.c:2151–2168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2149}
2150
2151static int private_log_file_open(int directory_fd, const char *base_name, struct stat *status_out) {
2152 int flags = O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK;
2153 int fd = openat(directory_fd, base_name, flags | O_CREAT | O_EXCL, 0600);
2154 if (fd < 0 && errno == EEXIST) {
2155 fd = openat(directory_fd, base_name, flags);
2156 }
2157 struct stat status;
2158 if (fd < 0 || !fd_set_cloexec(fd) || fchmod(fd, 0600) != 0 ||
2159 !private_regular_file_snapshot(directory_fd, base_name, fd, 1, &status) ||
2160 status.st_size < 0) {
2161 if (fd >= 0) {
2162 (void)close(fd);
2163 }
2164 return -1;
2165 }
2166 *status_out = status;
2167 return fd;
2168}
2169
2170FILE *cbm_daemon_ipc_private_log_open(const char *directory_path, const char *base_name,
2171 size_t rotate_cap_bytes) {

Callers 1

Calls 3

fd_set_cloexecFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected