~ubuntu-branches/ubuntu/precise/ceph/precise

« back to all changes in this revision

Viewing changes to src/mon/MonitorStore.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "include/types.h"
19
19
#include "include/buffer.h"
20
20
 
 
21
#include <iosfwd>
21
22
#include <string.h>
22
23
 
23
24
class MonitorStore {
25
26
  int lock_fd;
26
27
 
27
28
  int write_bl_ss(bufferlist& bl, const char *a, const char *b, bool append, bool sync=true);
 
29
 
28
30
public:
 
31
  class Error : public std::exception
 
32
  {
 
33
  public:
 
34
    static Error FromErrno(const char *prefix,
 
35
                                  const char *prefix2, int errno_);
 
36
    Error(const std::string &str_);
 
37
    virtual ~Error() throw ();
 
38
    const char *what() const throw ();
 
39
  private:
 
40
    std::string str;
 
41
  };
 
42
 
29
43
  MonitorStore(const char *d) : dir(d) { }
30
44
  ~MonitorStore() { }
31
45
 
51
65
  }
52
66
  bool exists_bl_sn(const char *a, version_t b) {
53
67
    char bs[20];
54
 
    sprintf(bs, "%llu", (unsigned long long)b);
 
68
    snprintf(bs, sizeof(bs), "%llu", (unsigned long long)b);
55
69
    return exists_bl_ss(a, bs);
56
70
  }
57
71
  int get_bl_sn(bufferlist& bl, const char *a, version_t b) {
58
72
    char bs[20];
59
 
    sprintf(bs, "%llu", (unsigned long long)b);
 
73
    snprintf(bs, sizeof(bs), "%llu", (unsigned long long)b);
60
74
    return get_bl_ss(bl, a, bs);
61
75
  }
62
76
  int put_bl_sn(bufferlist& bl, const char *a, version_t b, bool sync=true) {
63
77
    char bs[20];
64
 
    sprintf(bs, "%llu", (unsigned long long)b);
 
78
    snprintf(bs, sizeof(bs), "%llu", (unsigned long long)b);
65
79
    return put_bl_ss(bl, a, bs, sync);
66
80
  }
67
81
 
68
82
  int erase_ss(const char *a, const char *b);
69
83
  int erase_sn(const char *a, version_t b) {
70
84
    char bs[20];
71
 
    sprintf(bs, "%llu", (unsigned long long)b);
 
85
    snprintf(bs, sizeof(bs), "%llu", (unsigned long long)b);
72
86
    return erase_ss(a, bs);
73
87
  }
74
88