From 7b0315e84d4d0d5f95f8a5dc891df386206300bb Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 4 Oct 2007 21:28:27 +0000 Subject: [PATCH] set file mode atomically git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1884 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/mon/MonitorStore.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/branches/sage/mds/mon/MonitorStore.cc b/branches/sage/mds/mon/MonitorStore.cc index 30eb4796a5383..86df22bcd6590 100644 --- a/branches/sage/mds/mon/MonitorStore.cc +++ b/branches/sage/mds/mon/MonitorStore.cc @@ -109,9 +109,8 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) char tfn[200]; sprintf(tfn, "%s.new", fn); - int fd = ::open(tfn, O_WRONLY|O_CREAT); + int fd = ::open(tfn, O_WRONLY|O_CREAT, 0644); assert(fd > 0); - ::fchmod(fd, 0644); ::write(fd, vs, strlen(vs)); ::close(fd); ::rename(tfn, fn); @@ -201,12 +200,9 @@ int MonitorStore::put_bl_ss(bufferlist& bl, const char *a, const char *b) char tfn[200]; sprintf(tfn, "%s.new", fn); - int fd = ::open(tfn, O_WRONLY|O_CREAT); + int fd = ::open(tfn, O_WRONLY|O_CREAT, 0644); assert(fd); - // chmod - ::fchmod(fd, 0644); - // write data for (list::const_iterator it = bl.buffers().begin(); it != bl.buffers().end(); -- 2.39.5