]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
strerror -> strerror_r
authorSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 23:17:04 +0000 (16:17 -0700)
committerSage Weil <sage@newdream.net>
Fri, 18 Sep 2009 23:17:04 +0000 (16:17 -0700)
20 files changed:
src/ceph.cc
src/cmon.cc
src/common/buffer.cc
src/cosd.cc
src/crushtool.cc
src/ebofs/BlockDevice.cc
src/mds/Server.cc
src/messages/MClientReply.h
src/messages/MOSDOpReply.h
src/mon/ClientMonitor.cc
src/mon/MonClient.cc
src/mon/Monitor.cc
src/mon/MonitorStore.cc
src/monmaptool.cc
src/msg/SimpleMessenger.cc
src/os/FileJournal.cc
src/os/FileStore.cc
src/os/JournalingObjectStore.cc
src/osdmaptool.cc
src/rados.cc

index f66f8871b2dc4be4f65a078977257e76ba15a745..d32ee9e42c7ad07580cb99e29bfccec673ea9962 100644 (file)
@@ -509,7 +509,8 @@ int do_cli()
       if (out.read_file(infile) == 0) {
        cout << "read " << out.length() << " from " << infile << std::endl;
       } else {
-       cerr << "couldn't read from " << infile << ": " << strerror(errno) << std::endl;
+       char buf[80];
+       cerr << "couldn't read from " << infile << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
        continue;
       }
     }
index 2d8a4bbc30cf985e4e9c2f6f7fc4fbf304b6d75c..d7637badaca6a791047f6641b7f21314d7a4afe8 100644 (file)
@@ -69,7 +69,8 @@ int main(int argc, const char **argv)
   MonitorStore store(g_conf.mon_data);
   err = store.mount();
   if (err < 0) {
-    cerr << "problem opening monitor store in " << g_conf.mon_data << ": " << strerror(-err) << std::endl;
+    char buf[80];
+    cerr << "problem opening monitor store in " << g_conf.mon_data << ": " << strerror_r(-err, buf, sizeof(buf)) << std::endl;
     exit(1);
   }
 
index 9ece38444ef47f0a6705e4daadd7453e9b40d780..592943d0d64a2965ad3c3f21729cdbca278621ca 100644 (file)
@@ -26,7 +26,8 @@ int buffer::list::read_file(const char *fn)
   struct stat st;
   int fd = ::open(fn, O_RDONLY);
   if (fd < 0) {
-    cerr << "can't open " << fn << ": " << strerror(errno) << std::endl;
+    char buf[80];
+    cerr << "can't open " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
     return -errno;
   }
   ::fstat(fd, &st);
