diff --git a/src/restart_counter.c b/src/restart_counter.c index 958ade5..b785844 100644 --- a/src/restart_counter.c +++ b/src/restart_counter.c @@ -33,7 +33,7 @@ UCRCResult uc_restart_counter_init( counter->counter = 0; counter->fd = -1; - fd = open(filename, O_CREAT|O_RDWR, 0600); + fd = open(filename, O_CREAT|O_RDWR, 0644); if (fd == -1) { return UC_RC_ERR_FILE_ACCESS_ERROR; @@ -62,6 +62,7 @@ UCRCResult uc_restart_counter_init( if (lseek(fd, 0, SEEK_SET) != 0 || ftruncate(fd,0) != 0) { rc = UC_RC_ERR_UNSPECIFIED; + goto done; } @@ -75,6 +76,9 @@ UCRCResult uc_restart_counter_init( rc = UC_RC_ERR_UNSPECIFIED; } + fsync(fd); + +done: if ((flags & UC_RC_FL_LOCK_FILE) == 0) { close(fd); }