int create_image() { int r; int order = 0; r = rados_create(&cluster, NULL); if (r < 0) { simple_err("Could not create cluster handle", r); return r; } rados_conf_parse_env(cluster, NULL); r = rados_conf_read_file(cluster, NULL); if (r < 0) { simple_err("Error reading ceph config file", r); goto failed_shutdown; } r = rados_connect(cluster); if (r < 0) { simple_err("Error connecting to cluster", r); goto failed_shutdown; } r = krbd_create_from_context(rados_cct(cluster), &krbd); if (r < 0) { simple_err("Could not create libkrbd handle", r); goto failed_shutdown; } r = rados_pool_create(cluster, pool); if (r < 0 && r != -EEXIST) { simple_err("Error creating pool", r); goto failed_krbd; } r = rados_ioctx_create(cluster, pool, &ioctx); if (r < 0) { simple_err("Error creating ioctx", r); goto failed_krbd; } if (clone_calls) { r = rbd_create2(ioctx, iname, 0, RBD_FEATURE_LAYERING, &order); } else { r = rbd_create(ioctx, iname, 0, &order); } if (r < 0) { simple_err("Error creating image", r); goto failed_open; } return 0; failed_open: rados_ioctx_destroy(ioctx); failed_krbd: krbd_destroy(krbd); failed_shutdown: rados_shutdown(cluster); return r; }
int rbdfs_create(const char *path, mode_t mode, struct fuse_file_info *fi) { int r; int order = imageorder; r = rbd_create2(ioctx, path+1, imagesize, imagefeatures, &order); return r; }