@@ -51,7 +52,8 @@ int buffer::list::write_file(const char *fn)
 {
   int fd = ::open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644);
   if (fd < 0) {
-    cerr << "can't write " << fn << ": " << strerror(errno) << std::endl;
+    char buf[80];
+    cerr << "can't write " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
     return -errno;
   }
   for (std::list<ptr>::const_iterator it = _buffers.begin(); 
index 7f9aa23b6ef9627e44e1f25c189b926fbf97e386..d1337fbf265d591b00b5f8db1347b3ffa8afeb9e 100644 (file)
@@ -86,10 +86,11 @@ int main(int argc, const char **argv)
   if (mc.get_monmap_privately() < 0)
     return -1;
 
+  char buf[80];
   if (mkfs) {
     int err = OSD::mkfs(g_conf.osd_data, g_conf.osd_journal, mc.monmap.fsid, whoami);
     if (err < 0) {
-      cerr << "error creating empty object store in " << g_conf.osd_data << ": " << strerror(-err) << std::endl;
+      cerr << "error creating empty object store in " << g_conf.osd_data << ": " << strerror_r(-err, buf, sizeof(buf)) << std::endl;
       exit(1);
     }
     cout << "created object store for osd" << whoami << " fsid " << mc.monmap.fsid << " on " << g_conf.osd_data << std::endl;
@@ -102,10 +103,10 @@ int main(int argc, const char **argv)
   int r = OSD::peek_super(g_conf.osd_data, magic, fsid, w);
   if (r < 0) {
     cerr << TEXT_RED << " ** " << TEXT_HAZARD << "ERROR: " << TEXT_RED
-         << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror(-r) << TEXT_NORMAL << std::endl;
+         << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror_r(-r, buf, sizeof(buf)) << TEXT_NORMAL << std::endl;
     if (r == -ENOTSUP)
       cerr << TEXT_RED << " **        please verify that underlying storage supports xattrs" << TEXT_NORMAL << std::endl;
-    derr(0) << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror(-r) << dendl;
+    derr(0) << "unable to open OSD superblock on " << g_conf.osd_data << ": " << strerror_r(-r, buf, sizeof(buf)) << dendl;
     exit(1);
   }
   if (w != whoami) {
index 423078e784b1c1d761ef4f02b47f329fee6a291e..ceb20afba14a7fbe157582af4e7f5f94d94fc30a 100644 (file)
@@ -701,7 +701,8 @@ int main(int argc, const char **argv)
     bufferlist bl;
     int r = bl.read_file(dinfn);
     if (r < 0) {
-      cerr << me << ": error reading '" << dinfn << "': " << strerror(-r) << std::endl;
+      char buf[80];
+      cerr << me << ": error reading '" << dinfn << "': " << strerror_r(-r, buf, sizeof(buf)) << std::endl;
       exit(1);
     }
     bufferlist::iterator p = bl.begin();
@@ -841,7 +842,8 @@ int main(int argc, const char **argv)
       crush.encode(bl);
       int r = bl.write_file(outfn);
       if (r < 0) {
-       cerr << me << ": error writing '" << outfn << "': " << strerror(-r) << std::endl;
+       char buf[80];
+       cerr << me << ": error writing '" << outfn << "': " << strerror_r(-r, buf, sizeof(buf)) << std::endl;
        exit(1);
       }
       if (verbose)
index fdb7f5a7691604fc067db13a63bdb4cd7d03d489..d0adbbda0e5487a778d0e1f22dd7b3d4a5ed87c9 100644 (file)
@@ -300,7 +300,8 @@ block_t BlockDevice::get_num_blocks()
 #endif
     } else {
       // hmm, try stat!
-      dout(10) << "get_num_blocks ioctl(2) failed with " << errno << " " << strerror(errno) << ", using stat(2)" << dendl;
+      char buf[80];
+      dout(10) << "get_num_blocks ioctl(2) failed with " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << ", using stat(2)" << dendl;
       struct stat st;
       fstat(fd, &st);
       uint64_t bytes = st.st_size;
@@ -714,9 +715,10 @@ int BlockDevice::_write(int fd, unsigned bno, unsigned num, bufferlist& bl)
     int r = ::writev(fd, iov, n);
     
     if (r < 0) {
+      char buf[80];
       dout(1) << "couldn't write bno " << bno << " num " << num 
              << " (" << len << " bytes) in " << n << " iovs,  r=" << r 
-             << " errno " << errno << " " << strerror(errno) << dendl;
+             << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       dout(1) << "bl is " << bl << dendl;
       assert(0);
     } else if (r < (int)len) {
@@ -761,7 +763,8 @@ int BlockDevice::open(kicker *idle)
   // open?
   fd = open_fd();
   if (fd < 0) {
-    dout(1) << "open failed, r = " << fd << " " << strerror(errno) << dendl;
+    char buf[80];
+    dout(1) << "open failed, r = " << fd << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     fd = 0;
     return -1;
   }
index c003846a086c2a56f709ec00e8941428d967e4ca..8a9a421b7cc4aee6b41c377151a5cd9cb29e97bc 100644 (file)
@@ -703,8 +703,9 @@ void Server::early_reply(MDRequest *mdr, CInode *tracei, CDentry *tracedn)
   // mark xlocks "done", indicating that we are exposing uncommitted changes
   mds->locker->set_xlocks_done(mdr);
 
+  char buf[80];
   dout(10) << "early_reply " << reply->get_result() 
-          << " (" << strerror(-reply->get_result())
+          << " (" << strerror_r(-reply->get_result(), buf, sizeof(buf))
           << ") " << *req << dendl;
 
   if (tracei || tracedn) {
@@ -735,8 +736,9 @@ void Server::reply_request(MDRequest *mdr, MClientReply *reply, CInode *tracei,
 {
   MClientRequest *req = mdr->client_request;
   
+  char buf[80];
   dout(10) << "reply_request " << reply->get_result() 
-          << " (" << strerror(-reply->get_result())
+          << " (" << strerror_r(-reply->get_result(), buf, sizeof(buf))
           << ") " << *req << dendl;
 
   // note result code in session map?
index 899a558593926c61de61f1db088e19669547c127..41eacc127cd1ea21af3c314c26ef2c0e7e20b6a5 100644 (file)
@@ -204,8 +204,10 @@ public:
   void print(ostream& o) {
     o << "client_reply(???:" << head.tid;
     o << " = " << get_result();
-    if (get_result() <= 0)
-      o << " " << strerror(-get_result());
+    if (get_result() <= 0) {
+      char buf[80];
+      o << " " << strerror_r(-get_result(), buf, sizeof(buf));
+    }
     if (head.op & CEPH_MDS_OP_WRITE) {
       if (head.safe)
        o << " safe";
index f5d15677d094ba3d2924b5424c0708b5bfd35a41..9e7488486ae35bd6fd00c42cc9bf3a74dc538c74 100644 (file)
@@ -112,8 +112,10 @@ public:
        out << " ack";
     }
     out << " = " << get_result();
-    if (get_result() < 0) 
-      out << " (" << strerror(-get_result()) << ")";
+    if (get_result() < 0) {
+      char buf[80];
+      out << " (" << strerror_r(-get_result(), buf, sizeof(buf)) << ")";
+    }
     out << ")";
   }
 
index a2f0d7ba04dbfab497f667a34ca3b74752565060..85c44f10cb8e9d19682a70d88e5dc9642d77b54f 100644 (file)
@@ -203,7 +203,7 @@ bool ClientMonitor::prepare_mount(MClientMount *m)
   dout(10) << "mount: assigned client" << client << " to " << addr << dendl;
   
   paxos->wait_for_commit(new C_Mounted(this, client, (MClientMount*)m));
-  ss << "client" << client << " " << addr << " mounted";
+  ss << "client" << client << " " << addr;
   mon->get_logclient()->log(LOG_INFO, ss);
   return true;
 }
index 5dcc824e137dd612b6160cb3b75083946d31b834..89b727c53fc9e28f3150a99b99bbe0d5502560fe 100644 (file)
@@ -47,7 +47,8 @@ int MonClient::build_initial_monmap()
     int r = monmap.read(monmap_fn);
     if (r >= 0)
       return 0;
-    cerr << "unable to read monmap from " << monmap_fn << ": " << strerror(errno) << std::endl;
+    char buf[80];
+    cerr << "unable to read monmap from " << monmap_fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
   }
 
   // -m foo?
index 37c0ebd32a2f7a44a45a481c7dadcdf7239eda1b..0cf27ffe858ab33c7e3f1eb75f34c7daf79ec480 100644 (file)
@@ -592,7 +592,8 @@ int Monitor::mkfs(bufferlist& osdmapbl)
   // create it
   int err = store->mkfs();
   if (err < 0) {
-    cerr << "error " << err << " " << strerror(err) << std::endl;
+    char buf[80];
+    cerr << "error " << err << " " << strerror_r(err, buf, sizeof(buf)) << std::endl;
     exit(1);
   }
   
index 4e7582173e8babaaefaebd921a82e10aff344721..0579ffcd07c3e85970cdcab7623ef893559fa546 100644 (file)
@@ -173,7 +173,8 @@ bool MonitorStore::exists_bl_ss(const char *a, const char *b)
   
   struct stat st;
   int r = ::stat(fn, &st);
-  //dout(15) << "exists_bl stat " << fn << " r=" << r << " errno " << errno << " " << strerror(errno) << dendl;
+  //char buf[80];
+  //dout(15) << "exists_bl stat " << fn << " r=" << r << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
   return r == 0;
 }
 
@@ -222,7 +223,10 @@ int MonitorStore::get_bl_ss(bufferlist& bl, const char *a, const char *b)
   while (off < len) {
     dout(20) << "reading at off " << off << " of " << len << dendl;
     int r = ::read(fd, bp.c_str()+off, len-off);
-    if (r < 0) derr(0) << "errno on read " << strerror(errno) << dendl;
+    if (r < 0) {
+      char buf[80];
+      derr(0) << "errno on read " << strerror_r(errno, buf, sizeof(buf)) << dendl;
+    }
     assert(r>0);
     off += r;
   }
@@ -267,8 +271,10 @@ int MonitorStore::write_bl_ss(bufferlist& bl, const char *a, const char *b, bool
     int r = ::write(fd, it->c_str(), it->length());
     if (r != (int)it->length())
       derr(0) << "put_bl_ss ::write() returned " << r << " not " << it->length() << dendl;
-    if (r < 0) 
-      derr(0) << "put_bl_ss ::write() errored out, errno is " << strerror(errno) << dendl;
+    if (r < 0) {
+      char buf[80];
+      derr(0) << "put_bl_ss ::write() errored out, errno is " << strerror_r(errno, buf, sizeof(buf)) << dendl;
+    }
   }
 
   if (sync)
index f6ae62c3aa4066d1e7f99e857ada78d41e36eab7..50b86c75ec23880fdb42092c127019d775c80772 100644 (file)
@@ -97,8 +97,9 @@ int main(int argc, const char **argv)
   if (!(create && clobber))
     r = monmap.read(fn);
 
+  char buf[80];
   if (!create && r < 0) {
-    cerr << me << ": couldn't open " << fn << ": " << strerror(errno) << std::endl;
+    cerr << me << ": couldn't open " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
     return -1;
   }    
   else if (create && !clobber && r == 0) {
@@ -140,7 +141,7 @@ int main(int argc, const char **argv)
         << std::endl;
     int r = monmap.write(fn);
     if (r < 0) {
-      cerr << "monmaptool: error writing to '" << fn << "': " << strerror(-r) << std::endl;
+      cerr << "monmaptool: error writing to '" << fn << "': " << strerror_r(-r, buf, sizeof(buf)) << std::endl;
       return 1;
     }
   }
index 3d6b09085cf1a1f1259575f16c0633940d0db3e5..615928037bec3f3da07e2804264a62e2af358889 100644 (file)
@@ -79,8 +79,9 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce)
   /* socket creation */
   listen_sd = ::socket(AF_INET, SOCK_STREAM, 0);
   if (listen_sd < 0) {
+    char buf[80];
     derr(0) << "accepter.bind unable to create socket: "
-           << strerror(errno) << dendl;
+           << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
   opened_socket();
@@ -94,8 +95,9 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce)
     // specific port
     rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr, sizeof(listen_addr));
     if (rc < 0) {
+      char buf[80];
       derr(0) << "accepter.bind unable to bind to " << g_my_addr.ipaddr
-             << ": " << strerror(errno) << dendl;
+             << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       return -errno;
     }
   } else {
@@ -107,9 +109,10 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce)
        break;
     }
     if (rc < 0) {
+      char buf[80];
       derr(0) << "accepter.bind unable to bind to " << g_my_addr.ipaddr
              << " on any port in range " << CEPH_PORT_START << "-" << CEPH_PORT_LAST
-             << ": " << strerror(errno) << dendl;
+             << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       return -errno;
     }
   }
