Open restart file in 0644 mode, fsync the file, don't
write to file if seek/truncate failed
This commit is contained in:
@@ -33,7 +33,7 @@ UCRCResult uc_restart_counter_init(
|
|||||||
counter->counter = 0;
|
counter->counter = 0;
|
||||||
counter->fd = -1;
|
counter->fd = -1;
|
||||||
|
|
||||||
fd = open(filename, O_CREAT|O_RDWR, 0600);
|
fd = open(filename, O_CREAT|O_RDWR, 0644);
|
||||||
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return UC_RC_ERR_FILE_ACCESS_ERROR;
|
return UC_RC_ERR_FILE_ACCESS_ERROR;
|
||||||
@@ -62,6 +62,7 @@ UCRCResult uc_restart_counter_init(
|
|||||||
if (lseek(fd, 0, SEEK_SET) != 0 ||
|
if (lseek(fd, 0, SEEK_SET) != 0 ||
|
||||||
ftruncate(fd,0) != 0) {
|
ftruncate(fd,0) != 0) {
|
||||||
rc = UC_RC_ERR_UNSPECIFIED;
|
rc = UC_RC_ERR_UNSPECIFIED;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -75,6 +76,9 @@ UCRCResult uc_restart_counter_init(
|
|||||||
rc = UC_RC_ERR_UNSPECIFIED;
|
rc = UC_RC_ERR_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fsync(fd);
|
||||||
|
|
||||||
|
done:
|
||||||
if ((flags & UC_RC_FL_LOCK_FILE) == 0) {
|
if ((flags & UC_RC_FL_LOCK_FILE) == 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user