Merge "logcatd: unset pinning log files" into rvc-dev am: 04083e2ba8 am: 0561cefc44 am: ead6029693

Change-Id: Icf21c968bf9b61bc7bb545cc5dea42235c758227
This commit is contained in:
TreeHugger Robot 2020-04-23 23:27:43 +00:00 committed by Automerger Merge Worker
commit 27eff567b7
1 changed files with 14 additions and 0 deletions

View File

@ -122,6 +122,18 @@ static int openLogFile(const char* pathname, size_t sizeKB) {
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() {
// Can't rotate logs if we're not outputting to a file
if (!output_file_name_) return;
@ -152,6 +164,8 @@ void Logcat::RotateLogs() {
break;
}
closeLogFile(file0.c_str());
int err = rename(file0.c_str(), file1.c_str());
if (err < 0 && errno != ENOENT) {