]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
authtool: useful error/output msg when creating new key file
authorSage Weil <sage@newdream.net>
Thu, 22 Oct 2009 18:25:29 +0000 (11:25 -0700)
committerSage Weil <sage@newdream.net>
Thu, 22 Oct 2009 18:25:29 +0000 (11:25 -0700)
src/authtool.cc
src/common/buffer.cc
src/include/buffer.h
src/vstart.sh

index b37b8579dee447bdb1eeed9e16f9d9fa704fc9e0..6bf09367facaedcdfdc62dd30efb13b1984be804 100644 (file)
@@ -78,7 +78,7 @@ int main(int argc, const char **argv)
   key.create(CEPH_SECRET_AES);
 
   bufferlist bl;
-  int r = bl.read_file(fn);
+  int r = bl.read_file(fn, true);
   if (r >= 0) {
     try {
       bufferlist::iterator iter = bl.begin();
@@ -87,6 +87,11 @@ int main(int argc, const char **argv)
       cerr << "error reading file " << fn << std::endl;
       exit(1);
     }
+  } else if (r == -ENOENT) {
+    cout << "creating " << fn << std::endl;
+  } else {
+    cerr << "can't open " << fn << ": " << strerror(errno) << std::endl;
+    exit(1);
   }
 
   if (gen_key) {
index 592943d0d64a2965ad3c3f21729cdbca278621ca..ea079ecdd1a0767e800168b3a96c892c3d310215 100644 (file)
 
 atomic_t buffer_total_alloc;
 
-int buffer::list::read_file(const char *fn)
+int buffer::list::read_file(const char *fn, bool silent)
 {
   struct stat st;
   int fd = ::open(fn, O_RDONLY);
   if (fd < 0) {
-    char buf[80];
-    cerr << "can't open " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
+    if (!silent) {
+      char buf[80];
+      cerr << "can't open " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
+    }
     return -errno;
   }
   ::fstat(fd, &st);
index 89edd5304267292693665ab5e5913bbbb5a6e4de..c0720ace3edb6d6c91c166da1b2c1280f15f4d28 100644 (file)
@@ -1089,7 +1089,7 @@ public:
     }
 
     void hexdump(std::ostream &out);
-    int read_file(const char *fn);
+    int read_file(const char *fn, bool silent=false);
     int write_file(const char *fn);
     __u32 crc32c(__u32 crc) {
       for (std::list<ptr>::const_iterator it = _buffers.begin(); 
index 7d32b3d2e38fb427fa81fc2da705863021bdbeb9..32f18481033303a162d00c931cf72826cac3a803 100755 (executable)
@@ -185,6 +185,7 @@ echo "ip $IP"
 
 monkeys_fn=monkeys.bin
 CEPH_ADM="$CEPH_BIN/ceph -k $monkeys_fn -I admin"
+test -e $monkeys_fn && rm $monkeys_fn
 
 if [ "$start_mon" -eq 1 ]; then
        if [ "$new" -eq 1 ]; then
@@ -250,7 +251,7 @@ EOF
 
                for f in `seq 0 $((CEPH_NUM_MON-1))`
                do
-                   echo $CEPH_BIN/mkmonfs --clobber --mon-data dev/mon$f -i $f --monmap .ceph_monmap --osdmap .ceph_osdmap
+                   echo $CEPH_BIN/mkmonfs -c $conf --clobber --mon-data dev/mon$f -i $f --monmap=.ceph_monmap --osdmap=.ceph_osdmap --keys-file=$monkeys_fn
                    $CEPH_BIN/mkmonfs -c $conf --clobber --mon-data=dev/mon$f -i $f --monmap=.ceph_monmap --osdmap=.ceph_osdmap --keys-file=$monkeys_fn
                done
        fi