char tfn[1024];
snprintf(tfn, sizeof(tfn), "%s.new", fn);
- int fd = TEMP_FAILURE_RETRY(::open(tfn, O_WRONLY|O_CREAT, 0600));
+ int fd = TEMP_FAILURE_RETRY(::open(tfn, O_WRONLY|O_CREAT|O_TRUNC, 0600));
if (fd < 0) {
int err = errno;
derr << "MonitorStore::put_int: failed to open '" << tfn << "': "
snprintf(fn, sizeof(fn), "%s/%llu", dfn, (long long unsigned)p->first);
snprintf(tfn, sizeof(tfn), "%s.new", fn);
- int fd = ::open(tfn, O_WRONLY|O_CREAT, 0600);
+ int fd = ::open(tfn, O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (fd < 0) {
int err = -errno;
derr << "failed to open " << tfn << ": " << cpp_strerror(err) << dendl;