@@ -123,8 +126,9 @@ int SimpleMessenger::Accepter::bind(int64_t force_nonce)
   // listen!
   rc = ::listen(listen_sd, 128);
   if (rc < 0) {
+    char buf[80];
     derr(0) << "accepter.bind unable to listen on " << g_my_addr.ipaddr 
-           << ": " << strerror(errno) << dendl;
+           << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
   
@@ -183,6 +187,8 @@ void *SimpleMessenger::Accepter::entry()
   // block SIGUSR1
   pthread_sigmask(SIG_BLOCK, &sigmask, NULL);
 
+  char buf[80];
+
   while (!done) {
     FD_ZERO(&fds);
     FD_SET(listen_sd, &fds);
@@ -205,8 +211,8 @@ void *SimpleMessenger::Accepter::entry()
       if (g_conf.ms_tcp_nodelay) {
        int flag = 1;
        int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
-       if (r < 0) 
-         dout(0) << "accepter could't set TCP_NODELAY: " << strerror(errno) << dendl;
+       if (r < 0)
+         dout(0) << "accepter could't set TCP_NODELAY: " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       }
       
       rank->lock.Lock();
@@ -218,7 +224,7 @@ void *SimpleMessenger::Accepter::entry()
       }
       rank->lock.Unlock();
     } else {
-      dout(0) << "accepter no incoming connection?  sd = " << sd << " errno " << errno << " " << strerror(errno) << dendl;
+      dout(0) << "accepter no incoming connection?  sd = " << sd << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       if (++errors > 4)
        break;
     }
