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

Function private_log_file_open

src/daemon/ipc.c:1550–1567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1548}
1549
1550static int private_log_file_open(int directory_fd, const char *base_name, struct stat *status_out) {
1551 int flags = O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK;
1552 int fd = openat(directory_fd, base_name, flags | O_CREAT | O_EXCL, 0600);
1553 if (fd < 0 && errno == EEXIST) {
1554 fd = openat(directory_fd, base_name, flags);
1555 }
1556 struct stat status;
1557 if (fd < 0 || !fd_set_cloexec(fd) || fchmod(fd, 0600) != 0 ||
1558 !private_regular_file_snapshot(directory_fd, base_name, fd, 1, &status) ||
1559 status.st_size < 0) {
1560 if (fd >= 0) {
1561 (void)close(fd);
1562 }
1563 return -1;
1564 }
1565 *status_out = status;
1566 return fd;
1567}
1568
1569FILE *cbm_daemon_ipc_private_log_open(const char *directory_path, const char *base_name,
1570 size_t rotate_cap_bytes) {

Callers 1

Calls 2

fd_set_cloexecFunction · 0.85

Tested by

no test coverage detected