Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 928bdbf5 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Gerrit Code Review
Browse files

Merge "logcatd: unset pinning log files"

parents efe9defc 2e5b7c42
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -123,6 +123,18 @@ static int openLogFile(const char* pathname, size_t sizeKB) {
    return fd;
    return fd;
}
}


static void closeLogFile(const char* pathname) {
    int fd = open(pathname, O_WRONLY | O_CLOEXEC);
    if (fd == -1) {
        return;
    }

    // no need to check errors
    __u32 set = 0;
    ioctl(fd, F2FS_IOC_SET_PIN_FILE, &set);
    close(fd);
}

void Logcat::RotateLogs() {
void Logcat::RotateLogs() {
    // Can't rotate logs if we're not outputting to a file
    // Can't rotate logs if we're not outputting to a file
    if (!output_file_name_) return;
    if (!output_file_name_) return;
@@ -153,6 +165,8 @@ void Logcat::RotateLogs() {
            break;
            break;
        }
        }


        closeLogFile(file0.c_str());

        int err = rename(file0.c_str(), file1.c_str());
        int err = rename(file0.c_str(), file1.c_str());


        if (err < 0 && errno != ENOENT) {
        if (err < 0 && errno != ENOENT) {