@@ -533,7 +539,8 @@ int SimpleMessenger::Pipe::accept()
   socklen_t len = sizeof(socket_addr.ipaddr);
   int r = ::getpeername(sd, (sockaddr*)&socket_addr.ipaddr, &len);
   if (r < 0) {
-    dout(0) << "accept failed to getpeername " << errno << " " << strerror(errno) << dendl;
+    char buf[80];
+    dout(0) << "accept failed to getpeername " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     state = STATE_CLOSED;
     return -1;
   }
@@ -824,7 +831,8 @@ int SimpleMessenger::Pipe::connect()
   // create socket?
   sd = ::socket(AF_INET, SOCK_STREAM, 0);
   if (sd < 0) {
-    dout(-1) << "connect couldn't created socket " << strerror(errno) << dendl;
+    char buf[80];
+    dout(-1) << "connect couldn't created socket " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     assert(0);
     goto fail;
   }
@@ -837,17 +845,20 @@ int SimpleMessenger::Pipe::connect()
   dout(10) << "binding to " << myAddr << dendl;
   rc = ::bind(sd, (struct sockaddr *)&myAddr, sizeof(myAddr));
   if (rc < 0) {
+    char buf[80];
     dout(2) << "bind error " << myAddr
-            << ", " << errno << ": " << strerror(errno) << dendl;
+            << ", " << errno << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
 
+  char buf[80];
+
   // connect!
   dout(10) << "connecting to " << peer_addr.ipaddr << dendl;
   rc = ::connect(sd, (sockaddr*)&peer_addr.ipaddr, sizeof(peer_addr.ipaddr));
   if (rc < 0) {
     dout(2) << "connect error " << peer_addr.ipaddr
-            << ", " << errno << ": " << strerror(errno) << dendl;
+            << ", " << errno << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
 
@@ -856,14 +867,14 @@ int SimpleMessenger::Pipe::connect()
     int flag = 1;
     int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
     if (r < 0) 
-      dout(0) << "connect couldn't set TCP_NODELAY: " << strerror(errno) << dendl;
+      dout(0) << "connect couldn't set TCP_NODELAY: " << strerror_r(errno, buf, sizeof(buf)) << dendl;
   }
 
   // verify banner
   // FIXME: this should be non-blocking, or in some other way verify the banner as we get it.
   rc = tcp_read(sd, (char*)&banner, strlen(CEPH_BANNER));
   if (rc < 0) {
-    dout(2) << "connect couldn't read banner, " << strerror(errno) << dendl;
+    dout(2) << "connect couldn't read banner, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
   if (memcmp(banner, CEPH_BANNER, strlen(CEPH_BANNER))) {
@@ -878,14 +889,14 @@ int SimpleMessenger::Pipe::connect()
   msg.msg_iovlen = 1;
   msglen = msgvec[0].iov_len;
   if (do_sendmsg(sd, &msg, msglen)) {
-    dout(2) << "connect couldn't write my banner, " << strerror(errno) << dendl;
+    dout(2) << "connect couldn't write my banner, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
 
   // identify peer
   rc = tcp_read(sd, (char*)&paddr, sizeof(paddr));
   if (rc < 0) {
-    dout(2) << "connect couldn't read peer addr, " << strerror(errno) << dendl;
+    dout(2) << "connect couldn't read peer addr, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
   dout(20) << "connect read peer addr " << paddr << " on socket " << sd << dendl;
@@ -905,7 +916,7 @@ int SimpleMessenger::Pipe::connect()
   // peer addr for me
   rc = tcp_read(sd, (char*)&peer_addr_for_me, sizeof(peer_addr_for_me));
   if (rc < 0) {
-    dout(2) << "connect couldn't read peer addr for me, " << strerror(errno) << dendl;
+    dout(2) << "connect couldn't read peer addr for me, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
   dout(20) << "connect peer addr for me is " << peer_addr_for_me << dendl;
@@ -920,7 +931,7 @@ int SimpleMessenger::Pipe::connect()
   msg.msg_iovlen = 1;
   msglen = msgvec[0].iov_len;
   if (do_sendmsg(sd, &msg, msglen)) {
-    dout(2) << "connect couldn't write my addr, " << strerror(errno) << dendl;
+    dout(2) << "connect couldn't write my addr, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     goto fail;
   }
   dout(10) << "connect sent my addr " << rank->rank_addr << dendl;
@@ -944,14 +955,14 @@ int SimpleMessenger::Pipe::connect()
     dout(10) << "connect sending gseq=" << gseq << " cseq=" << cseq
             << " proto=" << connect.protocol_version << dendl;
     if (do_sendmsg(sd, &msg, msglen)) {
-      dout(2) << "connect couldn't write gseq, cseq, " << strerror(errno) << dendl;
+      dout(2) << "connect couldn't write gseq, cseq, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       goto fail;
     }
 
     dout(20) << "connect wrote (self +) cseq, waiting for reply" << dendl;
     ceph_msg_connect_reply reply;
     if (tcp_read(sd, (char*)&reply, sizeof(reply)) < 0) {
-      dout(2) << "connect read reply " << strerror(errno) << dendl;
+      dout(2) << "connect read reply " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       goto fail;
     }
     dout(20) << "connect got reply tag " << (int)reply.tag
@@ -1095,8 +1106,9 @@ void SimpleMessenger::Pipe::fault(bool onconnect, bool onread)
     dout(10) << "fault already connecting, reader shutting down" << dendl;
     return;
   }
-
-  if (!onconnect) dout(2) << "fault " << errno << ": " << strerror(errno) << dendl;
+  
+  char buf[80];
+  if (!onconnect) dout(2) << "fault " << errno << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
 
   if (state == STATE_CLOSED ||
       state == STATE_CLOSING) {
@@ -1260,12 +1272,13 @@ void SimpleMessenger::Pipe::reader()
 
     lock.Unlock();
 
+    char buf[80];
     char tag = -1;
     dout(20) << "reader reading tag..." << dendl;
     int rc = tcp_read(sd, (char*)&tag, 1);
     if (rc < 0) {
       lock.Lock();
-      dout(2) << "reader couldn't read tag, " << strerror(errno) << dendl;
+      dout(2) << "reader couldn't read tag, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       fault(false, true);
       continue;
     }
@@ -1283,7 +1296,7 @@ void SimpleMessenger::Pipe::reader()
       int rc = tcp_read( sd, (char*)&seq, sizeof(seq));
       lock.Lock();
       if (rc < 0) {
-       dout(2) << "reader couldn't read ack seq, " << strerror(errno) << dendl;
+       dout(2) << "reader couldn't read ack seq, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
        fault(false, true);
       } else if (state != STATE_CLOSED) {
        dout(15) << "reader got ack seq " << seq << dendl;
@@ -1307,7 +1320,7 @@ void SimpleMessenger::Pipe::reader()
       lock.Lock();
       
       if (!m) {
-       derr(2) << "reader read null message, " << strerror(errno) << dendl;
+       derr(2) << "reader read null message, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
        fault(false, true);
        continue;
       }
@@ -1431,6 +1444,8 @@ public:
  */
 void SimpleMessenger::Pipe::writer()
 {
+  char buf[80];
+
   lock.Lock();
 
   while (state != STATE_CLOSED) {// && state != STATE_WAIT) {
@@ -1470,7 +1485,7 @@ void SimpleMessenger::Pipe::writer()
        int rc = write_keepalive();
        lock.Lock();
        if (rc < 0) {
-         dout(2) << "writer couldn't write keepalive, " << strerror(errno) << dendl;
+         dout(2) << "writer couldn't write keepalive, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
          fault();
          continue;
        }
@@ -1484,7 +1499,7 @@ void SimpleMessenger::Pipe::writer()
        int rc = write_ack(send_seq);
        lock.Lock();
        if (rc < 0) {
-         dout(2) << "writer couldn't write ack, " << strerror(errno) << dendl;
+         dout(2) << "writer couldn't write ack, " << strerror_r(errno, buf, sizeof(buf)) << dendl;
          fault();
          continue;
        }
@@ -1510,7 +1525,7 @@ void SimpleMessenger::Pipe::writer()
        lock.Lock();
        if (rc < 0) {
           derr(1) << "writer error sending " << m << ", "
-                 << errno << ": " << strerror(errno) << dendl;
+                 << errno << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
          fault();
         }
        m->put();
@@ -1668,6 +1683,8 @@ Message *SimpleMessenger::Pipe::read_message()
 
 int SimpleMessenger::Pipe::do_sendmsg(int sd, struct msghdr *msg, int len, bool more)
 {
+  char buf[80];
+
   while (len > 0) {
     if (0) { // sanity
       int l = 0;
@@ -1680,7 +1697,7 @@ int SimpleMessenger::Pipe::do_sendmsg(int sd, struct msghdr *msg, int len, bool
     if (r == 0) 
       dout(10) << "do_sendmsg hmm do_sendmsg got r==0!" << dendl;
     if (r < 0) { 
-      dout(1) << "do_sendmsg error " << strerror(errno) << dendl;
+      dout(1) << "do_sendmsg error " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       return -1;
     }
     if (state == STATE_CLOSED) {
index eeafd32fed6e75c89a38ed082255d3bcd76ed08e..623d60280a3918648ac32d32d6a2251a59d3e49f 100644 (file)
@@ -29,6 +29,7 @@
 
 int FileJournal::_open(bool forwrite, bool create)
 {
+  char buf[80];
   int flags;
 
   if (forwrite) {
@@ -44,7 +45,7 @@ int FileJournal::_open(bool forwrite, bool create)
     ::close(fd);
   fd = ::open(fn.c_str(), flags, 0644);
   if (fd < 0) {
-    dout(2) << "_open failed " << errno << " " << strerror(errno) << dendl;
+    dout(2) << "_open failed " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
 
@@ -90,6 +91,7 @@ int FileJournal::_open(bool forwrite, bool create)
 
 int FileJournal::create()
 {
+  char buf[80];
   dout(2) << "create " << fn << dendl;
 
   int err = _open(true, true);
@@ -111,7 +113,7 @@ int FileJournal::create()
   buffer::ptr bp = prepare_header();
   int r = ::pwrite(fd, bp.c_str(), bp.length(), 0);
   if (r < 0) {
-    dout(0) << "create write header error " << errno << " " << strerror(errno) << dendl;
+    dout(0) << "create write header error " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
 
@@ -247,8 +249,10 @@ void FileJournal::read_header()
     memset(&header, 0, sizeof(header));  // zero out (read may fail)
     r = ::pread(fd, &header, sizeof(header), 0);
   }
-  if (r < 0) 
-    dout(0) << "read_header error " << errno << " " << strerror(errno) << dendl;
+  if (r < 0) {
+    char buf[80];
+    dout(0) << "read_header error " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
+  }
   print_header();
 }
 
@@ -493,10 +497,12 @@ void FileJournal::do_write(bufferlist& bl)
        it++) {
     if ((*it).length() == 0) continue;  // blank buffer.
     int r = ::write(fd, (char*)(*it).c_str(), (*it).length());
-    if (r < 0)
-      derr(0) << "do_write failed with " << errno << " " << strerror(errno) 
+    if (r < 0) {
+      char buf[80];
+      derr(0) << "do_write failed with " << errno << " " << strerror_r(errno, buf, sizeof(buf)) 
              << " with " << (void*)(*it).c_str() << " len " << (*it).length()
              << dendl;
+    }
     pos += (*it).length();
   }
   if (!directio) {
index c9f7bdcfa41ad3f87745d65d84d3e166372172df..21a31b5476b07ae1ae37a935a783a36adb6ec845 100644 (file)
@@ -388,7 +388,8 @@ int FileStore::lock_fsid()
   l.l_len = 0;
   int r = ::fcntl(fsid_fd, F_SETLK, &l);
   if (r < 0) {
-    derr(0) << "mount failed to lock " << basedir << "/fsid, is another cosd still running? " << strerror(errno) << dendl;
+    char buf[80];
+    derr(0) << "mount failed to lock " << basedir << "/fsid, is another cosd still running? " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
   return 0;
@@ -396,6 +397,8 @@ int FileStore::lock_fsid()
 
 int FileStore::mount() 
 {
+  char buf[80];
+
   if (g_conf.filestore_dev) {
     dout(0) << "mounting" << dendl;
     char cmd[100];
@@ -409,7 +412,7 @@ int FileStore::mount()
   struct stat st;
   int r = ::stat(basedir.c_str(), &st);
   if (r != 0) {
-    derr(0) << "unable to stat basedir " << basedir << ", " << strerror(errno) << dendl;
+    derr(0) << "unable to stat basedir " << basedir << ", " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     return -errno;
   }
   
@@ -433,7 +436,7 @@ int FileStore::mount()
             << " " << strerror(errno)
             << dendl;*/
     if (x != y) {
-      derr(0) << "xattrs don't appear to work (" << strerror(errno) << ") on " << basedir << ", be sure to mount underlying file system with 'user_xattr' option" << dendl;
+      derr(0) << "xattrs don't appear to work (" << strerror_r(errno, buf, sizeof(buf)) << ") on " << basedir << ", be sure to mount underlying file system with 'user_xattr' option" << dendl;
       return -errno;
     }
   }
@@ -500,11 +503,11 @@ int FileStore::mount()
     if (r == -EBADF) {
       dout(0) << "mount detected shiny new btrfs" << dendl;      
     } else {
-      dout(0) << "mount detected dingey old btrfs (r=" << r << " " << strerror(-r) << ")" << dendl;
+      dout(0) << "mount detected dingey old btrfs (r=" << r << " " << strerror_r(-r, buf, sizeof(buf)) << ")" << dendl;
       btrfs = 1;
     }
   } else {
-    dout(0) << "mount did NOT detect btrfs: " << strerror(-r) << dendl;
+    dout(0) << "mount did NOT detect btrfs: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
     btrfs = 0;
   }
 
@@ -629,14 +632,15 @@ int FileStore::_transaction_start(int len)
       !g_conf.filestore_btrfs_trans)
     return 0;
 
+  char buf[80];
   int fd = ::open(basedir.c_str(), O_RDONLY);
   if (fd < 0) {
-    derr(0) << "transaction_start got " << strerror(errno)
+    derr(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf))
            << " from btrfs open" << dendl;
     assert(0);
   }
   if (::ioctl(fd, BTRFS_IOC_TRANS_START) < 0) {
-    derr(0) << "transaction_start got " << strerror(errno)
+    derr(0) << "transaction_start got " << strerror_r(errno, buf, sizeof(buf))
            << " from btrfs ioctl" << dendl;    
     ::close(fd);
     return -errno;
@@ -1209,7 +1213,7 @@ unsigned FileStore::apply_transaction(Transaction &t, Context *onsafe)
   if (trans->len) {
     r = ::ioctl(fsid_fd, BTRFS_IOC_USERTRANS, (unsigned long)trans);
     if (r < 0) {
-      derr(0) << "apply_transaction_end got " << strerror(errno)
+      derr(0) << "apply_transaction_end got " << strerror_r(errno, buf, sizeof(buf))
              << " from btrfs usertrans ioctl" << dendl;    
       r = -errno;
     } 
@@ -1266,7 +1270,8 @@ int FileStore::read(coll_t cid, const sobject_t& oid,
   int r;
   int fd = ::open(fn, O_RDONLY);
   if (fd < 0) {
-    dout(10) << "read couldn't open " << fn << " errno " << errno << " " << strerror(errno) << dendl;
+    char buf[80];
+    dout(10) << "read couldn't open " << fn << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     r = -errno;
   } else {
     __u64 actual = ::lseek64(fd, offset, SEEK_SET);
@@ -1345,10 +1350,11 @@ int FileStore::_write(coll_t cid, const sobject_t& oid,
   dout(15) << "write " << fn << " " << offset << "~" << len << dendl;
   int r;
 
+  char buf[80];
   int flags = O_WRONLY|O_CREAT;
   int fd = ::open(fn, flags, 0644);
   if (fd < 0) {
-    derr(0) << "write couldn't open " << fn << " flags " << flags << " errno " << errno << " " << strerror(errno) << dendl;
+    derr(0) << "write couldn't open " << fn << " flags " << flags << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     r = -errno;
   } else {
     
@@ -1365,12 +1371,12 @@ int FileStore::_write(coll_t cid, const sobject_t& oid,
       if (r > 0)
        did += r;
       else {
-       derr(0) << "couldn't write to " << fn << " len " << len << " off " << offset << " errno " << errno << " " << strerror(errno) << dendl;
+       derr(0) << "couldn't write to " << fn << " len " << len << " off " << offset << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
       }
     }
     
     if (did < 0) {
-      derr(0) << "couldn't write to " << fn << " len " << len << " off " << offset << " errno " << errno << " " << strerror(errno) << dendl;
+      derr(0) << "couldn't write to " << fn << " len " << len << " off " << offset << " errno " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
     }
     
     ::close(fd);
@@ -1735,7 +1741,8 @@ int FileStore::_setattrs(coll_t cid, const sobject_t& oid, map<nstring,bufferptr
       val = "";
     r = do_setxattr(fn, n, val, p->second.length());
     if (r < 0) {
-      cerr << "error setxattr " << strerror(errno) << std::endl;
+      char buf[80];
+      cerr << "error setxattr " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
       break;
     }
   }
index aa9d52352a22ed0fcd1167994a3ea68c3f9a9414..dac595cff68ca1ca34ba1be8aaec540894e3afce 100644 (file)
@@ -15,8 +15,9 @@ int JournalingObjectStore::journal_replay()
 
   int err = journal->open(op_seq+1);
   if (err < 0) {
+    char buf[80];
     dout(3) << "journal_replay open failed with" << err
-           << " " << strerror(err) << dendl;
+           << " " << strerror_r(err, buf, sizeof(buf)) << dendl;
     delete journal;
     journal = 0;
     return err;
index ac9b92699289171c591394916b31bb4144d30c52..5cb650651222c3c9d37ba05d27eb178e14518570 100644 (file)
@@ -105,8 +105,9 @@ int main(int argc, const char **argv)
     r = bl.read_file(fn);
     osdmap.decode(bl);
   }
+  char buf[80];
   if (!createsimple && r < 0) {
-    cerr << me << ": couldn't open " << fn << ": " << strerror(errno) << std::endl;
+    cerr << me << ": couldn't open " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
     return -1;
   }    
   else if (createsimple && !clobber && r == 0) {
@@ -223,7 +224,7 @@ int main(int argc, const char **argv)
         << std::endl;
     int r = bl.write_file(fn);
     if (r < 0) {
-      cerr << "osdmaptool: error writing to '" << fn << "': " << strerror(-r) << std::endl;
+      cerr << "osdmaptool: error writing to '" << fn << "': " << strerror_r(-r, buf, sizeof(buf)) << std::endl;
       return 1;
     }
   }
index 0bc750d0d9cc74df8f3cb24fc7c6f339de6ed1d5..46a59737e91d2128c8591a5bc4559469c420767d 100644 (file)
@@ -272,13 +272,14 @@ int main(int argc, const char **argv)
   }
 
   int ret = 0;
+  char buf[80];
 
   // open pool?
   rados_pool_t p;
   if (pool) {
     ret = rados.open_pool(pool, &p);
     if (ret < 0) {
-      cerr << "error opening pool " << pool << ": " << strerror(-ret) << std::endl;
+      cerr << "error opening pool " << pool << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
   }
@@ -287,7 +288,7 @@ int main(int argc, const char **argv)
   if (snapname) {
     ret = rados.snap_lookup(p, snapname, &snapid);
     if (ret < 0) {
-      cerr << "error looking up snap '" << snapname << "': " << strerror(-ret) << std::endl;
+      cerr << "error looking up snap '" << snapname << "': " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
   }
@@ -355,7 +356,7 @@ int main(int argc, const char **argv)
       list<object_t> vec;
       ret = rados.list(p, 1 << 10, vec, ctx);
       if (ret < 0) {
-       cerr << "got error: " << strerror(-ret) << std::endl;
+       cerr << "got error: " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
        goto out;
       }
       if (vec.empty())
@@ -373,7 +374,7 @@ int main(int argc, const char **argv)
     object_t oid(nargs[1]);
     ret = rados.read(p, oid, 0, outdata, 0);
     if (ret < 0) {
-      cerr << "error reading " << pool << "/" << oid << ": " << strerror(-ret) << std::endl;
+      cerr << "error reading " << pool << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
 
@@ -401,14 +402,14 @@ int main(int argc, const char **argv)
     } else {
       ret = indata.read_file(nargs[2]);
       if (ret) {
-       cerr << "error reading input file " << nargs[2] << ": " << strerror(-ret) << std::endl;
+       cerr << "error reading input file " << nargs[2] << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
        goto out;
       }
     }
 
     ret = rados.write_full(p, oid, indata);
     if (ret < 0) {
-      cerr << "error writing " << pool << "/" << oid << ": " << strerror(-ret) << std::endl;
+      cerr << "error writing " << pool << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
   }
@@ -418,7 +419,7 @@ int main(int argc, const char **argv)
     object_t oid(nargs[1]);
     ret = rados.remove(p, oid);
     if (ret < 0) {
-      cerr << "error removing " << pool << "/" << oid << ": " << strerror(-ret) << std::endl;
+      cerr << "error removing " << pool << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
   }
@@ -464,7 +465,7 @@ int main(int argc, const char **argv)
     ret = rados.snap_create(p, nargs[1]);
     if (ret < 0) {
       cerr << "error creating pool " << pool << " snapshot " << nargs[1]
-          << ": " << strerror(-ret) << std::endl;
+          << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
     cout << "created pool " << pool << " snap " << nargs[1] << std::endl;
@@ -477,7 +478,7 @@ int main(int argc, const char **argv)
     ret = rados.snap_remove(p, nargs[1]);
     if (ret < 0) {
       cerr << "error removing pool " << pool << " snapshot " << nargs[1]
-          << ": " << strerror(-ret) << std::endl;
+          << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       goto out;
     }
     cout << "removed pool " << pool << " snap " << nargs[1] << std::endl;