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

Function private_log_file_open

src/daemon/ipc.c:1569–1586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1567}
1568
1569static int private_log_file_open(int directory_fd, const char *base_name, struct stat *status_out) {
1570 int flags = O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK;
1571 int fd = openat(directory_fd, base_name, flags | O_CREAT | O_EXCL, 0600);
1572 if (fd < 0 && errno == EEXIST) {
1573 fd = openat(directory_fd, base_name, flags);
1574 }
1575 struct stat status;
1576 if (fd < 0 || !fd_set_cloexec(fd) || fchmod(fd, 0600) != 0 ||
1577 !private_regular_file_snapshot(directory_fd, base_name, fd, 1, &status) ||
1578 status.st_size < 0) {
1579 if (fd >= 0) {
1580 (void)close(fd);
1581 }
1582 return -1;
1583 }
1584 *status_out = status;
1585 return fd;
1586}
1587
1588FILE *cbm_daemon_ipc_private_log_open(const char *directory_path, const char *base_name,
1589 size_t rotate_cap_bytes) {

Callers 1

Calls 2

fd_set_cloexecFunction · 0.85

Tested by

no test coverage detected