If the mon-data directory does not exist when ceph-mon --mkfs runs, it
is created.
Signed-off-by: Loic Dachary <loic@dachary.org>
return -ENOENT;
}
+int mon_data_exists(bool *r)
+{
+ string mon_data = g_conf->mon_data;
+ struct stat buf;
+ if (::stat(mon_data.c_str(), &buf)) {
+ if (errno == ENOENT) {
+ *r = false;
+ } else {
+ cerr << "stat(" << mon_data << ") " << strerror(errno) << std::endl;
+ return -errno;
+ }
+ } else {
+ *r = true;
+ }
+ return 0;
+}
void usage()
{
usage();
}
+ bool exists;
// -- mkfs --
if (mkfs) {
+
+ if (mon_data_exists(&exists))
+ exit(1);
+
+ if (!exists) {
+ if (::mkdir(g_conf->mon_data.c_str(), 0755)) {
+ cerr << "mkdir(" << g_conf->mon_data << ") : "
+ << strerror(errno) << std::endl;
+ exit(1);
+ }
+ }
+
// resolve public_network -> public_addr
pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC);